How to use EMF Diff/Merge programmatically [message #1737860] |
Wed, 13 July 2016 10:48  |
Eclipse User |
|
|
|
Hello,
I want to use programmatically EMF Diff/Merge for my EMF model project to make a specific diff and merge plugin. I found help for it only in its javadoc and on this site: http://wiki.eclipse.org/EMF_DiffMerge/Programmatic_Usage
but it's not detailed enough for me.
I tried an example code that is written on the site above, but I got in trouble about how could I get the differences programmatically (in what form does it give the differences and how could I understand and interpret these) that EMF Diff/Merge gives and how could I work with its result.
My example code is this (according to that site):
ResourceSet resSet = new ResourceSetImpl();
Resource resource = resSet.getResource(URI.createURI("grafok/MyGraph.xmi"), true);
Resource resource2 = resSet.getResource(URI.createURI("grafok/MyGraph2.xmi"), true);
IEditableModelScope targetScope = new FragmentedModelScope(resource, false);
IEditableModelScope referenceScope = new FragmentedModelScope(resource2, false);
IComparison comparison = new EComparisonImpl(targetScope, referenceScope);
comparison.compute(new DefaultMatchPolicy(), new DefaultDiffPolicy(), new DefaultMergePolicy(), new NullProgressMonitor());
Collection<IDifference> differences = comparison.getRemainingDifferences();
Can anyone help about it or link a more detailed and understandable documentation about EMF Diff/Merge?
Thanks in advance
|
|
|
|
|
|
|
|
|
|
|
|
Re: How to use EMF Diff/Merge programmatically [message #1738426 is a reply to message #1738382] |
Tue, 19 July 2016 12:46  |
Eclipse User |
|
|
|
In that case, you can redefine method "getMatchID" of DefaultMatchPolicy so that it returns, for example, the String concatenation of the (qualified) type name and the ID value. The idea is that two elements match if and only if their match IDs are equal.
Other than that, is there any reason why you have such a specific, per-type identification mechanism? If you want to have, e.g., version control of your models, a 'classical' way would be to have a root metaclass in the type hierarchy of your metamodel owning an ID attribute of type EString, and a customized constructor implementation in the corresponding Java class that sets the value of the ID attribute to, for example, EcoreUtil.generateUUID().
|
|
|
Powered by
FUDForum. Page generated in 0.39084 seconds