我有一个很大的问题:
使用atl插件时,我使用常规方法进行完美无缺的ATL转换。
但是当我尝试java启动时,它找不到模型的类(org.eclipse.emf.ecore.xmi.ClassNotFoundException:Class' operationalTemplateGroup'未找到或是抽象的)
例:
我有一个" operationalTemplateGroup"我的模型上的类,但元模型将其描述为:
<eClassifiers xsi:type="ecore:EClass" name="OPERATIONALTEMPLATEGROUP">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="OPERATIONALTEMPLATEGROUP"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
请参阅,OPERATIONALTEMPLATEGROUP而不是operationalTemplateGroup,为什么插件可以解析它,但java启动器不? 我有这个问题只有1个模型,其他工作正常,如果我将其更改为operationalTemplateGroup它将工作,直到下一个具有相同问题的类,(约6000行代码)。 方法:
public static void main(String[] args) {
try {
System.out.println("Running...");
/*
* Paths
*/
String inModelPath = "models/architectures/AToMS.acmehealth";
String inModelPath2 = "models/openehr/TemplatesAToMS.openehr2008v4";
String outModelPath = "models/richubi/TemplatesAToMS22.rich_interface_model";
String archMMPath = "metamodels/architectures/ACMEHealthv2.ecore";
String openEHRMMPath = "metamodels/openehr/openehr2008v4.ecore";
String richUbiMMPath = "metamodels/richubi/rich_interface_components.ecore";
System.out.println("inModelPath: " inModelPath);
System.out.println("inModelPath2: " inModelPath2);
System.out.println("outModelPath: " outModelPath);
System.out.println("archMMPath: " archMMPath);
System.out.println("openEHRMMPath: " openEHRMMPath);
System.out.println("richUbiMMPath: " richUbiMMPath);
/*
* Initializations
*/
ILauncher transformationLauncher = new EMFVMLauncher();
ModelFactory modelFactory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IExtractor extractor = new EMFExtractor();
/*
* Load metamodels
*/
IReferenceModel archMetamodel = modelFactory.newReferenceModel();
injector.inject(archMetamodel, archMMPath);
IReferenceModel openEHRMetamodel = modelFactory.newReferenceModel();
injector.inject(openEHRMetamodel, openEHRMMPath);
IReferenceModel richUbiMetamodel = modelFactory.newReferenceModel();
injector.inject(richUbiMetamodel, richUbiMMPath);
System.out.println("Metamodels loaded.");
/*
* Load models and run transformation
*/
IModel inModel2 = modelFactory.newModel(openEHRMetamodel);
injector.inject(inModel2, inModelPath2); // ERROR HERE!!!!
IModel inModel = modelFactory.newModel(archMetamodel);
injector.inject(inModel, inModelPath);
IModel outModel = modelFactory.newModel(richUbiMetamodel);
System.out.println("IN, OUT models loaded.");
System.out.print("Running ATL trasformation...");
transformationLauncher.initialize(new HashMap<String, Object>());
transformationLauncher.addLibrary("LibHelpers",
new FileInputStream("transformations/LibHelpers.asm"));
transformationLauncher.addInModel(inModel, "archMM", "openEHRMM");
transformationLauncher.addInModel(inModel2, null, "openEHRMM");
transformationLauncher.addOutModel(outModel, "archM", "openEHRM");
transformationLauncher
.launch(ILauncher.RUN_MODE,
new NullProgressMonitor(),
new HashMap<String, Object>(),
new FileInputStream(
"/home/operador/workspace/Transformation/transformations/OpenEHRTemplates2RichUbi.asm"));
System.out.println("Done.");
System.out.print("Extracting OUT model...");
extractor.extract(outModel, outModelPath);
System.out.println("Done.");
/*
* Unload all models and metamodels (EMF-specific)
*/
EMFModelFactory emfModelFactory = (EMFModelFactory) modelFactory;
emfModelFactory.unload((EMFModel) inModel);
emfModelFactory.unload((EMFModel) outModel);
emfModelFactory.unload((EMFReferenceModel) archMetamodel);
emfModelFactory.unload((EMFReferenceModel) openEHRMetamodel);
} catch (ATLCoreException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}