Programatic java ATL launch not working

399 Views Asked by At

I have a huge problem:

I have an ATL transformation that works flawlessly when I use the normal way to do it, using the atl plugin.

But when I try to java launch, it cannot find the classes of a model (org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'operationalTemplateGroup' is not found or is abstract)

Exemple: I have a "operationalTemplateGroup" class on my model, but the metamodel describes it as : <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>

See, OPERATIONALTEMPLATEGROUP and not operationalTemplateGroup, why the plugin can parse it but the java launcher dont? I have this problem with only 1 model, the others are working fine, and if I change it to operationalTemplateGroup it will work, until the next class that has the same problem, ( About 6000 lines of code ). Method:

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();
    }
}
0

There are 0 best solutions below