EMF Compare Diff unexpected behavior [message #1853632] |
Mon, 11 July 2022 20:50 |
Marwan Zizi 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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03469 seconds