Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » EMF Compare Load model file
EMF Compare Load model file [message #1009450] Fri, 15 February 2013 06:57 Go to next message
serhat gezgin is currently offline serhat gezgin
Messages: 239
Registered: January 2013
Location: Izmir
Senior Member
i use the following code for compare models.

bu i always get ;

Exception in thread "main" java.io.IOException: Unable to load model at //Case1.ecore.
at org.eclipse.emf.compare.util.ModelUtils.load(ModelUtils.java:359)
at EmfCompare.emfCompareDeneme.name(emfCompareDeneme.java:27)
at EmfCompare.emfCompareDeneme.main(emfCompareDeneme.java:45)

error. I'll try all path location posibilities but cant success.

		ResourceSet resourceSet1 = new ResourceSetImpl();
		ResourceSet resourceSet2 = new ResourceSetImpl();
		
		String xmi1 = "//Case1.ecore";
		String xmi2 = "//Case2.ecore";
		
		EObject model1 = ModelUtils.load(xmi1, resourceSet1);
		EObject model2 = ModelUtils.load(xmi2, resourceSet2);
		 
		// Matching model elements
		MatchModel match = MatchService.doMatch(model1, model2, Collections.<String, Object> emptyMap());
		// Computing differences
		DiffModel diff = DiffService.doDiff(match, false);
		// Merges all differences from model1 to model2
		List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements());
		
		for (DiffElement diffElement : differences) {
			System.out.println(diffElement.toString());
		}
Re: EMF Compare Load model file [message #1009478 is a reply to message #1009450] Fri, 15 February 2013 08:05 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Serhat,

EMF Compare is based on Eclipse and EMF. Trying to use it from code without prior minimal knowledge of these two technologies will be a hard endeavour. You would probably gain from following a tutorial on plugin development ( http://www.vogella.com/articles/EclipsePlugIn/article.html for example) and EMF tutorials (maybe http://www.vogella.com/articles/EclipseEMF/article.html ).

What you can use as parameters of ModelUtils.load() is explained ... in the javadoc of ModelUtils.load.

Quote:

This can be called with paths of the form



  • /pluginID/path
  • platform:/plugin/pluginID/path
  • platform:/resource/pluginID/path



Google can give some more info on what these "forms" represent, for example http://lmap.blogspot.fr/2008/03/platform-scheme-uri.html .

Laurent Goubet
Obeo
Re: EMF Compare Load model file [message #1010760 is a reply to message #1009478] Mon, 18 February 2013 07:43 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezgin
Messages: 239
Registered: January 2013
Location: Izmir
Senior Member
Hi Lourent,

i study my lesson :)and i can load ecore like resource but when i run

MatchModel match = MatchService.doMatch(model1, model2,
Collections.<String, Object> emptyMap());

this method i always get that Error;

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Sets
at org.eclipse.emf.compare.match.engine.GenericMatchScope.resolveAll(GenericMatchScope.java:191)
at org.eclipse.emf.compare.match.engine.DefaultMatchScope.resolveAll(DefaultMatchScope.java:79)
at org.eclipse.emf.compare.match.engine.GenericMatchScope.<init>(GenericMatchScope.java:78)
at org.eclipse.emf.compare.match.engine.DefaultMatchScope.<init>(DefaultMatchScope.java:56)
at org.eclipse.emf.compare.match.engine.DefaultMatchScopeProvider.<init>(DefaultMatchScopeProvider.java:76)
at org.eclipse.emf.compare.match.engine.MatchScopeProviderUtil.getScopeProvider(MatchScopeProviderUtil.java:82)
at org.eclipse.emf.compare.match.engine.GenericMatchEngine.modelMatch(GenericMatchEngine.java:515)
at org.eclipse.emf.compare.match.service.MatchService.doMatch(MatchService.java:155)
at javaBean.emfCompareDeneme.name(emfCompareDeneme.java:52)
at javaBean.emfCompareDeneme.main(emfCompareDeneme.java:68)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Sets
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more


my function is;

		// 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();

		String xmi1 = "src-gen/Case5.ecore";
		String xmi2 = "src-gen/Case2.ecore";

		File file1 = new File(xmi1);
		File file2 = new File(xmi2);

		// Loading models
		EObject model1 = ModelUtils.load(file1, resourceSet1);
		EObject model2 = ModelUtils.load(file2, resourceSet2);

		URI uri1 = URI.createFileURI("src-gen/Case5.ecore");
		URI uri2 = URI.createFileURI("src-gen/Case2.ecore");
		
		// Matching model elements
		MatchModel match = MatchService.doMatch(model1, model2,
				Collections.<String, Object> emptyMap());
		// Computing differences
		DiffModel diff = DiffService.doDiff(match, false);
		// Merges all differences from model1 to model2
		List<DiffElement> differences = new ArrayList<DiffElement>(
				diff.getOwnedElements());
		// MergeService.merge(differences, true);
		for (DiffElement diffElement : differences) {
			System.out.println(diffElement.toString());
		}


this method is true or Where I'm doing wrong ?

Regards,
Re: EMF Compare Load model file [message #1010783 is a reply to message #1010760] Mon, 18 February 2013 08:28 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Hi Serhat,

Part of your training as a student in computer science is also to try and solve issues on your own : in a corporate environment, you'll face a number of wildly different issues that will require solving. Issues like these relating to dependencies are not something you should get blocked with so fast. Learning how to efficiently use google to find related information and adapt it to your case should be one of your priorities Wink.

With that in mind, if you use a query such as "EMF Compare" followed by the error message on google, the first few results relate to a very close issue : http://www.eclipse.org/forums/index.php/t/452425/ . Though the error is not exactly the same (well, it is, but for EMF Compare 2), the answer and solution are the same : EMF Compare depends on Google Guava, which can be installed from the following update site http://download.eclipse.org/tools/orbit/downloads/drops/R20130118183705/ . Note that we depend on guava 10 explicitely, do not install Guava 12! In the "install new software..." dialog, this is done by unchecking the "show only the latest version of available software" checkbox.

Laurent Goubet
Obeo
Previous Topic:Graphical comparison and difference display
Next Topic:Extracting only differences from model comparison
Goto Forum:
  


Current Time: Fri Sep 19 01:50:38 GMT 2014

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

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