Home » Modeling » Compare » ignoring identifiers problem(Seems UseIdentifiers.NEVER does not work for me)
ignoring identifiers problem [message #1691283] |
Sat, 04 April 2015 10:28  |
Eclipse User |
|
|
|
Hi everyone,
I have 2 models to compare. In my *.ecore model, I have an "Id" attribute and its ID property have been setted to true. I am using EcoreUtil.generateUUID() for unique ids.
In my case, I have one ready model and I am creating a new one in runtime. Therefore the ids are different from each other.
In developer guide of EMFCompare, they offer us to use UseIdentifiers.NEVER and I used. However it does not work.
In short, I want to ignore Id attributes in comparison.
Quote:
Left object: DocModel.impl.ParagraphImpl@2767e23c (Id: _8pidAdVSEeSCK78kxjXrDg) (name: null) (rawText: Lorem ipsum ....)
Right object: DocModel.impl.ParagraphImpl@33bc72d1 (Id: _QSFJodrUEeSkqsl19NdwQQ) (name: null) (rawText: Lorem ipsum ....)
d.getKind(): CHANGE
thanks and regards
[Updated on: Tue, 07 April 2015 08:27] by Moderator
|
|
| | | |
Re: ignoring identifiers problem [message #1693803 is a reply to message #1693754] |
Tue, 28 April 2015 07:59   |
Eclipse User |
|
|
|
OK. Now I understood the principle. I turned my codes into below:
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
IDiffProcessor customDiffProcessor = new DiffBuilder() {
@Override
public void attributeChange(Match match, EAttribute attribute, Object value, DifferenceKind kind, DifferenceSource source) {
if (attribute != EcorePackage.Literals.EATTRIBUTE__ID) {
super.attributeChange(match, attribute, value, kind, source);
}
}
};
IDiffEngine diffEngine = new DefaultDiffEngine(customDiffProcessor);
return EMFCompare.builder().setDiffEngine(diffEngine).build().compare(scope);
Is this right? Because, the output is still not what I want. The compare result :
Quote:d.getKind(): ADD
d.getMatch(): MatchSpec{left=Paragraph@59e2d8e3 Summary, right=Paragraph@4bf48f6 Summary, origin=<null>, #differences=2, #submatches=2}
State: UNRESOLVED
d.getKind(): DELETE
d.getMatch(): MatchSpec{left=Paragraph@59e2d8e3 Summary, right=Paragraph@4bf48f6 Summary, origin=<null>, #differences=2, #submatches=2}
State: UNRESOLVED
I tried to use ENAMED_ELEMENT__NAME for testing if it works, and it works properly for name attributes. But EATTRIBUTE__ID does not. ADD and DELETE come up consecutively for id attribute like above.
Attachment: left.png
(Size: 7.24KB, Downloaded 306 times)
Attachment: right.png
(Size: 6.31KB, Downloaded 294 times)
Attachment: model.png
(Size: 3.22KB, Downloaded 298 times)
[Updated on: Tue, 28 April 2015 09:51] by Moderator
|
|
| |
Re: ignoring identifiers problem [message #1694927 is a reply to message #1694013] |
Sat, 09 May 2015 09:59   |
Eclipse User |
|
|
|
Tested on same models above:
public Comparison compare(ResourceSet resourceSet1, ResourceSet resourceSet2)
{
//Creating the comparison scope
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
//Configuring the comparison
IDiffProcessor customDiffProcessor = new DiffBuilder() {
@Override
public void attributeChange(Match match, EAttribute attribute, Object value, DifferenceKind kind, DifferenceSource source) {
if (attribute != DocModel.DocModelPackage.Literals.ELEMENT__ID) {
super.attributeChange(match, attribute, value, kind, source);
}
}
};
IDiffEngine diffEngine = new DefaultDiffEngine(customDiffProcessor);
return EMFCompare.builder().setDiffEngine(diffEngine).build().compare(scope);
}
output:
Quote:
d.getKind(): ADD
d.getMatch(): MatchSpec{left=Paragraph@59e2d8e3 Summary, right=Paragraph@4bf48f6 Summary, origin=<null>, #differences=2, #submatches=2}
State: UNRESOLVED
d.getKind(): DELETE
d.getMatch(): MatchSpec{left=Paragraph@59e2d8e3 Summary, right=Paragraph@4bf48f6 Summary, origin=<null>, #differences=2, #submatches=2}
State: UNRESOLVED
Also as you can see, diff points the paragraph named Summary. But, the difference is in Key-Value Paragraph. I thing it ignores the ID but I do not know where ADD and DELETE come from. When I don't use the feature filtering, the CHANGE diff comes up like below:
Quote:d.getKind(): CHANGE
d.getMatch(): MatchSpec{left=Paragraph@536dbea0 Key-Value Pair, right=Paragraph@47c81abf Key-Value Pair, origin=<null>, #differences=1, #submatches=0}
State: UNRESOLVED
diff points the paragraph named Key-Value Paragraph.
best regards
|
|
|
Re: ignoring identifiers problem [message #1695787 is a reply to message #1694927] |
Tue, 19 May 2015 05:40  |
Eclipse User |
|
|
|
Hi,
As I mentionned earlier, the toString of these diffs does not provide nearly enough information to understand what's going on. Post the full xmi representation of that diff if you need to find that out, or screenshot the UI of EMF Compare so that we know what these diffs really are.
You may also provide us with the metamodels and models to test and debug this case.
Laurent Goubet
Obeo
|
|
|
Goto Forum:
Current Time: Sat Jun 14 23:12:58 EDT 2025
Powered by FUDForum. Page generated in 0.07287 seconds
|