Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314733 - After a copy/paste, (patchable) inconsistency in references
Summary: After a copy/paste, (patchable) inconsistency in references
Status: RESOLVED FIXED
Alias: None
Product: JWT
Classification: SOA
Component: WE (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-27 13:37 EDT by Marc Dutoo CLA
Modified: 2011-06-06 10:41 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Dutoo CLA 2010-05-27 13:37:02 EDT
In a workflow model (with or whitout aspects), after a copy/paste e.g. of an Action, when trying to save, a popup appears saying "inconsistency in references detected and fixed" and asking for confirmation.


Analysis :

When doing the copy/paste of e.g. an Action, the custom WE "copy/paste with clipboard" commands copies the selected Action, as well as its LayoutData. Even if a Reference/ActivityEdge is selected, it won't be copied (see WECopyToClipboardCommand ; why, by the way ?).

Then the default EMF copy/paste commands code kicks in. When InitializeCopyCommand inits the EMF (cross) reference fields of the new copy of the selected Action (notably performedBy Role ReferenceEdge), it (logically) sets those that target elements that are not in the clipboard so they will target those same elements as the original Action. However, this is inconsistent for JWT, since a ReferenceEdge should be targeted by at most one Action.

Then at save time, EMFHelper.correctReferences(this) detects this inconsistency and patches it by creating a new ReferenceEdge to be targeted by the copied Action.

Besides, the new Aspects copy/paste code seems to have to do nothing with this.


Workaround :

the model is OK before the save, after confirming the save (but both without references to roles), and after reloading the model (this time with references to roles).

Solution :

It is not only a technical problem but a functional one : do we want
1. to copy ReferenceEdge (targeting elements that are not in the clipboard) along ? (knowing that ActivityEdges won't be copied by the default EMF code)
2. or not ?
3. or ask the user about it at paste time, or create two set of paste commands ?

To implement 1., we could add the appropriate ReferenceEdges to be copied in the clipboard in WECopyToClipboardCommand's code.
To implement 2., we should create a custom InitializeCopyCommand that sets e.g. the copied performedBy EMF reference to null.
Comment 1 Marc Dutoo CLA 2010-06-03 14:06:28 EDT
I've just tried it using the official 0.7.0 release and it's the same behaviour.

More information : when opening the file again after having saved it, the copy-pasted action now references other, new Role(Reference)s and Application(Reference)s (but not other linked Actions) that have been created by the consistency checking mechanism, however their LayoutData were not copy-pasted so those new elements are displayed on the top left of the diagram.
Comment 2 Marc Dutoo CLA 2010-06-03 14:10:49 EDT
Having tried with 0.6.0, references were not copied at all when copy-pasting, meaning solution 2.
Comment 3 Christian Saad CLA 2010-06-07 08:04:46 EDT
Thanks for describing & analyzing this bug. I hoped that the copy&paste issues were finally resolved :(

Basically the idea was (and from my understandig still is) to add all edges (activity&reference) which exist *between* the selected objects to the copy&paste set. I'll have a look at it although I'm not sure if it would be safe to commit this to Helios.
Comment 4 Marc Dutoo CLA 2010-06-07 13:39:13 EDT
Thanks for this information, so at least it's not my Aspects copy/paste code that is at fault :)

If you want to copy all edges _between_ nodes, then I've got the solution (thanks to my Aspects copy/paste experience) : 

Write your own JWTInitializeCopyCommand (hook it classically in JWT's DefaultCommandProvider or ModelElementItemProviderAdapter) that extends InitializeCopyCommandWithAspects (and not InitializeCopyCommand in order not to lose Aspects copy/paste), and override getReferencesToCopy() so as to not return anymore (performedBy) EReferences that target a Role that has no copy (i.e. copyHelper.getCopy(owner.getPerformedBy() == null).

Actually, I could do it on my own without breaking too much sweat. Would you be OK with that ?

Regards,
Marc
Comment 5 Christian Saad CLA 2010-06-30 13:05:00 EDT
Due to limited time I implemented a simple solution, which I hope will do the trick. I added a CrossReference detection to WEPasteFromClipboardCommand. All external references which point to elements outside the clipboard are unset before pasting, except References and ActivityLinks. View elements' containedIn is reset to the current target Activity.

C&P inside one activity seems fine but there are some strange problems when copying/pasting between different activities. But I think in interest of this this should be moved to 1.1.0
Comment 6 Marc Dutoo CLA 2011-06-06 10:41:01 EDT
This last problem has now his own bugzilla :

#348400 Problems when copying/pasting between different activities

so closing this one, since everything else has been OK since then.