Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL transformation programming in java code
ATL transformation programming in java code [message #983881] Wed, 14 November 2012 03:10 Go to next message
Beatus Ding is currently offline Beatus Ding
Messages: 18
Registered: November 2012
Junior Member
I'm transforming one .fm model into another .unify model using ATL.Nothing wrong with ATL configuration.Now I want to use ATL transformation in java code.I get different result from that of ATL configuration.The following is my code
try {
			/*
			 * Initialization
			 */
			ILauncher transLauncher=new EMFVMLauncher();
			ModelFactory modelFactory=new EMFModelFactory();
			IInjector injector=new EMFInjector();
			IExtractor extractor=new EMFExtractor();
			
			/*
			 * Load metamodels
			 */
			 
			IReferenceModel fmMetaModel=modelFactory.newReferenceModel();
			injector.inject(fmMetaModel, "file:e:/实验室项目/models的文章/SynModel_old/fm.core/model/fm.ecore");
			//injector.inject(fmMetaModel, "http:///featureIDE");
			IReferenceModel unifyMetaModel=modelFactory.newReferenceModel();
			injector.inject(unifyMetaModel, "file:e:/实验室项目/models的文章/SynModel_old/unify.core/model/unify.ecore");
			
			/*
			 * Load model
			 */
			 
			IModel fmModel=modelFactory.newModel(fmMetaModel);
			injector.inject(fmModel, "file:e:/实验室项目/models的文章/SynModel_old/atl/fm/app1/new/app1.fm");
			IModel unifyModel=modelFactory.newModel(unifyMetaModel);
			
			/*
			 * transformation
			 */
			 
			transLauncher.initialize(new HashMap<String, Object>());
			transLauncher.addInModel(fmModel, "IN", "FM");
			transLauncher.addOutModel(unifyModel, "OUT", "UNIFY");
			transLauncher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), new HashMap<String, Object>(), new FileInputStream("E:/实验室项目/models的文章/SynModel_old/atl/fm/atl/app1/fm2unify.asm"));
			extractor.extract(fmModel, "file:/实验室项目/models的文章/SynModel_old/atl/fm/app1/new/app_d.unify");
			
			/*
			 * unload all models and metamodel(EMF-specific)
			 */
			 
			EMFModelFactory emfModelFactory=(EMFModelFactory) modelFactory;
			emfModelFactory.unload((EMFModel) fmModel);
			emfModelFactory.unload((EMFReferenceModel) fmMetaModel);
			emfModelFactory.unload((EMFReferenceModel) unifyMetaModel);
		} catch (ATLCoreException e) {
			// TODO: handle exception
			e.printStackTrace();
		}catch (FileNotFoundException e) {
			// TODO: handle exception
			e.printStackTrace();
		}

Is there anything wrong with my code?Thanks in anvance,any suggestion will be appreciated.
Re: ATL transformation programming in java code [message #983900 is a reply to message #983881] Wed, 14 November 2012 03:30 Go to previous messageGo to next message
Andreas Brieg is currently offline Andreas Brieg
Messages: 48
Registered: November 2012
Member
What is the difference in the result you see?
Re: ATL transformation programming in java code [message #983924 is a reply to message #983900] Wed, 14 November 2012 03:58 Go to previous messageGo to next message
Beatus Ding is currently offline Beatus Ding
Messages: 18
Registered: November 2012
Junior Member
Using the java code transformation,the transformed model remain almost the same with source model,while using ATL trans config,I can get exactly the right target model.I don't know why?Is there anything wrong with my java code?
Re: ATL transformation programming in java code [message #984239 is a reply to message #983924] Wed, 14 November 2012 09:27 Go to previous messageGo to next message
Andreas Brieg is currently offline Andreas Brieg
Messages: 48
Registered: November 2012
Member
Maybe the problem is in the initialization phase. You instantiate everything yourself. Did you have a look how that is done in the Eclipse ATL Plugins? Maybe there is one of those instances created elsewhere and some more configuration is applied.
Re: ATL transformation programming in java code [message #985201 is a reply to message #984239] Thu, 15 November 2012 03:22 Go to previous messageGo to next message
Mauro Faella is currently offline Mauro Faella
Messages: 31
Registered: June 2012
Member
Hi Beatus,
I had the same problem. Has your input model cross references with another model? In my case it has and the problem is that in java the transformation can't resolve the referenced elements, so they aren't transformed.
I solved this issue using ant (there is a thread Wink ) and the "platform path" format to load every model.
I hope it will help,
Mauro

[Updated on: Thu, 15 November 2012 03:23]

Report message to a moderator

Re: ATL transformation programming in java code [message #986211 is a reply to message #985201] Mon, 19 November 2012 08:36 Go to previous message
Beatus Ding is currently offline Beatus Ding
Messages: 18
Registered: November 2012
Junior Member
Thank sincerely for your reply.I just have one meta source model,one meta target model and one source model.I don't understand what the crossing reference model is.Can you tell some details about your solving progress?Best show me some source code,thanks a lot.
Previous Topic:Implied linking in Refining mode
Next Topic:Error loading file - org.eclipse.m2m.atl.core.ATLCoreException
Goto Forum:
  


Current Time: Tue Jul 22 17:47:47 EDT 2014

Powered by FUDForum. Page generated in 0.01924 seconds