run successive ATL transformations with java [message #1160684] |
Tue, 29 October 2013 09:31 |
Fy Za Messages: 245 Registered: March 2010 |
Senior Member |
|
|
Dear All,
I have these two transformations:
fiModel --
|- Ins2Lk.atl -> lkModel
fInsModel--
fiModel --
|- Lk2Tpn.atl -> tpnModel
lkModel --
I define a java program to launch them automatically.
However, I have an error when I try to inject the lkModel generated by the first transformation in the second transformation
this is my java program
public class Toolchain2 {
public static void main(String[] args) throws IOException {
/*
* The first transformation
*/
try {
// in order to generate models with relatifs inter-model references
System.setProperty("user.dir","/Users/f/Modeling/workspace25/org.eclipse.toolchain/models");
// in order to make allow inter model references = true
// we define MyEMFVMLauncher which is the same as EMFVMLauncher! just one modification in
// internalLaunch where we make
// modelAdapter.setAllowInterModelReferences(LauncherService.getBooleanOption(options.get("allowInterModelReferences"), true));
ILauncher transformationLauncher = new MyEMFVMLauncher();
transformationLauncher.initialize(new HashMap<String,Object>()) ;
ModelFactory modelFactory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IExtractor extractor = new EMFExtractor();
/*
* Load metamodels
*/
IReferenceModel fInsMetamodel = modelFactory.newReferenceModel();
injector.inject(fInsMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/FInst.ecore");
IReferenceModel fiMetamodel =modelFactory.newReferenceModel() ;
injector.inject(fiMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/FI.ecore");
IReferenceModel LkMetamodel = modelFactory.newReferenceModel();
injector.inject(LkMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/LK.ecore");
IModel fInsModel = modelFactory.newModel(fInsMetamodel);
injector.inject(fInsModel, "model.fins");
IModel fiModel = modelFactory.newModel(fiMetamodel) ;
injector.inject(fiModel, "model.f");
IModel lkModel = modelFactory.newModel(LkMetamodel) ;
transformationLauncher.addInModel(fInsModel, "InsModel", "InsMetaModel");
transformationLauncher.addInModel(fiModel, "FModel", "FMetaModel");
transformationLauncher.addOutModel(lkModel, "LKModel", "LKMetaModel");
transformationLauncher.addLibrary("library_links", (ASM) transformationLauncher.loadModule(new FileInputStream("/Users/f/Modeling/workspace25/org.eclipse.toolchain/library_links.asm")));
transformationLauncher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), new HashMap<String,Object>(),
new FileInputStream("/Users/f/Modeling/workspace25/org.eclipse.toolchain/Ins2Lk.asm"));
extractor.extract(lkModel, "model.flk");
EMFModelFactory emfModelFactory = (EMFModelFactory) modelFactory;
emfModelFactory.unload((EMFModel) lkModel);
emfModelFactory.unload((EMFModel) fiModel);
emfModelFactory.unload((EMFModel) fInsModel);
emfModelFactory.unload((EMFReferenceModel) fiMetamodel);
emfModelFactory.unload((EMFReferenceModel) fInsMetamodel);
emfModelFactory.unload((EMFReferenceModel) LkMetamodel);
}catch (Exception e) {
e.printStackTrace();
}
/*
* The second transformation
*/
try {
ILauncher transformationLauncher1 = new MyEMFVMLauncher();
transformationLauncher1.initialize(new HashMap<String,Object>()) ;
ModelFactory modelFactory1 = new EMFModelFactory();
IInjector injector1 = new EMFInjector();
IExtractor extractor1 = new EMFExtractor();
IReferenceModel LkMetamodel = modelFactory1.newReferenceModel();
injector1.inject(LkMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/LK.ecore");
IReferenceModel fiMetamodel =modelFactory1.newReferenceModel() ;
injector1.inject(fiMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/FI.ecore");
IReferenceModel tpnMetamodel = modelFactory1.newReferenceModel();
injector1.inject(tpnMetamodel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/metamodels/TPN.ecore");
IModel fkModel = modelFactory1.newModel(LkMetamodel);
injector1.inject(fkModel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/models/model.flk");
IModel fModel = modelFactory1.newModel(fiMetamodel) ;
injector1.inject(fModel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/models/model.f");
IModel tpnModel = modelFactory1.newModel(tpnMetamodel) ;
transformationLauncher1.addInOutModel(fkModel, "LkModel", "LkMetaModel");
transformationLauncher1.addInOutModel(fModel, "FModel", "FMetaModel");
transformationLauncher1.addInOutModel(tpnModel, "TpnModel", "TpnMetaModel");
transformationLauncher1.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), new HashMap<String,Object>(),
new FileInputStream("/Users/f/Modeling/workspace25/org.eclipse.toolchain/Lk2Tpn.asm"));
extractor1.extract(tpnModel, "/Users/f/Modeling/workspace25/org.eclipse.toolchain/models/model.tpn");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
and this is the error
org.eclipse.m2m.atl.core.ATLCoreException: Error loading model.flk: null
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:70)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:84)
at org.eclipse.toolchain.Toolchain.main(Toolchain.java:142)
Caused by: java.lang.NullPointerException
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2164)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2042)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:128)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1847)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:65)
... 2 more
Can you please help me!
Does it exist a java code which do the same (Successive ATL transformations + inter model references in java) ?
if it is exists, please share it!
Best regards,
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02833 seconds