Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] how to inject an already deserialized model?
[ATL] how to inject an already deserialized model? [message #628927] Fri, 24 September 2010 18:29 Go to next message
Stephan Krusche is currently offline Stephan KruscheFriend
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!

Re: [ATL] how to inject an already deserialized model? [message #629214 is a reply to message #628927] Mon, 27 September 2010 13:46 Go to previous message
Stephan Krusche is currently offline Stephan KruscheFriend
Messages: 18
Registered: August 2010
Location: Munich
Junior Member
Is there another possibility to use an already deserialized model?

Or do I have to serialize it first in an xmi file to use ATL M2M?
Previous Topic:[Announce] Demonstrations at ESE's Modeling Symposium
Next Topic:[ATL]: max of floats
Goto Forum:
  


Current Time: Thu Apr 25 03:31:19 GMT 2024

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

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

Back to the top