Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Compare nodes with different parent hierarchy
Compare nodes with different parent hierarchy [message #1695786] Tue, 19 May 2015 09:32 Go to next message
Kai Schreiber is currently offline Kai SchreiberFriend
Messages: 4
Registered: May 2015
Junior Member
Hi,

I try to compare two nodes where one node is additionally contained in another node.
Apart from this the two nodes and their sub-trees are equal and I expect to get no differences.
The reason seems to be the IEqualityHelper in the EditionDistance where the URI-distance is used.

Here is some sample code:

Document document1 = createDocument();
Document document2 = createDocument();

Project project = ModelFactory.eINSTANCE.createProject();
project.getDocuments.add(document1);

IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
matchEngineFactory.setRanking(20);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry.add(matchEngineFactory);
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
IComparisonScope scope = new DefaultComparisonScope(document1, document2, null);
Comparison result = comparator.compare(scope);

List<Diff> diffs = result.getDifferences();

assertEquals(0, diffs.size()); // Fails


Maybe I've missed something. Is there a setting to ignore the parent nodes?

Regards,
Kai
Re: Compare nodes with different parent hierarchy [message #1696398 is a reply to message #1695786] Tue, 26 May 2015 09:49 Go to previous messageGo to next message
Andreas Mayer is currently offline Andreas MayerFriend
Messages: 11
Registered: April 2014
Junior Member
Instead of calling DefaultMatchEngine.createDefaultEObjectMatcher(), create an IdentifierEObjectMatcher that delegates to an ProximityEObjectMatcher and give it an ID function that returns the same id (e.g. "root") for your two nodes and null for all other objects.

Thus configured, the IdentifierEObjectMatcher will add a match for your two nodes (without computing any edit distance, because they have the same id) and then delegate the matching of their children to the ProximityEObjectMatcher (because they have no ids).
Re: Compare nodes with different parent hierarchy [message #1697038 is a reply to message #1696398] Mon, 01 June 2015 07:03 Go to previous message
Kai Schreiber is currently offline Kai SchreiberFriend
Messages: 4
Registered: May 2015
Junior Member
Andreas, thank you. That did the trick.
Previous Topic:Problem with merge: duplicate objects are created
Next Topic:Print Structural differences to Console
Goto Forum:
  


Current Time: Sat Nov 17 19:03:04 GMT 2018

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

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

Back to the top