Home » Modeling » ATL » ATL to ATL Refining Mode
ATL to ATL Refining Mode [message #985902] |
Fri, 16 November 2012 10:54  |
Eclipse User |
|
|
|
Hi,
I'm trying to refine my ATL transformation using ATL. The end goal is to dynamically build my input model list. However, i'm having lots of problems getting up and running.
I am running Eclipse Juno and ATL 3.2.1. The issues are as follows:
1) The ATL Metamodel is registered in the EMF Registry. Why is this? I can see the ecore model in the jar org.eclipse.m2m.atl.dsls_3.3.0.v201205241358
2) I have imported the ATL.ecore into my workspace due to the issue in #1. It does not validate. I see 3 errors.
3) When running a simple ATL refiner I get the following error, i assume it is because of #2, "Error loading platform:/resource/TestRefining/Public2Private.atl: org.xml.sax.SAXParseException: Content is not allowed in prolog."
The refiner is as follows:
-- @atlcompiler atl2010
-- @nsURI ATL=http://www.eclipse.org/gmt/2005/ATL
--http://www.eclipse.org/m2m/atl/2011/EMFTVM
--http://www.eclipse.org/gmt/2005/ATL
module AtlFlattenerRefine;
--create OUT : ATL refining IN : ATL;
create OUT : ATL from IN : ATL;
rule RebuildCreateList{
from s : ATL!Rule
to t : ATL!Rule(
name <-s. name+'ZZZZZZZZZ'.debug('q')
)
}
I also did some testing with ATL 3.3.1 but got nowhere there either. That said the ATL.ecore was available via the uri http://www.eclipse.org/m2m/atl/2011/EMFTVM. Any help is appreciated!
Thanks,
Ronan
|
|
| | | | | | | | | |
Re: ATL to ATL Refining Mode [message #986539 is a reply to message #986210] |
Tue, 20 November 2012 15:27   |
Eclipse User |
|
|
|
Op 19/11/12 14:29, Ronan B schreef:
> Hi Dennis,
> Okay I have tried to create this in an ANT script but I just get the following
> out:
>
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
>
> My ANT file looks like this:
>
> <project name="MyProject" default="x" basedir=".">
> <description>
> x
> </description>
> <target name="x" description="x" >
> <emftvm.loadMetamodel name="ATL"
> uri="http://www.eclipse.org/gmt/2005/ATL"/>
> <emftvm.loadModel name="Public2Private"
> wspath="TestRefining/Public2Private.atl"/>
> <emftvm.run modulepath="platform:/resource/TestRefining/"
> module="ATLFlattenerRefine">
> <metamodel name="ATL"/>
> <inputmodel name="Public2Private" as="IN"/>
> <outputmodel name="ATLCopy-OUT" as="OUT"
> wspath="TestRefining/ZZZZ.xmi"/>
> </emftvm.run>
> <emftvm.saveModel name="ATLCopy-OUT" derived="true"/>
> </target>
> </project>
>
> When I run via the regular run configuration I get a full XMI file.
You should first load the .atl model, and then the ATL metamodel, because the
ATL parser insists on loading its own version of the ATL metamodel. EMFTVM
will reuse the ATL metamodel that was pre-loaded by the ATL parser.
Sounds counter-intuitive, but that's the conceptual mismatch between ATL and
EMF: EMF automatically determines the required metamodel from the model
itself, but ATL needs an explicit reference (to deal with output models,
a.o.). The Eclipse launch dialog takes care of this behind the scenes, but in
Ant, you prescribe the loading order.
>
> One other thing. It is cool the injection is automatic but how about
> serialization back to ATL for the output model with ANT.
>
> Thanks!
> Ronan
EMF selects the resource implementation (XMI, XML, ATL ,...) based on file
extension. That's why you need to save your UML models using the .uml
extension, or the wrong resource implementation is used.
If you want EMF to select the ATL resource implementation for the output
model, you should use the .atl file extension. Then you will get a textual ATL
file.
Cheers,
Dennis
|
|
| | | |
Re: ATL to ATL Refining Mode [message #987405 is a reply to message #986432] |
Mon, 26 November 2012 08:48   |
Eclipse User |
|
|
|
Hi Etienne,
I finally got the emftvm to run via the API. Unfortuantely the API is not the same as the one provided before in CoreService. Perhaps it can be in the future? I figured this out by debugging a laucnher that works. You will need a copy of many of the methods in org.eclipse.m2m.atl.emftvm.launcher/EMFTVMLaunchConfigurationDelegate to make this work. They are private there. The values are hardcoded below but are easily made generic.
ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
ResourceSet rs = new ResourceSetImpl();
Map<String, String> metamodelLocations = new HashMap<String, String>();
metamodelLocations.put("ATL","http://www.eclipse.org/gmt/2005/ATL");
Map<String, String> metamodelOptions = new HashMap<String, String>();
loadFileMetaModels(rs, metamodelLocations, metamodelOptions, env);
Map<String, String> inputModelLocations = new HashMap<String, String>();
inputModelLocations.put("IN", "platform:/resource/TestRefining/Public2Private.atl");
Map<String, String> inputModelOptions = new HashMap<String, String>();
loadInputModels(rs, inputModelLocations, inputModelOptions, env);
Map<String, String> outputModelLocations = new HashMap<String, String>();
outputModelLocations.put("OUT","platform:/resource/TestRefining/Public2Private_refined.atl");
Map<String, String> outputModelOptions = new HashMap<String, String>();
outputModelOptions.put("OUT","allowIntermodelReferences derivedFile");
createOutputModels(rs, outputModelLocations, outputModelOptions, env);
loadOtherMetaModels(rs, metamodelLocations, metamodelOptions, env);
ModuleResolver resolver = createModuleResolver("/TestRefining/");
env.loadModule(resolver, "ATLCopy");
TimingData timingData = new TimingData();
env.run(timingData);
Map<String, String> emptyMap = Collections.emptyMap();
saveModels(env.getOutputModels(), outputModelOptions, emptyMap);
After getting all this to work in Juno I found out the emftvm compiler does not work in Eclipse Helios Version: 3.6.2.r362_v20101104-9SAxFMKFkSAqi8axkv1ZjegmiBLY
Build id: M20110210-1200. I get the following error:
Errors occurred during the build.
Errors running builder 'ATL builder' on project 'X'.
org.eclipse.emf.ecore.util.Switch
Should I file a bug Dennis?
Regards,
Ronan
|
|
|
Re: ATL to ATL Refining Mode [message #987500 is a reply to message #987405] |
Mon, 26 November 2012 16:23   |
Eclipse User |
|
|
|
Hello Ronan, Etienne,
Op 26/11/12 14:48, Ronan B schreef:
> Hi Etienne,
> I finally got the emftvm to run via the API. Unfortuantely the API is not the
> same as the one provided before in CoreService. Perhaps it can be in the
> future? I figured this out by debugging a laucnher that works. You will need a
> copy of many of the methods in
> org.eclipse.m2m.atl.emftvm.launcher/EMFTVMLaunchConfigurationDelegate to make
> this work. They are private there. The values are hardcoded below but are
> easily made generic.
>
> ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
> ResourceSet rs = new ResourceSetImpl();
Basically, ExecEnv *is* the API. EMFTVM does not align with ATL's ILauncher
and IModel interfaces due to explicit design choice:
1. ATL/EMFTVM should not provide API for model loading/saving: this is the
domain of EMF. Any questions regarding loading/saving/parsing/pretty-printing
should be forwardable to EMF/EMFText/xText(/TCS?) whenever possible.
ATL/EMFTVM should stick to transformation.
2. ATL/EMFTVM should not record model-metamodel relationships when it cannot
enforce them anyway; EMF has a different, incompatible way of representing
model-metamodel relationships (i.e. on a per-instance basis, using XML
namespaces for example).
>
>
> Map<String, String> metamodelLocations = new HashMap<String, String>();
> metamodelLocations.put("ATL","http://www.eclipse.org/gmt/2005/ATL");
> Map<String, String> metamodelOptions = new HashMap<String, String>();
> loadFileMetaModels(rs, metamodelLocations, metamodelOptions, env);
>
> Map<String, String> inputModelLocations = new HashMap<String, String>();
> inputModelLocations.put("IN",
> "platform:/resource/TestRefining/Public2Private.atl");
> Map<String, String> inputModelOptions = new HashMap<String, String>();
> loadInputModels(rs, inputModelLocations, inputModelOptions, env);
>
> Map<String, String> outputModelLocations = new HashMap<String, String>();
> outputModelLocations.put("OUT","platform:/resource/TestRefining/Public2Private_refined.atl");
>
> Map<String, String> outputModelOptions = new HashMap<String, String>();
> outputModelOptions.put("OUT","allowIntermodelReferences derivedFile");
> createOutputModels(rs, outputModelLocations, outputModelOptions, env);
>
> loadOtherMetaModels(rs, metamodelLocations, metamodelOptions, env);
>
> ModuleResolver resolver = createModuleResolver("/TestRefining/");
> env.loadModule(resolver, "ATLCopy");
>
> TimingData timingData = new TimingData();
> env.run(timingData);
> Map<String, String> emptyMap = Collections.emptyMap();
> saveModels(env.getOutputModels(), outputModelOptions, emptyMap);
The above code translates an Eclipse launch configuration to the EMFTVM
ExecEnv API. Another example of using EMFTVM as part of an Eclipse plug-in can
be found here (see lines 200-225):
http://soft.vub.ac.be/viewvc/UML2CaseStudies/uml2cs-instantmessenger-config-editor/src/be/ac/vub/uml2cs/instantmessenger/popup/actions/GenerateBuildFileAction.java?view=markup
The basic recipe is quite simple:
1. Wrap any loaded EMF models inside EMFTVM Model and Metamodel instances:
Metamodel xml = EmftvmFactory.eINSTANCE.createMetamodel();
xml.setResource(emfResource);
Model in = EmftvmFactory.eINSTANCE.createModel();
in.setResource(anotherEmfResource);
1. Create an ExecEnv instance:
ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
2. Register any input/output/inout/meta-models:
env.registerMetaModel("CFG", cfg);
env.registerMetaModel("XML", xml);
env.registerInputModel("IN", in);
env.registerOutputModel("OUT", pars);
3. Create a module resolver that can load .emftvm modules and their imports
(DefaultModuleResolver expects a trailing '/' in the prefix!):
ModuleResolver resolver = new
DefaultModuleResolver("platform:/resource/.../", resourceSet);
4. Load a named module using the module resolver:
env.loadModule(resolver, "Module");
-- or, for modules that are contained in a package (folder):
env.loadModule(resolver, "Package::Module");
5. Run the transformation:
env.run(null);
You may add a TimingData object to the mix as well, if you're interested in
performance statistics.
>
> After getting all this to work in Juno I found out the emftvm compiler does
> not work in Eclipse Helios Version:
> 3.6.2.r362_v20101104-9SAxFMKFkSAqi8axkv1ZjegmiBLY
> Build id: M20110210-1200. I get the following error:
>
> Errors occurred during the build.
> Errors running builder 'ATL builder' on project 'X'.
> org.eclipse.emf.ecore.util.Switch
>
> Should I file a bug Dennis?
Hmm, you may. Try to include a stack trace as well. I suspect that I'm using a
newer version EMF... I've only tried EMFTVM on Eclipse 3.7 and up.
Cheers,
Dennis
>
> Regards,
> Ronan
>
>
>
>
|
|
| |
Goto Forum:
Current Time: Wed Jul 23 17:13:13 EDT 2025
Powered by FUDForum. Page generated in 0.05170 seconds
|