Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Running ATL in Java creates empty XMI document
[ATL] Running ATL in Java creates empty XMI document [message #510091] Tue, 26 January 2010 14:18
Eclipse UserFriend
Originally posted by: mschneider.uni-koblenz.de

Hi everyone,

I encountered a problem running an ATL Transformation in Java. I used
the example given from the JWT project and edited it to my models. But
somehow the result is an empty XMI document. To verify that I edited
everything correctly, here's my code:


private void createResources() {
modelLoader = new AtlEMFModelHandler().createModelLoader();

sparqlasResource =
SparqlasFactory.eINSTANCE.getClass().getResourceAsStream("/metamodel/sparqlas.ecore ");//$NON-NLS-1$
sparqlResource =
SparqlFactory.eINSTANCE.getClass().getResourceAsStream("/metamodel/sparql.ecore ");//$NON-NLS-1$

asmUrl =
ATLTransformation.class.getResource("/resources/sparqlas2sparql.asm ");//$NON-NLS-1$
}

private Map<String, ASMEMFModel> initMetamodels() {

Map<String, ASMEMFModel> models = new HashMap<String, ASMEMFModel>();

try {
sparqlasMetamodel = (ASMEMFModel) modelLoader.loadModel(
"sparqlas", modelLoader.getMOF(), sparqlasResource);//$NON-NLS-1$

sparqlMetamodel = (ASMEMFModel) modelLoader.loadModel(
"rq", modelLoader.getMOF(), sparqlResource);//$NON-NLS-1$
} catch (IOException e) {
e.printStackTrace();
}

models.put("sparqlas", sparqlasMetamodel);//$NON-NLS-1$ // here it
must be "sparqlas", else error
models.put("rq", sparqlMetamodel);//$NON-NLS-1$ // here it seems to
be irrelevant, whether "rq" or anything else
return models;
}

public boolean transform(Resource resource) {
boolean success = false;

createResources();

Map<String, ASMEMFModel> models = new HashMap<String, ASMEMFModel>();
models = initMetamodels(); // für ATLTransformationPostProcessor Zeile
auskommentieren

String inFilePath = resource.getURI().toFileString();
String outFilePath = resource.getURI().toFileString() + ".rq";

try {

// with regards to
org.eclipse.jwt.transformations.bpmn.internal.ATLTransformat ion
//
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jwt/tra nsformations/jwt-transformation-bpmn/?root=Technology_Projec t

// get/create models
ASMEMFModel sparqlasInputModel = (ASMEMFModel) modelLoader.loadModel(
"IN", sparqlasMetamodel, inFilePath);//$NON-NLS-1$
ASMEMFModel sparqlOutputModel = (ASMEMFModel) modelLoader.newModel(
"OUT", URI.createFileURI(outFilePath).toString(),
sparqlMetamodel);//$NON-NLS-1$

// load models
models.put("IN", sparqlasInputModel);//$NON-NLS-1$
models.put("OUT", sparqlOutputModel);//$NON-NLS-1$

// launch
AtlLauncher.getDefault().launch(this.asmUrl,
Collections.EMPTY_MAP, models, Collections.EMPTY_MAP,
Collections.EMPTY_LIST, Collections.EMPTY_MAP);

modelLoader.save(sparqlOutputModel, new
File(outFilePath).toURI().toURL().toString());

success = true;

} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
isInTransformation = false;
this.currentResource = null;
}

return success;
}

I think the problem lies within the ASM file, even if I have no idea how
that is possible. Anyway, I tried the exact code with the Familes2Persons
example and it worked out just fine. Any help would be highly appreciated.

Regards,
Mark Schneider
Previous Topic:Declarative QVT Execution
Next Topic:[ATL] ADT compatibility with eclipse and EMF
Goto Forum:
  


Current Time: Tue Oct 15 21:36:33 GMT 2019

Powered by FUDForum. Page generated in 0.02039 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top