The main purpose of Viewpoint collaborative features is to allow users to collaborate in real-time around semantic models and representations. Although Viewpoint provides default behavior and UI for collaboration, you are totally free to use Viewpoint as a platform and build your own features uppon it, or customize existing behaviors.
The following documentation will give you an overview of the Collaborative API provided by Viewpoint. Feel free to consult the common collaborative use case documentation and the advanced collaborative use case documentation to see examples of Collaborative features use and customization.
Viewpoint collaborative features are based on the CDO technology (please refer to CDO documentation for additional informations).
These features are defined in the following plugins:
fr.obeo.dsl.viewpoint.collab
plugin contains all the non-UI collaborative behavior (API for connecting to CDO Repositories, lock/unlock elements, customize authentication and lock strategies...).
fr.obeo.dsl.viewpoint.collab.ui
plugin contains all UI related to collaborative features (decoration of locked elements, Lock/Unlock Actions, Collaborative Wizards...).
fr.obeo.dsl.viewpoint.collab.ui.diagram
,
fr.obeo.dsl.viewpoint.collab.ui.table
and
fr.obeo.dsl.viewpoint.collab.ui.tree
plugins contain all UI specific to each kind of representation.
Viewpoint also provides a
Collaborative Test Framework through the
fr.obeo.dsl.viewpoint.tests.collab.*
plugins.
The
fr.obeo.dsl.viewpoint.collab.api.remotesession.CollaborativeSession
interface represents any Viewpoint Session able to reference semantic resources or representations located on a remote CDO Repository.
When the collaborative mode is active (i.e. if
CDOViewpointPreferenceKeys.COLLABORATIVE_MODE_ACTIVATED
is true), all Viewpoint Sessions created by calling
fr.obeo.dsl.viewpoint.business.api.session.factory.SessionFactory
or through the
fr.obeo.dsl.viewpoint.business.api.session.SessionManager
will implement this interface.
This interface provides collaborative behavior for Viewpoint sessions.
You will be able to connect a Collaborative Session to a CDO repository. This will create a new
CDOTransaction
on the described repository. Consequently, when the user will try to add a remote CDO model or representation to this session, the repository location will be pre-filled.
Notice that as soon as a Remote Semantic Resource or Representation is referenced by the Collaborative Session, the session
will connect itself to the corresponding CDO Repository. So you should use the
connect(RepositoryConfig)
method only if you want a Collaborative Session to be connected by default (even if empty) to a certain repository.
// Step 1: create the RepositoryConfig describing my repository location
RepositoryConfig repositoryConfig = CDOConfigFactory.eINSTANCE.createRepositoryConfig();
repositoryConfig.setHostLocation("localhost:2036");
repositoryConfig.setRepositoryName("myRepo");
// Step 2: connect my Session to this repository
session.connect(repositoryConfig);
If a Collaborative Session has been
connected (explicitly or automatically) to a CDO Repository, you can easily get the
RepositoryManager associated to this session: simply call
session.getRepositoryManager()
.
When user saves his session, if the modifications are impacting elements located on a CDO Repository, we can:
CDOPushTransaction
for additional informations). Such modifications saved locally will be kept local until the user actually commit them.
The default behavior is to check the Collaborative preferences:
CDOViewpointPreferenceKeys.PREF_ENABLE_DURABLE_LOCKING
or
CDOViewpointPreferenceKeys.PREF_ENABLE_SAVE_AND_COMMIT_DECORELATION
is false, we align commit and save (always commit when a save is performed).
CDOViewpointPreferenceKeys.PREF_BY_DEFAULT_COMMIT_ON_SAVE
preference. If true, then we commit on save ; otherwise we save locally.
Thanks to the
session.setCommitOnSave(boolean)
method, you can specify whether the
next call to
session.save()
will commit the changes (if the parameter is
true
) or same them locally (if
false
).
Notice that committing changes or saving them locally has impact on lock releasing.
The
session.setDefaultRepresentationContainer(URI danalysisURI)
method allows you to specify in which
DAnalysis
new representations should be stored. Using this method, you can easily force all new representations to be created on the repository.
// Step 1: get all the Remote DAnalysis associated to our current session
Iterable<CDOResource> remoteDAnalyses = Iterables.filter(collaborativeSession.getAllSessionResources(), CDOResource.class);
// Step 2: we say that all new representations should be created
// in the first Remote DAnalysis we found
if (remoteDAnalyses.iterator().hasNext()){
collaborativeSession.setDefaultRepresentationContainer(remoteDAnalyses.iterator().next().getURI());
}
The
fr.obeo.dsl.viewpoint.collab.api.CDORepositoryManager
handles the lifecycle of CDOTransactions and CDOSessions.
You should not open your own CDOTransactions, but rely on the CDORepositoryManager to do so.
The fundamental rules of the CDORepositoryManager are:
The
fr.obeo.dsl.viewpoint.collab.api.CDORepositoryManagerRegistry
is in charge of creating and deleting
CDORepositoryManager
when needed.
You can easily get the CDOTransaction associated to a Collaborative session:
// Step 1: get the CDORepositoryManager
// using the repository configuration
CDORepositoryManager manager = CDORepositoryManagerRegistry.getRepositoryManager(repositoryConfig);
// using directly the session:
CDORepositoryManager manager = CDORepositoryManagerRegistry.getRepositoryManager(session);
// or
CDORepositoryManager manager = session.getRepositoryManager();
// Step 2: get the CDOTransaction associated to the session
CDOTransaction transaction = manager.getOrCreateTransaction(session);
Notice that the CDORepositoryManager already handles CDOTransactions lifecycle: CDOTransactions are opened when a Collaborative Session referencing a CDORepository is opened and close when this session is closed.
However, you may need to open or close CDOTransactions that are not linked to any viewpoint session, to make some modifications on the CDO Repository.
// Step 1: creating a resource set for my transaction
ResourceSet rs = new ResourceSetImpl();
// Step 2: open a transaction on this resourceSet
CDORepositoryManager manager = CDORepositoryManagerRegistry.getRepositoryManager(config);
CDOTransaction transaction = manager.getOrCreateTransaction(rs);
// Step 3: using the transaction to modify the repository content
transaction.getOrCreateResource("myNewResource");
transaction.commit();
// Step 4: close the transaction
// this will also close the CDOSession
// and dispose the CDORepositoryManager
manager.closeTransaction(transaction);
The CDOLockManager allows you to determine whether an element is:
CDOWriteLock
on it)
CDOWriteLock
on it)
You can use the
boolean isLockedByOthers(EObject element)
,
boolean isLockedByAny
and
boolean isUnlocked(EObject element)
methods to determine the lock status of an element.
An explicit lock is a lock that is placed explicitly on remote elements (by the user through an Action or programmatically). Such locks are not released when the Transaction gets committed (contrary to Implicit locks ).
If the
CDOViewpointPreferenceKeys.PREF_ENABLE_DURABLE_LOCKING
is true, then the locks will be persistent, event if the Collaborative Session is closed. They will last until the locked elements are explicitly unlocked (by the user through an Action or programmatically).
An explicit lock can be performed recursively (i.e. all the children of locked elements are also locked). Notice that you can lock both semantic or graphical elements (DDiagrams, DTree items, DLines of a DTable...).
// Step 1: getting a remote semantic element
EObject rootElementToLock = session.getSemanticResources().iterator().next().getContents().get(0);
Collection<EObject> elementsToLock = Lists.newArrayList(rootElementToLock);
// Step 2: locking the element and all its children
CDOLockManager.INSTANCE.acquireLock(elementsToLock, true, true);
// Element is now locked:
// CDOLockManager.INSTANCE.isLockedByMe(rootElementToLock) : true
// CDOLockManager.INSTANCE.isLockedByOthers(rootElementToLock) : false
// CDOLockManager.INSTANCE.isUnlocked(rootElementToLock) : false
// Step 3: unlocking the element and all its children
CDOLockManager.INSTANCE.releaseExplicitLocks(elementsToLock, true);
// Element is now unlocked:
// CDOLockManager.INSTANCE.isLockedByMe(rootElementToLock) : false
// CDOLockManager.INSTANCE.isLockedByOthers(rootElementToLock) : false
// CDOLockManager.INSTANCE.isUnlocked(rootElementToLock) : true
Viewpoint relies on a pessimistic lock mechanism: any time a user makes a modification, all the elements impacted by this modification are automatically locked, to prevent from any conflict.
Such locks are called implicit locks, as they have been placed automatically. As their only purpose is to avoid conflicts, they are released when the user commits on the repository. Notice that if the save action should save locally changes and not commit them , then implicit locks will not be released until a commit is performed.
To determine the elements to lock when a modification is made, Viewpoint uses a default lock strategy. The platform allows you to define your own lock strategies .
Viewpoint provide API for uploading and downloading models on/from the CDO Repository, through the
fr.obeo.dsl.viewpoint.collab.api.CDOImportExportManager
.
The
Set<String> importLocalFilesOnRepository(Set<URI> urisOfLocalFilesToImport, CDORepositoryManager repositoryManager, boolean replaceExistingCDOResources, boolean exportWorkspaceImages, IProgressMonitor monitor)
method of the
CDOImportExportManager
allows you to upload a set of local models on a CDORepository.
The
Set<String> exportFilesFromRepository(Set<URI> resourceURIs, CDORepositoryManager repositoryManager, boolean replaceExistingResources, boolean importWorkspaceImages, IProgressMonitor monitor)
method of the
CDOImportExportManager
allows you to download a set of remote models inside the Eclipse workspace.
Viewpoint API allows you to customize your authentication policy.
If your CDOServer has an authentication mechanism, you may want to customize the way authentication is handled inside Viewpoint.
To do so, you can provide your own
fr.obeo.dsl.viewpoint.collab.api.CDOAuthenticationManager
and register it in the
fr.obeo.dsl.viewpoint.collab.api.CDOAuthenticationManagerRegistry
.
Please refer to the advanced collaborative use case documentation to get an example of authentication customization.
You can change the Collaborative preferences to customize Viewpoint behavior:
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.COLLABORATIVE_MODE_ACTIVATED
: set it to false will disable all Viewpoint Collaborative features. User will not be able to connect to any CDO Repository.
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_ENABLE_DURABLE_LOCKING
: indicates whether
explicit locks should be persistent, event if the Collaborative Session is closed. If true, the locks will last until the locked elements are explicitly unlocked. If false, they will be released anyway when the Collaborative Session is closed. This preference has impacts on
save and commit decorellation .
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_ENABLE_SAVE_AND_COMMIT_DECORELATION
: if false, then calling
session.save()
will always commit. If true, then the
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_BY_DEFAULT_COMMIT_ON_SAVE
preference will be considered if a commit should be performed.
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_BY_DEFAULT_COMMIT_ON_SAVE
: indicates if calling
session.save()
should
commit the changes or save the changes locally. This preference can be modified by the user through the Collaborative preference page.
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_DEFAULT_REPOSITORY_NAME
: the default repository name (for example
'repo1') that will be displayed to the user inside wizards. This preference can be modified by the user through the Collaborative preference page.
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_DEFAULT_REPOSITORY_LOCATION
: the default repository location (for example
'localhost') that will be displayed to the user inside wizards. This preference can be modified by the user through the Collaborative preference page.
fr.obeo.dsl.viewpoint.collab.api.preferences.CDOViewpointPreferenceKeys.PREF_DEFAULT_REPOSITORY_PORT
: the default repository location (for example
'2036') that will be displayed to the user inside wizards. This preference can be modified by the user through the Collaborative preference page.