Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Saving Model Programmatically
[ATL] Saving Model Programmatically [message #83990] Mon, 09 June 2008 12:23
Mark Melia is currently offline Mark MeliaFriend
Messages: 142
Registered: July 2009
Senior Member
Hi all,

I am using code from a post in Jan, by Wong who outlined code to use to do
a transformation programmatically. The problem is when I go to save the
model created from the transformation, I get an exception suggestion that
the workspace is closed.

Below is the error and then the code (commented where exception occours)

Anybody have any ideas?
Mark

Trans MM: Author >>> Person
Trans Instance: IN >>> OUT
ASM: /home/mmelia/workspace3/AntworksDennies1/bin/Author2Person.a sm
09-Jun-2008 12:39:30 org.eclipse.m2m.atl.engine.vm.nativelib.ASMModel save
SEVERE: ERROR: save not implemented !
java.lang.IllegalStateException: Workspace is closed.
at
org.eclipse.core.resources.ResourcesPlugin.getWorkspace(Reso urcesPlugin.java:326)
at
org.eclipse.m2m.atl.engine.AtlEMFModelHandler.saveModel(AtlE MFModelHandler.java:144)
at
org.eclipse.m2m.atl.engine.AtlEMFModelHandler.saveModel(AtlE MFModelHandler.java:65)
at JavaATL.ATLTransformations.runATLTransformation(JavaATL.java :111)
at JavaATL.ATLTransformations.main(JavaATL.java:43)

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;


import org.atl.eclipse.engine.AtlLauncher;
import org.atl.eclipse.engine.AtlModelHandler;
import org.atl.engine.vm.nativelib.ASMModel;


class ATLTransformations {



public static void main(String[] args) {

runATLTransformation();


}


public static void runATLTransformation() {


try {
AtlModelHandler emfamh =
AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);

URL asmurl = ATLTransformations.class.getResource("../DM2CG.asm");
ASMModel inputMetaModel = emfamh.loadModel("DOMAIN", emfamh.getMof(),
ATLTransformations.class.getResource("../Metamodels/skos2.ecore ").openStream());
ASMModel outputMetaModel = emfamh.loadModel("COURSE", emfamh.getMof(),
ATLTransformations.class.getResource("../Metamodels/Course.ecore ").openStream());
ASMModel inputInstance = emfamh.loadModel("inputInstance",
emfamh.getMof(),
ATLTransformations.class.getResource("../caviar.ecore").openStream());
ASMModel outputInstance;


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

models.put(inputMetaModel.getName(), inputMetaModel);
models.put(outputMetaModel.getName(), outputMetaModel);
System.out.println("Trans MM: "+inputMetaModel.getName()+" >>>
"+outputMetaModel.getName());

models.put("IN", inputInstance); // input model
outputInstance = emfamh.newModel("coursexmi", outputMetaModel); // output
model
models.put("OUT", outputInstance);
System.out.println("Trans Instance: "+inputInstance.getName()+" >>>
"+outputInstance.getName());

Map params = Collections.EMPTY_MAP;
Map libs = Collections.EMPTY_MAP;

System.out.println("ASM: "+asmurl.getPath());


AtlLauncher.getDefault().launch(asmurl, libs, models, params);

OutputStream out = new FileOutputStream(new
File("C:/workspaceEclipse/Antworks/bin/zzzz.xmi"));


AtlModelHandler.getHandler(outputMetaModel).saveModel(output Instance,out);
//*************EXCEPTION THROWN**********************/



System.out.println(outputInstance);
out.flush();
out.close();

} catch (Exception e) {
e.printStackTrace();
}

}

}
Previous Topic:[ATL, UML] How to structure output model elements
Next Topic:UML Model generation from Other models
Goto Forum:
  


Current Time: Fri Apr 26 15:35:00 GMT 2024

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

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

Back to the top