Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 230908 - Synchronization problems between model resources
Summary: Synchronization problems between model resources
Status: VERIFIED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Dave Steinberg CLA
QA Contact:
URL: http://www.opencanarias.com
Whiteboard:
Keywords:
Depends on:
Blocks: 204200
  Show dependency tree
 
Reported: 2008-05-07 11:15 EDT by Victor Roldan Betancort CLA
Modified: 2008-05-12 19:45 EDT (History)
2 users (show)

See Also:


Attachments
Test metamodel, genmodel generated code and test models. (129.97 KB, application/x-zip-compressed)
2008-05-07 11:15 EDT, Victor Roldan Betancort CLA
no flags Details
Changes to editor template (6.16 KB, patch)
2008-05-08 09:44 EDT, Ed Merks CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Roldan Betancort CLA 2008-05-07 11:15:04 EDT
Created attachment 99098 [details]
Test metamodel, genmodel generated code and test models.

Detected on EMF 2.4.0 M7 and Eclipse 3.4 M7.
Also reproduced on Eclipse 3.3 and older EMF version.

I've noticed a problem with synchronization on models that reference elements of other models. I've been using the latest stuff (Eclipse 3.4 M7 and EMF 2.4.0 M7). I detected this behaviour also in previous versions. I did investigate a bit, and end up in a repeatable sequence of steps.

1. Create an .ecore metamodel, with two Classes:

ClassA (attribute name:EString, reference[0..1] refA:ClassA, reference[0..1] refB:ClassB)

- refA is contained.

ClassB (attribute name:EString, reference[0..1] refA:ClassA, reference[0..1] refB:ClassB)

- refB is contained.

2. Create .genmodel and generate model, edit and editor.
Ensure that contained references in the genmodel has "children", "create child" and "notify" to true. I also set "property type" to "none".

3. Execute a second eclipse instance, an generate two diferent models. The first will have ClassA as root, for the second, use ClassB as root. Save both and keep editors opened..

4. Let's modify firstly the second model. Add a "ClassB" child to root.
Set names for those classes to identify better, if you wish. Now SAVE.

5. Now modify the first model. Add a "ClassA" child to root. Let set the value for "refB" reference of this nested "ClassA" child. Use "Load Resource" to load the second file, so you can load deepest "ClassB" children. Now SAVE.

6. Ok, now add another ClassB in the second model (you should have now one root and 2 nested children). Now SAVE. Problem should arise. Go to first model editor, you should realized than the linked resource hasn't been synchronized. Furthermore, if you now modify it and save, changes in the second model would be overriden.
Comment 1 Ed Merks CLA 2008-05-08 09:44:33 EDT
Created attachment 99280 [details]
Changes to editor template

Because we support "save only if changed", a resource being added to the saved resources list might not actually have been changed at all.  It it's not really changed, we get no delta for it, so it's not cleared from that list.  If later there is a real delta on it, it's ignored because the code is assuming it's an expected delta from an earlier save.  I've changed it to use timestamps to check if a change should really be expected.
Comment 2 Ed Merks CLA 2008-05-08 09:45:02 EDT
Dave,

Please have a look at the patch.
Comment 3 Dave Steinberg CLA 2008-05-08 14:44:18 EDT
The fix looks good.
Comment 4 Ed Merks CLA 2008-05-09 16:18:55 EDT
The changes are committed to CVS.
Comment 5 Nick Boldt CLA 2008-05-12 19:45:45 EDT
Fix available in HEAD: 2.4.0.I200805121800.