[EMFTVM/ATL/SimpleGT] XMI Model injector and extractor [message #1727513] |
Wed, 23 March 2016 08:24  |
Eclipse User |
|
|
|
Hi All,
Sometimes, we have the need to extract a model version of ATL/SimpleGT transformation, e.g. an ATL transformation that transforms ATL/SimpleGT to EMFTVM requires an ATL/SimpleGT input model.
My tool tries to do some static analysis on ATL/SimpleGT transformations. ATL provides some facilities to generate a model version of ATL. I wonder how can I get a model version of SimpleGT?
Consult SimpleGT source code, I did something like this:
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("simplegt", new SimplegtResourceFactory());
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
URI uri = URI.createURI(filePath);
SimplegtResource resource = (SimplegtResource) rs.getResource(uri, true);
Model simplegtm = EmftvmFactory.eINSTANCE.createModel();
simplegtm.setResource(resource);
This probably enough for me. But I wonder can I serialize this model *simplegtm* as XMI model? e.g. can I using a EMFExtractor?
Thanks in advance.
Best,
Zheng
[Updated on: Wed, 23 March 2016 08:34] by Moderator
|
|
|
Re: [EMFTVM/ATL/SimpleGT] XMI Model injector and extractor [message #1727539 is a reply to message #1727513] |
Wed, 23 March 2016 11:34  |
Eclipse User |
|
|
|
My colleague helps me with this. For anybody who interests of doing this. The general idea is to wrap the *simplegt* resource to a *xmi* resource, and save it. It looks something like:
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("simplegt", new SimplegtResourceFactory());
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
URI uri = URI.createURI(filePath);
SimplegtResource resource = (SimplegtResource) rs.getResource(uri, true);
Model simplegtm = EmftvmFactory.eINSTANCE.createModel();
simplegtm.setResource(resource);
Resource xmiResource = rs.createResource(uri.appendFileExtension("xmi"));
xmiResource.getContents().addAll(EcoreUtil.copyAll(resource.getContents()));
xmiResource.save(null);
|
|
|
Powered by
FUDForum. Page generated in 0.10286 seconds