Empty XMI when running a transformation from an eclipse plugin [message #1753173] |
Thu, 02 February 2017 12:46 |
Thibault beziers la fosse Messages: 10 Registered: February 2017 |
Junior Member |
|
|
Hello, I'm trying to refine a model from the MoDisco java MetaModel. When I launch the transformation from the ATL EMFTVM Configuration, it works fine, but I want to do this as an eclipse plug-in command.
Using MoDisco programmatically, I generate a java-model of an eclipse java project, but then when I launch the ATL transformation, either the xmi model is empty, or the previous java model hasn't changed at all.
Here's a sample of the java code:
execEnv = FACTORY.createExecEnv();
resourceSet = new ResourceSetImpl();
Metamodel inOutMetamodel = EmftvmFactory.eINSTANCE.createMetamodel();
inOutMetamodel.setResource(resourceSet.getResource(URI.createURI("platform:/plugin/org.eclipse.gmt.modisco.java/model/java.ecore"), true));
execEnv.registerMetaModel("MM", inOutMetamodel);
inOutModel = EmftvmFactory.eINSTANCE.createModel();
inOutModel.setResource(resourceSet.getResource(URI.createURI("/Model/Model_java.xmi"), true));
execEnv.registerInOutModel("IN", inOutModel);
ModuleResolver moduleResolver = new DefaultModuleResolver(transformationDir, resourceSet);
execEnv.loadModule("platform:/plugin/model2test/transformation/", "m2t");
TimingData timingData = new TimingData();
timingData.finishLoading();
execEnv.run(timingData);
timingData.finish();
inOutModel.getResource().save(Collections.emptyMap());
Here's the header of the ATL file:
-- @atlcompiler emftvm
-- @nsURI MM=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
module m2t;
create OUT : MM refining IN : MM;
During the execution, the debug mode showed that both the Metamodel and the Model has been found, but still, nothing happen.
If you could give me an advice, that would be very helpful. The whole project is attached if you need more details.
Thank you
[Updated on: Thu, 02 February 2017 19:25] Report message to a moderator
|
|
|
Re: Empty XMI when running a transformation from an eclipse plugin [message #1753208 is a reply to message #1753173] |
Thu, 02 February 2017 16:56 |
|
Hello,
You already try use
inOutMetamodel.setResource(JavaFactory.eINSTANCE.eResource());
instead
inOutMetamodel.setResource(resourceSet.getResource(URI.createURI(MMInOut), true));
and use
execEnv.registerMetaModel("MM", "http://www.eclipse.org/MoDisco/Java/0.2.incubation/java");
instead
execEnv.registerMetaModel("MM", "platform:/plugin/org.eclipse.gmt.modisco.java/model/java.ecore");
|
|
|
|
Re: Empty XMI when running a transformation from an eclipse plugin [message #1753242 is a reply to message #1753230] |
Thu, 02 February 2017 21:12 |
|
Hmm, for the Ecore or UML metamodel you could just use something like this:
EcorePackage.eINSTANCE.eResource()
However, MoDisco's JavaPackage somehow does not inherit from EObject, and so does not provide the eResource() method, so you cannot use this strategy.
Another trick you may use, is to load the metamodel by its nsURI *after* the model; loading the model triggers the ResourceSet to load the metamodel as well, and then you can just fetch it from the ResourceSet by its namespace URI ("http://www.eclipse.org/MoDisco/Java/0.2.incubation/java"). If in doubt, you can always set a debugging breakpoint to introspect the contents of the resourceSet after loading the model.
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.04331 seconds