Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » EMF Compare Diff unexpected behavior
EMF Compare Diff unexpected behavior [message #1853632] Mon, 11 July 2022 20:50 Go to next message
Marwan Zizi is currently offline Marwan ZiziFriend
Messages: 2
Registered: July 2022
Junior Member
Hello,

I have some problems with the EMF Compare plugin.

I created a simple box metamodel : Box {members: 0...*Box}.

Then I generated two basic containers models :

Model 1 : SecondBox{ThirdBox}

Model 2: FirstBox{ SecondBox{ ThirdBox, FourthBox } }

I have a Main.java File where i am using the EMFCompare lib to compare the two models and highlights the differences. There is the code :


public static Comparison CompareModels( Box Model1, Box Model2) {
    
    IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
    IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
    matchEngineFactory.setRanking(120);
    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory); 
    IComparisonScope scope = EMFCompare.createDefaultScope(Model1, Model2);
    IDiffProcessor diffProcessor = new DiffBuilder();
    IDiffEngine diffEngine = new DefaultDiffEngine(diffProcessor);
    EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    List<Diff> differences  = comparison.getDifferences();
    for(Diff d: differences)
    {
      System.out.println("KIND: "+d.getKind());
      System.out.println("MATCH : "+d.getMatch());
    }  
}


The result I expected is :

ADD FirstBox
MOVE SecondBox to First Box
ADD FourthBox in Second Box

But when I display the detected diffs I get :
 

KIND: ADD
MATCH : org.eclipse.emf.compare.internal.spec.MatchSpec{left=Box@3738449f SecondBox,right=Box@3246fb96 SecondBox,origin=<null>,#differences=1,#submatches=2}
KIND: MOVE
MATCH : org.eclipse.emf.compare.internal.spec.MatchSpec{left=Box@77eca502 FirstBox,right=<null>,origin=<null>,#differences=1,#submatches=1}




I also tried with other examples and it seems to miss some important differences. And when I try to merge the two models the final result is not the one we expected..If someone can please give me some explanations.

Regards,

Marwan
Re: EMF Compare Diff unexpected behavior [message #1853639 is a reply to message #1853632] Tue, 12 July 2022 07:23 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hello,

You will have to navigate to the submatches to see the other differences. As you can see from your println, "#submatches=n".

[edit] sorry, read your question a little too fast.

Make sure you compare the containing resources of your objects and not the objects themselves. In this case model1 is SecondBox and model2 is FirstBox so I am assuming the differences you're seeing are:
ADD 4 in 2
MOVE 2 in 1

EMF Compare has no way to see the addition of "1" since that is the root of one of your compared sides.

Laurent Goubet
Obeo

[Updated on: Tue, 12 July 2022 07:31]

Report message to a moderator

Re: EMF Compare Diff unexpected behavior [message #1853692 is a reply to message #1853639] Wed, 13 July 2022 17:59 Go to previous message
Marwan Zizi is currently offline Marwan ZiziFriend
Messages: 2
Registered: July 2022
Junior Member
Hello,

Thanks for the answer !
The fact that EMF Compare doesn't have the ability to detect the addition of the root is the information i was missing.

Regards,

Marwan
Previous Topic:EMF Compare dialog in standalone RCP application e4
Next Topic:Resolving Proxies
Goto Forum:
  


Current Time: Wed Nov 13 03:20:07 GMT 2024

Powered by FUDForum. Page generated in 0.03469 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top