Merge EMF (UML) Models [message #620274] |
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
|
|
|
Powered by
FUDForum. Page generated in 0.02544 seconds