Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » EMF Compare get Object Attributes
EMF Compare get Object Attributes [message #1062893] Tue, 11 June 2013 09:27 Go to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Hi there.
I've been working on my project with EMF Compare and for my purpose I need to get the name of the Object where there is a difference between two textual models.

I'd really appreciate any help from you.

Regards.

[Updated on: Thu, 13 June 2013 17:28]

Report message to a moderator

Re: EMF Compare get Object Attributes [message #1063429 is a reply to message #1062893] Thu, 13 June 2013 07:25 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1886
Registered: July 2009
Senior Member
Hi,

I have no idea what you're trying to achieve, but I guess what you want is to retrieve info about the target of a diff. With EMF Compare 1, you will have to cast to the proper diff type (ModelElementChangeRightTarget, ModelElementChangeLeftTarget, ...), use the getter for the target element (getRightElement, getLeftElement, ...) and navigate from that element to the info you seek : getClass(), getName(), etc.

You should switch to EMF Compare 2, since exploiting the comparison result is much easier now :

IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
Comparison comparison = EMFCompare.builder().build().compare(scope);

List<Diff> differences = comparison.getDifferences();
for (Diff diff : differences) {
	if (diff instanceof ReferenceChange) {
		EObject changed = ((ReferenceChange)diff).getValue();
		System.out.println("Changed EObject '" + changed.getName() + "' of type : " + changed.getClass());
	}
}


Laurent Goubet
Obeo
Re: EMF Compare get Object Attributes [message #1066102 is a reply to message #1063429] Sun, 30 June 2013 16:54 Go to previous messageGo to next message
Hans 17 is currently offline Hans 17Friend
Messages: 2
Registered: June 2013
Junior Member
Hi guys.

I also have some question about this topic. In my case I need to get the 2 objects where there was a change on different attributes. But until now everything seems to be workless.

[Updated on: Thu, 18 July 2013 15:48]

Report message to a moderator

Re: EMF Compare get Object Attributes [message #1066353 is a reply to message #1066102] Tue, 02 July 2013 09:35 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1886
Registered: July 2009
Senior Member
Hans,

You may want to look at a few java tutorials before trying to tackle Eclipse plugin development.

What you have here is a very basic exception, which tells you (straight from the documentation of "ClassCastException") :
Quote:

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
Object x = new Integer(0);
System.out.println((String)x);



In this case, you are trying to cast a reference order changed as an UpdateAttribute, while "UpdateAttribute" has no relation to a ReferenceChange whatsoever.

Laurent Goubet
Obeo
Re: EMF Compare get Object Attributes [message #1070761 is a reply to message #1066353] Thu, 18 July 2013 15:54 Go to previous messageGo to next message
Hans 17 is currently offline Hans 17Friend
Messages: 2
Registered: June 2013
Junior Member
Laurent thanks a lot for your replay and explanation, actually I feel a little embarrassed...
Re: EMF Compare get Object Attributes [message #1809782 is a reply to message #1070761] Tue, 23 July 2019 11:56 Go to previous messageGo to next message
Snehal Nakave is currently offline Snehal NakaveFriend
Messages: 9
Registered: September 2018
Junior Member
Hi Guys,

Thanks for the above post and replies.

I am also working on similar project where i want the differences between two run-time generated files (mydsl files). The two files are :
1) the current run-time file where user will do the updates and
2) locally stored file (without these latest user changes i.e. consider last git commit file)

I am able to get the differences with Diff of EMF Compare. I also got the EObject using above code snippet but I am not yet able to get the values.
Now I want to fetch the differences in terms of EMF model classes with the changed values or want to access that EObject.
How it could be done?
Re: EMF Compare get Object Attributes [message #1809792 is a reply to message #1070761] Tue, 23 July 2019 13:20 Go to previous messageGo to next message
Snehal Nakave is currently offline Snehal NakaveFriend
Messages: 9
Registered: September 2018
Junior Member
Hi Guys,

Thanks for the above post and replies.

I am also working on similar project where i want the differences between two run-time generated files (mydsl files). The two files are :
1) the current run-time file where user will do the updates and
2) locally stored file (without these latest user changes i.e. consider last git commit file)

I am able to get the differences with Diff of EMF Compare. I also got the EObject using above code snippet but I am not yet able to get the values.
Now I want to fetch the differences in terms of EMF model classes with the changed values or want to access that EObject.
How it could be done?
Re: EMF Compare get Object Attributes [message #1810010 is a reply to message #1809792] Mon, 29 July 2019 07:30 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1886
Registered: July 2009
Senior Member
Hello,

Please create a new thread for new questions, don't resurect old ones.

You might want to look at what we're doing in org.eclipse.emf.compare.utils.EMFComparePrettyPrinter to navigate the differences and look at the documentation for the core concepts. Though incomplete, the documentation could explain what most references mean on the Diff objects. If this is not enough, please detail your questions (in a new thread).

Laurent Goubet
Obeo
Previous Topic:Package with uri 'http:///org/eclipse/epf/uma/resourcemanager.ecore' not found
Next Topic:Custom Comparison
Goto Forum:
  


Current Time: Sun Oct 25 19:40:12 GMT 2020

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

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

Back to the top