Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Get EObjects that cause a difference
Get EObjects that cause a difference [message #1410348] Wed, 20 August 2014 13:56 Go to next message
Abelneh Teka is currently offline Abelneh TekaFriend
Messages: 3
Registered: May 2014
Junior Member
I used emf compare to programamticaly get the difference between two xmi models. As I understood, the Diff model generated by EMF Compare has no longer relation to the source xmi models (Correct me if I am wrong as I am new to EMF Compare). However, I want to get the EObjects of my input models that cause the difference. For example, Is there a way to achieve something similar to this;

Diff diff_1 = ....; // Get one of the diff models from the Diff List
EObject x = diff_1.getSource();

in which getSource() returns the EObject that cause the difference between the two models?

P.S. I want the source objects that make the difference because I want to do further analysis on them.

Re: Get EObjects that cause a difference [message #1410703 is a reply to message #1410348] Thu, 21 August 2014 12:27 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1897
Registered: July 2009
Senior Member
Hi abel,

The source object can be obtained through the Match to which each Diff is associated. For example :

Diff diff = ...;
Match match = diff.getMatch();
EObject leftChangedObject = match.getLeft();

This may not be exactly what you seek for containment changes, since in these case the "added" object is not the "changed" one

ReferenceChange diff = ...;
if (diff.getReference().isContainment()) {
    diff.getMatch().getLeft(); // <= this is the left container of the added/removed object
    diff.getMatch().getComparison().getMatch(diff.getValue()).getLeft(); // <= This is the left version of the added/removed object
} else {
    diff.getMatch().getLeft(); // <= this is the object on which we've observed a change
    diff.getMatch().getComparison().getMatch(diff.getValue()).getLeft(); // <= and this is the left version of the object that's been added/removed from a reference of the previous object (object from the previous line)

See also the developer guide

Laurent Goubet
Previous Topic:Customization and Team support
Next Topic:How to compare more than two Eobjects using EMF compare
Goto Forum:

Current Time: Wed Jun 29 11:26:11 GMT 2022

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

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

Back to the top