ATL transformation programming in java code [message #983881] |
Wed, 14 November 2012 08: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.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03431 seconds