| Home » Archived » M2M (model-to-model transformation) » [ATL] extracting a model with 3.0 EMF Specific VM
 Goto Forum:| 
| [ATL] extracting a model with 3.0 EMF Specific VM [message #103090] | Wed, 08 April 2009 12:30  |  | 
| Eclipse User  |  |  |  |  | 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 #103213 is a reply to message #103145] | Thu, 09 April 2009 07:14   |  | 
| Eclipse User  |  |  |  |  | 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 #103451 is a reply to message #103265] | Tue, 14 April 2009 07:03  |  | 
| Eclipse User  |  |  |  |  | > 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.
 |  |  |  | 
 
 
 Current Time: Fri Oct 31 16:57:11 EDT 2025 
 Powered by FUDForum . Page generated in 0.05393 seconds |