| [EMF Compare] Inverse use of EMF Compare [message #671231] |
Tue, 17 May 2011 04:28  |
 |
Kai B. Heinz Messages: 17 Registered: March 2011 Location: Germany |
Junior Member |
|
|
Hi,
I hope I got the right forum for an EMF Compare question. Otherwise please lead me to the right place, thanks.
I have two ecore models, where a lot of Elements are equal. Now I want to use EMF Compare to find these equal Elements. How can I do that? Certainly, I will find all differences, but how do I find "the rest"?
Thanks a lot,
Kai
[Updated on: Tue, 17 May 2011 04:29] Report message to a moderator
|
|
|
|
|
|
| Re: [EMF Compare] Inverse use of EMF Compare [message #675334 is a reply to message #675166] |
Tue, 31 May 2011 04:08   |
 |
Kai B. Heinz Messages: 17 Registered: March 2011 Location: Germany |
Junior Member |
|
|
Thanks a lot!
I had to make some minor changes to to code above, but now it works very well.
Kai
List<MatchElement> matchElements =
((MatchElement) matchModelObject.eContents().get(0)).getSubMatchElements();
List<DiffGroup> diffGroups = new ArrayList<DiffGroup>();
TreeIterator<EObject> iterator = diffObject.eAllContents();
while (iterator.hasNext())
{
EObject next = iterator.next();
if (next instanceof DiffGroup)
{
diffGroups.add((DiffGroup)next);
}
}
List<MatchElement> equalObjects = new ArrayList<MatchElement>(matchElements.size());
for (MatchElement match : matchElements)
{
DiffGroup correspondingGroup = null;
for (DiffGroup group : diffGroups)
{
if (((Match2Elements) match).getRightElement() == group.getRightParent())
{
// Note : not sure that instance equality is enough
correspondingGroup = group;
break;
}
}
if (correspondingGroup == null)
{
equalObjects.add(match);
}
else
{
diffGroups.remove(correspondingGroup);
}
}
[Updated on: Wed, 13 July 2011 07:12] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01575 seconds