Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] extracting a model with 3.0 EMF Specific VM
[ATL] extracting a model with 3.0 EMF Specific VM [message #103090] Wed, 08 April 2009 12:30 Go to next message
Eclipse UserFriend
I'm attempting to programmatically use the API for 3.0
to perform a transformation and extract the result
into a resource. I create a model using a model
factory and give with a "path" options with the
uri that I want to extract it to. After populating it
with a transformation, I'm attempting to extract
it using an extract method from the extractor, again
with the "path" option set, and get the following exception

org.eclipse.m2m.atl.core.ATLCoreException: No Resource found, unable to
extract to path: platform:/resource/ccc/library.ecore
at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(EMFExtract or.java:63)
at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(EMFExtract or.java:77)

It appears that the extract method assume that the model
already has an associated resource. Where should I have set this?

thanks
Andy.

--
-- ------------------------------------------------------------ -------------
Dr Andy Carpenter
School of Computer Science,
University of Manchester, Manchester M13 9PL, UK
Email: Andy.Carpenter@manchester.ac.uk
Tel: +44 161 275 6168
Fax: +44 161 275 6280
Re: [ATL] extracting a model with 3.0 EMF Specific VM [message #103145 is a reply to message #103090] Thu, 09 April 2009 04:38 Go to previous messageGo to next message
Eclipse UserFriend
hi,
i am extracting a model to a .ecore file with ATL3 simply with:
//Save to .ecore
atlASMModel.getModelLoader().save(atlASMModel, "file:/" +
destinationFile);

this saves the model in its xmi format.

is this what you want to do?
Re: [ATL] extracting a model with 3.0 EMF Specific VM [message #103213 is a reply to message #103145] Thu, 09 April 2009 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Skander,

It looks like your using a different API to me; my code is
given below. If I set the LAUNCHER_NAME to
"Regular VM (with debugger)", I get an Eclipse resource
containing the output model. When the name is set to
"EMF-specific VM", I get an exception. Having made
some changes overnight, the exception is now:

org.eclipse.m2m.atl.engine.emfvm.VMException
at
org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.set (EMFModelAdapter.java:609)
at
org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:437)
at
org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:373)
at
org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperat ion.java:373)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:177)
at
org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:134)

Andy.



Map<String, Object> options = new HashMap<String, Object>();
options.put("allowInterModelReferences", "true");

ILauncher launcher = CoreService.getLauncher(LAUNCHER_NAME);
// Regular VM expects allowInterModelReferences passed to initialize
launcher.initialize(options);

ModelFactory modelFactory = CoreService.createModelFactory(
launcher.getDefaultModelFactoryName());
IInjector injector = CoreService.getInjector(
modelFactory.getDefaultInjectorName());
IExtractor extractor = CoreService.getExtractor(
modelFactory.getDefaultEXtractorName());

// options only used by Regular VM
Map<String, Object> options = new HashMap<String, Object>();
options.put(ASMFactory.OPTION_NEW_MODEL, "false");
options.put(ASMFactory.OPTION_MODEL_NAME, "in Model");
options.put(ASMFactory.OPTION_MODEL_PATH, inResource.getURI().toString());
IModel inModel = modelFactory.newModel(inMetaModel, options);
injector.inject(inModel, inResource.getURI().toString());

launcher.addInModel(inModel, "in", "IN");

// options used by Regular VM
Map<String, Object> options = new HashMap<String, Object>();
options.put(ASMFactory.OPTION_NEW_MODEL, "true");
options.put(ASMFactory.OPTION_MODEL_NAME, "out Model");
options.put(ASMFactory.OPTION_MODEL_PATH, outUri);
// options used by EMF specific VM
options.put("path", outUri);
IModel outModel = modelFactory.newModel(outMetaModel, options);

launcher.addOutModel(outModel, "out", "OUT");

// EMF specific VM expects allowInterModelReferences passed to launch
launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), options,
getClass().getResourceAsStream(M2M_ASM));

extractor.extract(outModel, outUri);


"Skander " <skander.turki@gmail.com> wrote in message
news:2c002c3e1239503a750fd7fff7473d95$1@www.eclipse.org...
> hi,
> i am extracting a model to a .ecore file with ATL3 simply with:
> //Save to .ecore
> atlASMModel.getModelLoader().save(atlASMModel, "file:/" +
> destinationFile);
>
> this saves the model in its xmi format.
>
> is this what you want to do?
>
Re: [ATL] extracting a model with 3.0 EMF Specific VM [message #103230 is a reply to message #103213] Thu, 09 April 2009 09:33 Go to previous messageGo to next message
Eclipse UserFriend
i'm using ATL 3.0.0.v200903171237

here is my code:
public ASMModel injectAtlFileToAtlModel
(String sourceFile, String destinationFile){
// TODO Auto-generated method stub
System.out.println("injection started!");
ASMModel atlASMModel = null;

try
{

AtlModelHandler amh = AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
ModelFactory factory = CoreService.createModelFactory("EMF");
IReferenceModel atlMM = factory.newReferenceModel();

System.out.println(CoreService.getInjectorsNames());

IInjector injector = CoreService.getInjector("EMF"); //new ASMInjector();
injector.inject(atlMM, atlMMpath);

//Create an empty ATL model
InputStream input = new FileInputStream(sourceFile);
//Now Parsing from atl file to atl model
//Create a new parser
AtlParser atlParser = AtlParser.getDefault();
//Create a new ASMModel
amh.createModelLoader().newModel("Marte2ATL", "file:/" + sourceFile,
atlASMModel); //ASMFactory;
//Launch Parsing
atlASMModel = atlParser.parseToModel(input);

//Save to .ecore
atlASMModel.getModelLoader().save(atlASMModel, "file:/" + destinationFile);
//////////////////////
System.out.println("injection Ended!");
}
catch (Exception e)
{
e.printStackTrace();
}
return atlASMModel;
}

I'm using the API from the interim update site:
http://download.eclipse.org/modeling/m2m/updates/interim/
Re: [ATL] extracting a model with 3.0 EMF Specific VM [message #103265 is a reply to message #103090] Fri, 10 April 2009 05:20 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

The resource is created during the transformation, when new elements are
created into the output model.
So you may have an error during the transformation. To debug, note that
as EMFModel have getResource() and setResource() methods.

Regards,

William

Andy Carpenter a écrit :
> I'm attempting to programmatically use the API for 3.0
> to perform a transformation and extract the result
> into a resource. I create a model using a model
> factory and give with a "path" options with the
> uri that I want to extract it to. After populating it
> with a transformation, I'm attempting to extract
> it using an extract method from the extractor, again
> with the "path" option set, and get the following exception
>
> org.eclipse.m2m.atl.core.ATLCoreException: No Resource found, unable to
> extract to path: platform:/resource/ccc/library.ecore
> at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(EMFExtract or.java:63)
> at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(EMFExtract or.java:77)
>
> It appears that the extract method assume that the model
> already has an associated resource. Where should I have set this?
>
> thanks
> Andy.
>
Re: [ATL] extracting a model with 3.0 EMF Specific VM [message #103451 is a reply to message #103265] Tue, 14 April 2009 07:03 Go to previous message
Eclipse UserFriend
> The resource is created during the transformation, when new elements are
> created into the output model.
> So you may have an error during the transformation. To debug, note that as
> EMFModel have getResource() and setResource() methods.

William,

Thanks; I did have a problem with my transformation.

Andy.
Previous Topic:[ATL]containment reference problem
Next Topic:[ATL] conditionally run a transformation based on the result of another transformation
Goto Forum:
  


Current Time: Sun May 04 10:51:54 EDT 2025

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

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

Back to the top