Merge EMF (UML) Models [message #129230] |
Mon, 01 September 2008 07:53 |
Pierre Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Hello,
I wanted to reply to
http://dev.eclipse.org/newslists/news.eclipse.technology.emf t/msg04924.html
but it was impossible (archived post), that's why I write this new post.
According to the code posted in this last URL, I could merge two EMF
models. The fact is that I have few problems using this code.
Here is mine : (that's the same as the one in the other post, except the
URI models)
import java.io.File;
import java.util.Collections;
import org.eclipse.emf.compare.diff.merge.service.MergeService;
import org.eclipse.emf.compare.diff.metamodel.DiffModel;
import org.eclipse.emf.compare.diff.service.DiffService;
import org.eclipse.emf.compare.match.metamodel.MatchModel;
import org.eclipse.emf.compare.match.service.MatchService;
import org.eclipse.emf.compare.util.ModelUtils;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.common.util.URI;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
try {
final ResourceSet modelResourceSet = new ResourceSetImpl();
Resource model1 = ModelUtils
.load(
URI
.createFileURI("D:/eclipse/workspace/com.odyssee.service/model/service.uml"),
modelResourceSet).eResource();
Resource model2 = ModelUtils
.load(
new java.io.File(
"D:/BAV3/workspace/com.odyssee.calcul/model/calcul.uml"),
modelResourceSet).eResource();
// Matches elements of the two models
final MatchModel match = MatchService.doResourceMatch(model1,
model2, null);
// Detects differences
final DiffModel diff = DiffService.doDiff(match);
// Merges all differences from model1 to model2
MergeService.merge(diff.getOwnedElements(), true);
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
Here is the error I get when launching the application:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/emf/ecore/xmi/impl/XMIResourceFactoryImpl
at
org.eclipse.emf.compare.util.ModelUtils.createResource(Model Utils.java:121)
at org.eclipse.emf.compare.util.ModelUtils.load(ModelUtils.java :319)
at Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException:
org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more
--> When I debug, the problem occurs on the loading of model1 : "Resource
model1 = ModelUtils.load( ..."
My questions are:
1. Why using "URI.createFileURI" for model1 ? My two models already
exists, and I just want if possible to create another one to get the
merging of my two models
2. is there is a problem of merging *.uml models (with the same metamodel
UML2) instead of *.ecore, like in the URL posted at the top of this post ?
And if you have any ideas to help solving my problem, everything is
welcomed !
Regards,
Pierre
|
|
|
Re: Merge EMF (UML) Models [message #129246 is a reply to message #129230] |
Mon, 01 September 2008 11:17 |
|
This is a multi-part message in MIME format.
--------------090203060308000202090107
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi Pierre,
This exception means you haven't got the jar org.eclipse.emf.ecore.xmi
which is needed by EMF Compare. You need to put this dependency in your
classpath.
As for 'createFileURI', we use it in order to convert the location of
the model to a 'file:' scheme URI.
Cheers,
Laurent Goubet
Obeo
Pierre a
|
|
|
|
|
|
|
|
Re: Merge EMF (UML) Models [message #129390 is a reply to message #129377] |
Tue, 02 September 2008 14:15 |
|
This is a multi-part message in MIME format.
--------------060700030007080804040903
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Pierre,
Well that's one I do not understand :(. Can your model be loaded within
Eclipse in the ecore editor? I'd expect it not to be valid and EMF
Compare relies on EMF for the model loading so we need it to be a
loadable model. If it can be loaded in the sample ecore editor ... well
I hope Ed will jump in and save the day!
Laurent Goubet
Obeo
Pierre a
|
|
|
|
Re: Merge EMF (UML) Models [message #129416 is a reply to message #129403] |
Tue, 02 September 2008 14:55 |
|
This is a multi-part message in MIME format.
--------------080608070503060405000604
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Ha, a possible cause would then be the UML version. Within eclipse an
"in-place" transformation from UML2 to UML2.1 takes place so that the
loaded model is conform to the new meta-model. I don't really know how
to trigger this through code though.
Take a look at UMLResource and UMLResourceFactory,
UML22UMLExtendedMetaData, ... and post a specific entry for this since I
cannot help you further on this topic (I'm interested in your results
though, I'll probably add this to the standalone sample if you find
anything).
Cheers!
Laurent Goubet
Obeo
Pierre a
|
|
|
Re: Merge EMF (UML) Models [message #620275 is a reply to message #129230] |
Mon, 01 September 2008 11:17 |
|
This is a multi-part message in MIME format.
--------------090203060308000202090107
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi Pierre,
This exception means you haven't got the jar org.eclipse.emf.ecore.xmi
which is needed by EMF Compare. You need to put this dependency in your
classpath.
As for 'createFileURI', we use it in order to convert the location of
the model to a 'file:' scheme URI.
Cheers,
Laurent Goubet
Obeo
Pierre a
|
|
|
|
|
|
|
|
Re: Merge EMF (UML) Models [message #620286 is a reply to message #129377] |
Tue, 02 September 2008 14:15 |
|
This is a multi-part message in MIME format.
--------------060700030007080804040903
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Pierre,
Well that's one I do not understand :(. Can your model be loaded within
Eclipse in the ecore editor? I'd expect it not to be valid and EMF
Compare relies on EMF for the model loading so we need it to be a
loadable model. If it can be loaded in the sample ecore editor ... well
I hope Ed will jump in and save the day!
Laurent Goubet
Obeo
Pierre a
|
|
|
|
Re: Merge EMF (UML) Models [message #620288 is a reply to message #129403] |
Tue, 02 September 2008 14:55 |
|
This is a multi-part message in MIME format.
--------------080608070503060405000604
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Ha, a possible cause would then be the UML version. Within eclipse an
"in-place" transformation from UML2 to UML2.1 takes place so that the
loaded model is conform to the new meta-model. I don't really know how
to trigger this through code though.
Take a look at UMLResource and UMLResourceFactory,
UML22UMLExtendedMetaData, ... and post a specific entry for this since I
cannot help you further on this topic (I'm interested in your results
though, I'll probably add this to the standalone sample if you find
anything).
Cheers!
Laurent Goubet
Obeo
Pierre a
|
|
|
Powered by
FUDForum. Page generated in 0.05349 seconds