Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Execute atl in a java program
icon5.gif  Execute atl in a java program [message #897038] Fri, 20 July 2012 21:46 Go to next message
iram castaneda is currently offline iram castanedaFriend
Messages: 1
Registered: July 2012
Junior Member
hi guys
I am newbie with atl and I need to execute a program in java that runs on atl, it requires the program receives three inputs...
a) an ecore file ( file.ecore) is the metamodel source.
b) an ecore file ( file.ecore) is the metamodel target.
c) an file of an source model. file .pl_xelha(is an SPL language)
d) the ATL program

it should generate an output:
a) file of the target mode. file.pl_xelha(SPL language)


I am not certain how it should work...

Any suggestion, recommendation, code, algorithm or pray is welcome.

Very Happy
thank you!
Re: Execute atl in a java program [message #897276 is a reply to message #897038] Mon, 23 July 2012 13:28 Go to previous messageGo to next message
Holger S is currently offline Holger SFriend
Messages: 4
Registered: January 2012
Junior Member
Hi,

i think this link might help you:

http://wiki.eclipse.org/ATL_Howtos#How_do_I_launch_transformations_programmatically.3F

Greetings,
Holger
Re: Execute atl in a java program [message #897409 is a reply to message #897276] Tue, 24 July 2012 03:35 Go to previous messageGo to next message
Fernando Gonzalez is currently offline Fernando GonzalezFriend
Messages: 3
Registered: July 2012
Junior Member
We are trying to transform from one model to another model using the same metamodel as input and output.
There are several examples out there but some classes or methods have been deprecated.
The ATL.Zip by Milanovic has been deprecated too as he says.

Is there a newer example we could use ?

The launcher takes as input an asm module, so I guess I need to compile my ATL module but I don't know how.

Help anyone ?

Thanks in advance
Re: Execute atl in a java program [message #898735 is a reply to message #897409] Fri, 27 July 2012 11:46 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 57
Registered: June 2012
Member
You can easily replace the deprecated methods of ATLLauncher by valid ones with an additional parameter.
This is the code I am currently using for that purpose (still having problems during the transformation, though):
final Map<String, ASMEMFModel> models = new HashMap<String, ASMEMFModel>();

			final AtlEMFModelHandler modelHandler = (AtlEMFModelHandler) AtlModelHandler
					.getDefault(AtlModelHandler.AMH_EMF);
			final EMFModelLoader modelLoader = (EMFModelLoader) modelHandler
					.createModelLoader();
			/**
			 * Create the metamodels' URIs.
			 */
			final URI modelTransformationModelResource = 
                              URI.createFileURI("..\\ModelTransformation.ecore");
			final URI otxModelResource = 
                              URI.createFileURI("..\\otx.ecore");
			final URI hmiModelResource = 
                              URI.createFileURI("..\\hmi.ecore");
			/**
			 * Load the metamodels by their previously created URI.
			 */
			final ASMEMFModel modelTransformationMetaModel = modelLoader
					.loadModel("ModelTransformation", modelLoader.getMOF(),
							modelTransformationModelResource);
			final ASMEMFModel otxMetaModel = modelLoader.loadModel("otx",
					modelLoader.getMOF(), otxModelResource);
			final ASMEMFModel hmiMetaModel = modelLoader.loadModel("hmi",
					modelLoader.getMOF(), hmiModelResource);
			/**
			 * Load the input model from the given file.
			 */
			final URI inputModelUri = URI.createFileURI(inputFile.getPath());
			final ASMEMFModel modelTransformationInputModel = modelLoader
					.loadModel("IN", modelTransformationMetaModel,
							inputModelUri);
			/**
			 * Create output models (TODO allow inter-model references!).
			 */
			final URI otxOutputUri = URI.createFileURI(new File(folder
					.getAbsolutePath(), "out.otx").getPath());
			final ASMEMFModel otxOutputModel = (ASMEMFModel) modelLoader
					.newModel("OUT", otxOutputUri.toFileString(), otxMetaModel);

			final URI hmiOutputUri = URI.createFileURI(new File(folder
					.getAbsolutePath(), "out.hmi").getPath());
			final ASMEMFModel hmiOutputModel = (ASMEMFModel) modelLoader
					.newModel("hmi", hmiOutputUri.toFileString(), hmiMetaModel);

			models.put("transformate", modelTransformationMetaModel);
			models.put("otx", otxMetaModel);
			models.put("otxHmi", hmiMetaModel);
			models.put("IN", modelTransformationInputModel);
			models.put("OUT", otxOutputModel);
			models.put("hmi", hmiOutputModel);
			/**
			 * Determine the compiled ATL rule file.
			 */
			final URL atlAsmUrl = new URL(
					"..\\transformate2otx.asm");
			/**
			 * Important: Allow inter-model references.
			 */
			final Map<String, String> options = new HashMap<String, String>();
			options.put("allowInterModelReferences", "true");
			// options.put("outputModelContentTypesDetection", "true");
			/**
			 * Perform the model-to-model transformation.
			 */
			AtlLauncher.getDefault().launch(atlAsmUrl, Collections.emptyMap(),
					models, Collections.emptyMap(), Collections.emptyList(),
					options);
			modelLoader.save(otxOutputModel, otxOutputUri.toFileString());


You'll have to replace the file names, of course.
Re: Execute atl in a java program [message #900236 is a reply to message #898735] Mon, 06 August 2012 01:29 Go to previous message
Fernando Gonzalez is currently offline Fernando GonzalezFriend
Messages: 3
Registered: July 2012
Junior Member
What kind of project do you create ?
I assume you are using the classes from modeldriven.org
I installed the ModelPro but I still get some errors of objects that
can't be found.
Previous Topic:NoClassDefFound on programmatic launch of the families2persons example
Next Topic:How to call an EOperation in atl program?
Goto Forum:
  


Current Time: Fri Dec 19 04:41:34 GMT 2014

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

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