| ATL transformation programming in java code [message #983881] |
Wed, 14 November 2012 03:10  |
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 #985201 is a reply to message #984239] |
Thu, 15 November 2012 03:22   |
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 ) 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  |
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.
|
|
|
Powered by
FUDForum. Page generated in 0.02318 seconds