Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Launch ATL transformation programmatically
icon5.gif  Launch ATL transformation programmatically [message #1062432] Fri, 07 June 2013 16:30 Go to next message
Arnaud Dieumegard is currently offline Arnaud Dieumegard
Messages: 16
Registered: June 2010
Junior Member
Quote:
Hi,

I have a problem with launching an ATL transformation. I have a transformation metamodel A (MMA) to metamodel B (MMB) in MMA2MMB.atl/.asm

I try to launch the transformation using the code provided in https://github.com/101companies/101repo/blob/master/contributions/atl/src/atl/RunTransfoJava.java

ILauncher transformationLauncher = new EMFVMLauncher();
ModelFactory modelFactory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IExtractor extractor = new EMFExtractor();

IReferenceModel MMA = modelFactory.newReferenceModel();
injector.inject(MMA, "...");
IReferenceModel MMB = modelFactory.newReferenceModel();
injector.inject(MMB, "...");

IModel mA = modelFactory.newModel(MMA);
injector.inject(mA, "path to transformation input file (xmi)");

transformationLauncher.initialize(new HashMap<String,Object>());
transformationLauncher.addInModel(MMA, "IN", "name of IN model in MMA2MMB.atl");
transformationLauncher.addOutModel(MMB, "OUT", "name of OUT model in MMA2MMB.atl");
transformationLauncher.launch(
    ILauncher.RUN_MODE, 
    new NullProgressMonitor(), 
    new HashMap<String,Object>(),
    new FileInputStream("path to MMA2MMB.asm file"));

extractor.extract(MMA, "name of output file for transformation");

EMFModelFactory emfModelFactory = (EMFModelFactory) modelFactory;
emfModelFactory.unload((EMFReferenceModel) MMA);
emfModelFactory.unload((EMFReferenceModel) MMB);


I have an error while launching this:

Quote:

[CRITICAL_ERROR][Transfo.LaunchMMA2MMBInJava] () Unhandled exception

class org.eclipse.m2m.atl.engine.emfvm.VMException
Cannot find class Class1 in reference model outputModel
org.eclipse.m2m.atl.engine.emfvm.VMException: Cannot find class Class1 in reference model outputModel
at __matchInModel2OutModel#23(MMA2MMB.atl[11:3-13:4])
local variables: self=MMA2MMB : ASMModule, inSM=IN!<unnamed>
at __matcher__#1(MMA2MMB.atl)
local variables: self=MMA2MMB : ASMModule
at main#22(MMA2MMB.atl)
local variables: self=MMA2MMB : ASMModule


The transformation looks like this:

-- @path outputModel=path to outputModel.ecore
-- @path inputModel=path to inputModel.ecore

module MMA2MMB;
create OUT : outputModel from IN : inputModel;

rule InModel2OutModel {
	from
		inSM : inputModel!Model
	to 
		outProg : outputModel!Class1 (
			nodes <- inSM.elements
		)
}


So it seems that the metamodel is loaded as it found it (reference model outputModel), the transformation is loaded too (as he knows that it must create Class1 element). But it cannot find the classes in the metamodel (Class1).

I tried to register the metamodels (it does not changes anything).
I debugged it and the metamodel is well loaded (newReferenceModel creation).

Does anyone have an idea of what I'm doing wrong ?

Thanks
Arnaud
Re: Launch ATL transformation programmatically [message #1062436 is a reply to message #1062432] Fri, 07 June 2013 16:55 Go to previous message
Arnaud Dieumegard is currently offline Arnaud Dieumegard
Messages: 16
Registered: June 2010
Junior Member
Ok my bad, It was just a matter of creating a model to hold the result of the transformation:

transformationLauncher.addInModel(mA, "IN", "name of IN model in MMA2MMB.atl");
IModel mB = modelFactory.newModel(MMB);
transformationLauncher.addOutModel(mB, "OUT", "name of OUT model in MMA2MMB.atl");


Sorry for that.

Arnaud
Previous Topic:Convert UML to security policies
Next Topic:Change Source Element
Goto Forum:
  


Current Time: Thu Oct 23 20:02:06 GMT 2014

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

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