[ATL] how to inject an already deserialized model? [message #628927] |
Fri, 24 September 2010 18:29 |
Stephan Krusche Messages: 18 Registered: August 2010 Location: Munich |
Junior Member |
|
|
My input model is already deserialized and I have a Java Object which is the root object of my input model (inputRootObject)
My transformation already works, but output.xmi is empty as the ATL launcher does not have an input model. How can I tell the ATL Launcher that he should take the rootObject as input model? Is this possible?
I already tried two things (see code: Loading input model) but both does not work.
Can someone help?
Here is my code:
public void modelToModelTransformation(RootObject inputRootObject)
{
IInjector injector = CoreService.getInjector("EMF");
IExtractor extractor = CoreService.getExtractor("EMF");
URL transformationScrtipUrl = Platform.getBundle("atlProject").getEntry("transform.asm");
ModelFactory factory = CoreService.getModelFactory("EMF");
// Registrating metamodels
String inputMetaModelPath = "input.ecore";
String outputMetaModelPath = "output.ecore";
IReferenceModel inputMetaModel = factory.newReferenceModel();
IReferenceModel outputMetamodel = factory.newReferenceModel();
injector.inject(inputMetaModel, inputMetaModelPath);
injector.inject(outputMetamodel, outputMetaModelPath);
// Getting launcher
ILauncher launcher = null;
launcher = CoreService.getLauncher("EMF-specific VM");
launcher.initialize(Collections.<String, Object> emptyMap());
// Creating models
IModel inputModel = factory.newModel(inputMetaModel);
IModel outputModel = factory.newModel(outputMetamodel);
// Loading input model: this does not compile because I need a String here
injector.inject(inputModel, inputRootObject);
// Loading inpput model: this can compile, but does not work
Map<String, Object> options = new HashMap<String, Object>();
options.put("IN", inputRootObject);
// Launching
launcher.addInModel(inputModel, "IN", "InputMetaModel"); //EMF
launcher.addOutModel(outputModel, "OUT", "OutputMetaModel");
launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), options, transformationScrtipUrl.openStream());
// Saving output model
String outputModelPath = "output.xmi";
extractor.extract(outputModel, outputModelPath);
}
Thank you!
|
|
|
|
Powered by
FUDForum. Page generated in 0.01315 seconds