Skip to main content



      Home
Home » Modeling » ATL » Empty XMI when running a transformation from an eclipse plugin(Using the MoDisco java Metamodel and EMFTVM )
Empty XMI when running a transformation from an eclipse plugin [message #1753173] Thu, 02 February 2017 07:46 Go to next message
Eclipse UserFriend
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 14:25] by Moderator

Re: Empty XMI when running a transformation from an eclipse plugin [message #1753208 is a reply to message #1753173] Thu, 02 February 2017 11:56 Go to previous messageGo to next message
Eclipse UserFriend
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 #1753230 is a reply to message #1753208] Thu, 02 February 2017 14:27 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your answer, I tried using "http://www.eclipse.org/MoDisco/Java/0.2.incubation/java" as the MetaModel URL, but it's still not working.
Re: Empty XMI when running a transformation from an eclipse plugin [message #1753242 is a reply to message #1753230] Thu, 02 February 2017 16:12 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Empty XMI when running a transformation from an eclipse plugin [message #1753265 is a reply to message #1753242] Fri, 03 February 2017 03:52 Go to previous message
Eclipse UserFriend
It seems to be working using your tips,
Thank you Dennis
Previous Topic:Metamodel constraints in ATL HOT
Next Topic:ATL Metamodel
Goto Forum:
  


Current Time: Wed Jul 23 08:37:37 EDT 2025

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

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

Back to the top