[CDO] Question about locking [message #1372049] |
Wed, 21 May 2014 13:03  |
Eclipse User |
|
|
|
Hi all,
I have an application which displays two different Graphiti diagrams in their respective editors. These diagrams are stored in seperate resources in CDO.
And a same element is displayed in both diagrams.
So, when I acquire lock to edit the element in one diagram, it is then locked and non-editable in the other diagram because each Graphiti editor uses its own CDO transaction.
In my use case, locking the element makes sense to prevent conflicts with other users running other instances of my application.
But, it should not "apply" between editors inside a same application when one owns the lock.
Locking at session level would solve my problem but - unless i'm wrong - is not possible.
Any idea on how to handle this situation ? Is there any CDO option / feature, I'm not yet aware of, that could be used ?
kind regards,
Laurent
|
|
|
|
|
|
|
Re: [CDO] Question about locking [message #1383387 is a reply to message #1376314] |
Mon, 26 May 2014 06:41   |
Eclipse User |
|
|
|
Hi Leonid,
Thanks for the tip ! I try to use setCommittables but then, saving my diagram (resource) fails with the following error message :
!ENTRY org.eclipse.graphiti.ui 0 0 2014-05-26 12:22:57.807
!MESSAGE The following resources could not be saved:
URI: cdo://EntrepriseArchitectureRepository/Application_app1_1400270224492, cause:
org.eclipse.net4j.util.transaction.TransactionException: org.eclipse.emf.cdo.util.CommitException: org.eclipse.net4j.util.transaction.TransactionException: org.eclipse.emf.cdo.util.CommitIntegrityException: The resource of new object CommitInfo@oid1[NEW] needs to be included in the commit but isn't
at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.save(CDOResourceImpl.java:1236)
I create a CommitInfo element before the saving to store additionnal information (user Id, time stamp and an associated comment).
This element is added to the resource to be saved :
TransactionalEditingDomain ted = editor.getEditingDomain();
CDOResource r = editor.getDiagramTypeProvider().getDiagram().cdoResource();
ted.getCommandStack().execute(new AddCommand(ted, r.getContents(), commitInfo));
Then, for the saving, I make copy of the whole resource content (including the new element) :
TreeIterator<EObject> resourceWholeContent = diagramBehavior.getDiagramTypeProvider().getDiagram().cdoResource().getAllContents();
HashSet<EObject> commitables = new HashSet<EObject>();
while (resourceWholeContent.hasNext())
commitables.add(resourceWholeContent.next());
transaction.setCommittables(commitables);
Set<Resource> res = super.save(editingDomain, saveOptions, monitor);
Any idea why the 'NEW' object is apparently not considered in the same resource as the rest ?
Regards,
Laurent
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03820 seconds