|
Re: compare two xml models? [message #926058 is a reply to message #925245] |
Fri, 28 September 2012 09:07 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
File file1 = new File("EMFModelA.ecore");
File file2 = new File("EMFModelB.ecore");
//register XMI resource factory for all other extensions
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(
).put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
//Loading resources
EObject model1 = ModelUtils.load(file1,resourceSet);
EObject model2 = ModelUtils.load(file2,resourceSet);
//matching models
// MatchModel match = MatchService.doMatch(model1, model2, Collections.<String, Object> emptyMap());
MatchModel match = MatchService.doContentMatch(model1, model2, Collections.<String, Object> emptyMap());
//matching engine and matching
GenericMatchEngine eng = new GenericMatchEngine();
match = eng.contentMatch(model1, model2, Collections.<String, Object> emptyMap());
//Differencing models
DiffModel diff = DiffService.doDiff(match);
Iterator<DiffElement> it = diff.getDifferences().iterator();
while (it.hasNext()){
System.out.println(it.next());
}
|
|
|
Re: compare two xml models? [message #957520 is a reply to message #926058] |
Thu, 25 October 2012 09:29 |
|
Hi Kosala,
The solution you give here is how to compare with EMF Compare 1 (you can find similar info on the FAQ). However, you should avoid loading the two versions of your model in the same resource set.
For EMF Compare 2, that would be :
File file1 = new File("EMFModelA.ecore");
File file2 = new File("EMFModelB.ecore");
//register XMI resource factory for all other extensions
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(
).put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
ResourceSet resourceSet1 = new ResourceSetImpl();
ResourceSet resourceSet2 = new ResourceSetImpl();
//Loading resources
EObject model1 = ModelUtils.load(file1, resourceSet1);
EObject model2 = ModelUtils.load(file2, resourceSet2);
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
Comparison result = EMFCompare.builder().build().compare(scope);
Iterator<Diff> it = result.getDifferences().iterator();
while (it.hasNext()){
System.out.println(it.next());
}
|
|
|
|
Re: compare two xml models? [message #1004578 is a reply to message #1004023] |
Wed, 23 January 2013 13:44 |
|
Pedro,
You are using EMF Compare 1 (as given out with your "org.eclipse.emf.compare.diff.*" import). The four classes you mention are EMF Compare 2 classes.
Please see the EMF Compare FAQ for how to programmatically compare models. Either for the recommmanded EMF Compare 2 or the legacy EMF Compare 1.
Laurent Goubet
Obeo
|
|
|
|
Re: compare two xml models? [message #1006632 is a reply to message #1006507] |
Fri, 01 February 2013 09:32 |
|
Pedro,
Please elaborate upon what you are trying to achieve.
All you should have to do is install the already built library. Whether you want EMF Compare to be usable to compare EMF models in your Eclipse, you want to develop an Eclipse plug-in that augments or makes use of EMF Compare or you wish to use EMF Compare from your standalone application.
Cloning the git repository containing the source code of EMF Compare is only necessary if you wish to develop patches or contributions to EMF Compare.
Follow the Installation instructions in order to install EMF Compare in Eclipse. Once done, the jars will simply be available to you. The will be located in your Eclipse "<installation directory>/plugins" folders ... but that is only relevant if you wish to develop a standalone application. Otherwise you'll never have to meddle with their location on disk.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.03349 seconds