| Summary: | moved one element but EMF Compare produced two changes: A MoveModelElement (regular move) and a UpdateContainmentFeature (containment change) | ||
|---|---|---|---|
| Product: | [Modeling] EMFCompare | Reporter: | Patrick Konemann <patrick.koenemann> |
| Component: | Core | Assignee: | EMF Compare <emf.compare-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
You were right, its fixed now and will be available in RC2 , thanks for your feedback ! Closing our "resolved" and "verified" bugs. |
Build Identifier: I20100429-1549 In one of my comparisons I moved one element but EMF Compare produced two changes: A MoveModelElement (regular move) and a UpdateContainmentFeature (containment change), and both contain the very same properties! Example scenario and proposed fix below. Version: Eclipse 3.6M7 Scenario: Changing an association between two UML classes from unidirectional to directional. Technically speaking: The first listing is the model with the unidirectional association, the second listing the model with the directional association. LISTING UNCHANGED: <Class> A <Class> B - (feature ownedAttribute): <Property> dst : A <Association> A_src_dst - (feature ownedEnds): <Property> src : B LISTING CHANGED: <Class> A - (feature ownedAttribute): <Property> src : B <Class> B - (feature ownedAttribute): <Property> dst : A <Association> A_src_dst The two changes that EMF Compare detects are: - <Property> src : B has been moved from <Association> A_src_dst to <Class> A - Containment reference has been changed from ownedEnd to ownedAttribute As I understand it, there is a bug for the detection of containment reference changes: they should only be detected if it is not already a move. In other words, the containment reference changes should only be created if the container differs. I checked the generic diff engine and saw that this check is done for Match3Elements but not for Match2Elements. So I guess we just need to adjust the generic diff engine as follows (just one line added; untested): protected void checkContainmentUpdate(DiffGroup current, Match2Elements matchElement) { final EObject leftElement = matchElement.getLeftElement(); final EObject rightElement = matchElement.getRightElement(); if (leftElement.eContainmentFeature() != null && rightElement.eContainmentFeature() != null) { if (!leftElement.eContainmentFeature().getName().equals( rightElement.eContainmentFeature().getName()) && getMatchedEObject(leftElement.eContainer()).equals(rightElement.eContainer() // this line is new ) { createUpdateContainmentOperation(current, leftElement, rightElement); } } } Example models below. FILE: move_unchanged.uml ---------------------------8<--------------------------- <?xml version="1.0" encoding="UTF-8"?> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_9e02AAyyEd-lddWJYP-XCg" name="myModel"> <packagedElement xmi:type="uml:Class" xmi:id="_nb3TwVgiEd-v-4PFzr_Xug" name="A"/> <packagedElement xmi:type="uml:Class" xmi:id="_nb360FgiEd-v-4PFzr_Xug" name="B"> <ownedAttribute xmi:id="_nb4h4VgiEd-v-4PFzr_Xug" name="dst" type="_nb3TwVgiEd-v-4PFzr_Xug" association="_nb4h4FgiEd-v-4PFzr_Xug"> <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nb4h4lgiEd-v-4PFzr_Xug" value="1"/> <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nb4h41giEd-v-4PFzr_Xug" value="1"/> </ownedAttribute> </packagedElement> <packagedElement xmi:type="uml:Association" xmi:id="_nb4h4FgiEd-v-4PFzr_Xug" name="A_src_dst" memberEnd="_nb4h4VgiEd-v-4PFzr_Xug _nb4h5FgiEd-v-4PFzr_Xug"> <ownedEnd xmi:id="_nb4h5FgiEd-v-4PFzr_Xug" name="src" type="_nb360FgiEd-v-4PFzr_Xug" association="_nb4h4FgiEd-v-4PFzr_Xug"> <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nb4h5VgiEd-v-4PFzr_Xug" value="1"/> <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nb4h5lgiEd-v-4PFzr_Xug" value="1"/> </ownedEnd> </packagedElement> </uml:Model> --------------------------->8--------------------------- FILE: move_changed.uml ---------------------------8<--------------------------- <?xml version="1.0" encoding="UTF-8"?> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_9e02AAyyEd-lddWJYP-XCg" name="myModel"> <packagedElement xmi:type="uml:Class" xmi:id="_nb3TwVgiEd-v-4PFzr_Xug" name="A"> <ownedAttribute xmi:id="_nb4h5FgiEd-v-4PFzr_Xug" name="src" type="_nb360FgiEd-v-4PFzr_Xug" association="_nb4h4FgiEd-v-4PFzr_Xug"> <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nb4h5VgiEd-v-4PFzr_Xug" value="1"/> <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nb4h5lgiEd-v-4PFzr_Xug" value="1"/> </ownedAttribute> </packagedElement> <packagedElement xmi:type="uml:Class" xmi:id="_nb360FgiEd-v-4PFzr_Xug" name="B"> <ownedAttribute xmi:id="_nb4h4VgiEd-v-4PFzr_Xug" name="dst" type="_nb3TwVgiEd-v-4PFzr_Xug" association="_nb4h4FgiEd-v-4PFzr_Xug"> <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_nb4h4lgiEd-v-4PFzr_Xug" value="1"/> <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_nb4h41giEd-v-4PFzr_Xug" value="1"/> </ownedAttribute> </packagedElement> <packagedElement xmi:type="uml:Association" xmi:id="_nb4h4FgiEd-v-4PFzr_Xug" name="A_src_dst" memberEnd="_nb4h4VgiEd-v-4PFzr_Xug _nb4h5FgiEd-v-4PFzr_Xug"/> </uml:Model> --------------------------->8--------------------------- Reproducible: Always