final Map<String, ASMEMFModel> models = new HashMap<String, ASMEMFModel>(); final AtlEMFModelHandler modelHandler = (AtlEMFModelHandler) AtlModelHandler .getDefault(AtlModelHandler.AMH_EMF); final EMFModelLoader modelLoader = (EMFModelLoader) modelHandler .createModelLoader(); /** * Create the metamodels' URIs. */ final URI modelTransformationModelResource = URI.createFileURI("..\\ModelTransformation.ecore"); final URI otxModelResource = URI.createFileURI("..\\otx.ecore"); final URI hmiModelResource = URI.createFileURI("..\\hmi.ecore"); /** * Load the metamodels by their previously created URI. */ final ASMEMFModel modelTransformationMetaModel = modelLoader .loadModel("ModelTransformation", modelLoader.getMOF(), modelTransformationModelResource); final ASMEMFModel otxMetaModel = modelLoader.loadModel("otx", modelLoader.getMOF(), otxModelResource); final ASMEMFModel hmiMetaModel = modelLoader.loadModel("hmi", modelLoader.getMOF(), hmiModelResource); /** * Load the input model from the given file. */ final URI inputModelUri = URI.createFileURI(inputFile.getPath()); final ASMEMFModel modelTransformationInputModel = modelLoader .loadModel("IN", modelTransformationMetaModel, inputModelUri); /** * Create output models (TODO allow inter-model references!). */ final URI otxOutputUri = URI.createFileURI(new File(folder .getAbsolutePath(), "out.otx").getPath()); final ASMEMFModel otxOutputModel = (ASMEMFModel) modelLoader .newModel("OUT", otxOutputUri.toFileString(), otxMetaModel); final URI hmiOutputUri = URI.createFileURI(new File(folder .getAbsolutePath(), "out.hmi").getPath()); final ASMEMFModel hmiOutputModel = (ASMEMFModel) modelLoader .newModel("hmi", hmiOutputUri.toFileString(), hmiMetaModel); models.put("transformate", modelTransformationMetaModel); models.put("otx", otxMetaModel); models.put("otxHmi", hmiMetaModel); models.put("IN", modelTransformationInputModel); models.put("OUT", otxOutputModel); models.put("hmi", hmiOutputModel); /** * Determine the compiled ATL rule file. */ final URL atlAsmUrl = new URL( "..\\transformate2otx.asm"); /** * Important: Allow inter-model references. */ final Map<String, String> options = new HashMap<String, String>(); options.put("allowInterModelReferences", "true"); // options.put("outputModelContentTypesDetection", "true"); /** * Perform the model-to-model transformation. */ AtlLauncher.getDefault().launch(atlAsmUrl, Collections.emptyMap(), models, Collections.emptyMap(), Collections.emptyList(), options); modelLoader.save(otxOutputModel, otxOutputUri.toFileString());