Launch ATL transformation programmatically [message #1062432] |
Fri, 07 June 2013 12:30  |
Eclipse User |
|
|
|
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 12:55  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.25701 seconds