Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Comparing two structurally equal EObjects yields PSEUDO conflict [updated]
Comparing two structurally equal EObjects yields PSEUDO conflict [updated] [message #1757980] Wed, 22 March 2017 14:06 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Let's say I have this simple model (Xcore syntax):
class A {
  contains B[] bs opposite a
}

class B {
  String foo
  container A a opposite bs
}


I now have three A's, created like the following:

A a1 = ModelFactory.eINSTANCE.createA();
B b1 = ModelFactory.eINSTANCE.createB();
b1.setFoo("foo");
b1.setA(a1);

A a2 = ModelFactory.eINSTANCE.createA();
B b2 = ModelFactory.eINSTANCE.createB();
b2.setFoo("bar");
b2.setA(a2);

A a3 = ModelFactory.eINSTANCE.createA();
B b3 = ModelFactory.eINSTANCE.createB();
b3.setFoo("bar");
b3.setA(a3);


When I try to compare them like this:

DefaultComparisonScope scope = new DefaultComparisonScope(a1, a2, a3);
Comparison comp = EMFCompare.builder().build().compare(scope);
EList<Diff> diffs = comp.getDifferences();


I am expecting to get one attribute change on the B__FOO EAttribute, but I get two pseudo conflicts for the ADD kind for A__BS. I think this is because of how EMF handles equality, and the A's and B's are, technically, different.

How do I achieve that I get the "correct" differences?

EDIT: I now started with a clean project with this very simple example (but with a UUID property added to each of the classes as it is also the case with my "real" model I cannot post here) and it worked.

So can anyone guide me what can be the culprit that the diffs get recognized incorrectly in my real model? Things to look at to narrow down the origin of the problem?

[Updated on: Wed, 22 March 2017 17:24]

Report message to a moderator

Re: Comparing two structurally equal EObjects yields PSEUDO conflict [updated] [message #1758056 is a reply to message #1757980] Thu, 23 March 2017 08:23 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

Hi Jens,

I guess this is because of the matches established by the match engine. Have a look at the match objects in the comparison and check if the matches look as expected in both cases. If you compare the matches of the example that doesn't work with the example that worked, I guess you will see that a model element hasn't been matched.

If the match engine is the culprit, I suggest to use an ID-based matcher based on your UUIDs, since you mentioned that you have them in the model anyway. You might need to customize the ID function in your matcher though, unless the UUID is either an XMI UUID, or marked as "isId" in your Ecore.

Hope that helps!

Best wishes,

Philip

--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Comparing two structurally equal EObjects yields PSEUDO conflict [updated] [message #1758058 is a reply to message #1758056] Thu, 23 March 2017 08:27 Go to previous message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
In the meantime, I found the cause myself. I did not correctly load / update the "common ancestor" in my real model.

So, I constructed the left side from the files in my project, the right side from the current state in the database, and the common ancestor was the database state when creating the project. When committing changes, I forgot to update the common ancestor to the state after the commit - it was still the old one. Thus, I was comparing my previous commit and my new commit to the old outdated state which yielded this incorrect result.
Previous Topic:can't find kind=ADD
Next Topic:Newbie Guide to Creating Custom Matching Strategy
Goto Forum:
  


Current Time: Thu Apr 25 00:26:06 GMT 2024

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

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

Back to the top