Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to convert ATL-file to EMF-file?
How to convert ATL-file to EMF-file? [message #894816] Tue, 10 July 2012 16:03 Go to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi,

I would like to translate ATL-transformation code (from .atl- or .asm-files) into an EMF-model (.xmi-file). The aim is to further process the result in a M2M-transformation.

I guess the result should conform to ATL.ecore (or ATL-0.2.ecore ?). Or is there any other source for the current ATL-Metamodel?

Is there any way to automatically generate the needed xmi-file?

Thanks in advance for your help
Re: How to convert ATL-file to EMF-file? [message #896279 is a reply to message #894816] Tue, 17 July 2012 20:42 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 10-07-12 18:03, jo W schreef:
> Hi,
>
> I would like to translate ATL-transformation code (from .atl- or .asm-files)
> into an EMF-model (.xmi-file). The aim is to further process the result in a
> M2M-transformation.
>
> I guess the result should conform to ATL.ecore (or ATL-0.2.ecore ?). Or is
> there any other source for the current ATL-Metamodel?
>
> Is there any way to automatically generate the needed xmi-file?
>
> Thanks in advance for your help

If I remember correctly, AM3 used to be able to do this with a right-click action.

Currently, this scenario is also supported by EMFTVM
(http://wiki.eclipse.org/ATL/EMFTVM). To do this, run the ATLCopy.atl
transformation on a .atl file as input and a .xmi file as output:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/plugins/org.eclipse.m2m.atl.emftvm.compiler/transformations/ATLCopy.atl?view=markup&root=Modeling_Project

Use "http://www.eclipse.org/gmt/2005/ATL" as the URI for the ATL metamodel.

Cheers,
Dennis
Re: How to convert ATL-file to EMF-file? [message #896453 is a reply to message #896279] Wed, 18 July 2012 12:24 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
+1 on this subject.
I'm lucky this came up so recently.
Dennis, which should be the "SUPER" input that the transformation takes?
Thanks and best regards,
Juan Pedro

El 17/07/2012 22:42, Dennis Wagelaar escribió:
> Op 10-07-12 18:03, jo W schreef:
>> Hi,
>>
>> I would like to translate ATL-transformation code (from .atl- or .asm-files)
>> into an EMF-model (.xmi-file). The aim is to further process the result in a
>> M2M-transformation.
>>
>> I guess the result should conform to ATL.ecore (or ATL-0.2.ecore ?). Or is
>> there any other source for the current ATL-Metamodel?
>>
>> Is there any way to automatically generate the needed xmi-file?
>>
>> Thanks in advance for your help
>
> If I remember correctly, AM3 used to be able to do this with a right-click action.
>
> Currently, this scenario is also supported by EMFTVM
> (http://wiki.eclipse.org/ATL/EMFTVM). To do this, run the ATLCopy.atl
> transformation on a .atl file as input and a .xmi file as output:
>
> http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/plugins/org.eclipse.m2m.atl.emftvm.compiler/transformations/ATLCopy.atl?view=markup&root=Modeling_Project
>
> Use "http://www.eclipse.org/gmt/2005/ATL" as the URI for the ATL metamodel.
>
> Cheers,
> Dennis
Re: How to convert ATL-file to EMF-file? [message #896523 is a reply to message #896279] Wed, 18 July 2012 16:23 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Many Thanks, Dennis. This is really good news.

Although I still have some problems getting your transformation to run:

First, the location for the ATL metamodel does not seem to be existing. I tried the URI you named and got the following Exception: Error loading http://www.eclipse.org/gmt/2005/ATL: java.io.FileNotFoundException: http://www.eclipse.org/gmt/2005/ATL

Second, like Juan Pedro, I also don't know what input is expected for source model SUPER.

Best regards
Josa
Re: How to convert ATL-file to EMF-file? [message #896730 is a reply to message #896523] Thu, 19 July 2012 14:05 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 18-07-12 18:23, jo W schreef:
> Many Thanks, Dennis. This is really good news.
>
> Although I still have some problems getting your transformation to run:
>
> First, the location for the ATL metamodel does not seem to be existing. I
> tried the URI you named and got the following Exception: Error loading
> http://www.eclipse.org/gmt/2005/ATL: java.io.FileNotFoundException:
> http://www.eclipse.org/gmt/2005/ATL
>
> Second, like Juan Pedro, I also don't know what input is expected for source
> model SUPER.
>
> Best regards
> Josa

You don't need the SUPER model (you may in fact delete it from ATLCopy.atl).
I'm running this from Ant:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/tests/org.eclipse.m2m.atl.emftvm.tests/anttest/build.xml?view=markup&root=Modeling_Project

Dennis
Re: How to convert ATL-file to EMF-file? [message #899291 is a reply to message #896730] Tue, 31 July 2012 11:21 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi!
I can't get the ANT File running.
Even when I change the paths to my local directories, I get a load error at line 15:
"Problem: failed to create task or type emftvm.loadModel
Cause: The name is undefined."
I am not familiar to ANT tasks, so maybe it is just a beginners mistake.
Thanks for any help
Josa


Dennis Wagelaar wrote on Thu, 19 July 2012 10:05


You don't need the SUPER model (you may in fact delete it from ATLCopy.atl).
I'm running this from Ant:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/tests/org.eclipse.m2m.atl.emftvm.tests/anttest/build.xml?view=markup&root=Modeling_Project

Dennis

Re: How to convert ATL-file to EMF-file? [message #899421 is a reply to message #899291] Tue, 31 July 2012 18:34 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 31-07-12 13:21, jo W schreef:
> Hi!
> I can't get the ANT File running.
> Even when I change the paths to my local directories, I get a load error at
> line 15:
> "Problem: failed to create task or type emftvm.loadModel
> Cause: The name is undefined."
> I am not familiar to ANT tasks, so maybe it is just a beginners mistake.
> Thanks for any help
> Josa
>
>
> Dennis Wagelaar wrote on Thu, 19 July 2012 10:05
>> You don't need the SUPER model (you may in fact delete it from ATLCopy.atl).
>> I'm running this from Ant:
>>
>> http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/tests/org.eclipse.m2m.atl.emftvm.tests/anttest/build.xml?view=markup&root=Modeling_Project

Read this:
http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Tools#Launching_an_Ant_file_with_ATL_tasks_in_an_Eclipse_workbench

Then this:
http://wiki.eclipse.org/ATL/EMFTVM#Running_EMFTVM_modules

Dennis
Re: How to convert ATL-file to EMF-file? [message #901608 is a reply to message #899421] Mon, 13 August 2012 16:17 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi Dennis,
thanks a lot, I finally got the transformation working!

Unfortunately now a new problem occurs:
My aim is to define a (partly) translation between Henshin and ATL as model to model HOT using Henshin as language for this transformation. For this I need the suited meta-models for ATL and OCL.
I tried to import from the locations
http://www.eclipse.org/gmt/2005/ATL
and
http://www.eclipse.org/gmt/2005/OCL
but this failed.
I also tried to use ecore-files I found for ATL and OCL, but I do not know whether I have the right file for ATL and for OCL it does not work, because I do not have a definition fitting to ATL.
Also when I try to open the generated xmi file (from your transformation) with sample reflective ecore model editor in eclipse, I get a lot of PackageNotFoundExceptions and ClassNotFoundExceptions regarding OCL.

Hoping for more help
Josa
Re: How to convert ATL-file to EMF-file? [message #901761 is a reply to message #901608] Tue, 14 August 2012 13:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4187
Registered: July 2009
Senior Member
Hi

I can't help you will the ATL reference and can only provide some clues
on the OCL reference, since you didn't tell us what OCL file you found
where or when.

If. as it appears. you are using ATL as your model, then you should be
aware that ATL does not use OCL; just something that has many
similarities to OCL. You must use the 'OCL' model that comes with ATL.

"http://www.eclipse.org/gmt/2005/OCL" is unlikely to be correct since
GMT has never hosted an OCL project.

Regards

Ed Willink


On 13/08/2012 17:17, jo W wrote:
> Hi Dennis,
> thanks a lot, I finally got the transformation working!
>
> Unfortunately now a new problem occurs:
> My aim is to define a (partly) translation between Henshin and ATL as
> model to model HOT using Henshin as language for this transformation.
> For this I need the suited meta-models for ATL and OCL.
> I tried to import from the locations http://www.eclipse.org/gmt/2005/ATL
> and
> http://www.eclipse.org/gmt/2005/OCL
> but this failed.
> I also tried to use ecore-files I found for ATL and OCL, but I do not
> know whether I have the right file for ATL and for OCL it does not
> work, because I do not have a definition fitting to ATL.
> Also when I try to open the generated xmi file (from your
> transformation) with sample reflective ecore model editor in eclipse,
> I get a lot of PackageNotFoundExceptions and ClassNotFoundExceptions
> regarding OCL.
>
> Hoping for more help
> Josa
Re: How to convert ATL-file to EMF-file? [message #902651 is a reply to message #901761] Thu, 16 August 2012 17:08 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 14-08-12 15:24, Ed Willink schreef:
> Hi
>
> I can't help you will the ATL reference and can only provide some clues on the
> OCL reference, since you didn't tell us what OCL file you found where or when.
>
> If. as it appears. you are using ATL as your model, then you should be aware
> that ATL does not use OCL; just something that has many similarities to OCL.
> You must use the 'OCL' model that comes with ATL.
>
> "http://www.eclipse.org/gmt/2005/OCL" is unlikely to be correct since GMT has
> never hosted an OCL project.
>
> Regards
>
> Ed Willink

The URL "http://www.eclipse.org/gmt/2005/OCL" refers to an internal EPackage
inside ATL.ecore. It is not related to Eclipse OCL, and in fact refers to
ATL's implementation of OCL.

>
>
> On 13/08/2012 17:17, jo W wrote:
>> Hi Dennis,
>> thanks a lot, I finally got the transformation working!
>>
>> Unfortunately now a new problem occurs:
>> My aim is to define a (partly) translation between Henshin and ATL as model
>> to model HOT using Henshin as language for this transformation. For this I
>> need the suited meta-models for ATL and OCL.
>> I tried to import from the locations http://www.eclipse.org/gmt/2005/ATL
>> and
>> http://www.eclipse.org/gmt/2005/OCL
>> but this failed.
>> I also tried to use ecore-files I found for ATL and OCL, but I do not know
>> whether I have the right file for ATL and for OCL it does not work, because
>> I do not have a definition fitting to ATL.
>> Also when I try to open the generated xmi file (from your transformation)
>> with sample reflective ecore model editor in eclipse, I get a lot of
>> PackageNotFoundExceptions and ClassNotFoundExceptions regarding OCL.
>>
>> Hoping for more help
>> Josa

You can't really re-open that XMI, I'm afraid. ATL does not register its
namespace URIs with EMF. However, because you have EMFTVM installed, you can
open .atl files directly in EMF editors (EMFTVM registers an EMF
ResourceFactory for .atl files). Therefore, Henshin should also be able to
open a .atl file as an EMF model.

Regards,
Dennis
Re: How to convert ATL-file to EMF-file? [message #902652 is a reply to message #902651] Thu, 16 August 2012 18:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4187
Registered: July 2009
Senior Member
Hi Dennis

Since ATL is not part of GMT any more you might plan to migrate the URIs
to e.g. http://www.eclipse.org/atl/2012/ATL and e.g.
..http://www.eclipse.org/atl/2012/OCL.

You can always put in duplicate registrations to preserve backwards
compatibility.

Regards

Ed Willink


On 16/08/2012 18:08, Dennis Wagelaar wrote:
> Op 14-08-12 15:24, Ed Willink schreef:
>> Hi
>>
>> I can't help you will the ATL reference and can only provide some clues on the
>> OCL reference, since you didn't tell us what OCL file you found where or when.
>>
>> If. as it appears. you are using ATL as your model, then you should be aware
>> that ATL does not use OCL; just something that has many similarities to OCL.
>> You must use the 'OCL' model that comes with ATL.
>>
>> "http://www.eclipse.org/gmt/2005/OCL" is unlikely to be correct since GMT has
>> never hosted an OCL project.
>>
>> Regards
>>
>> Ed Willink
> The URL "http://www.eclipse.org/gmt/2005/OCL" refers to an internal EPackage
> inside ATL.ecore. It is not related to Eclipse OCL, and in fact refers to
> ATL's implementation of OCL.
>
>>
>> On 13/08/2012 17:17, jo W wrote:
>>> Hi Dennis,
>>> thanks a lot, I finally got the transformation working!
>>>
>>> Unfortunately now a new problem occurs:
>>> My aim is to define a (partly) translation between Henshin and ATL as model
>>> to model HOT using Henshin as language for this transformation. For this I
>>> need the suited meta-models for ATL and OCL.
>>> I tried to import from the locations http://www.eclipse.org/gmt/2005/ATL
>>> and
>>> http://www.eclipse.org/gmt/2005/OCL
>>> but this failed.
>>> I also tried to use ecore-files I found for ATL and OCL, but I do not know
>>> whether I have the right file for ATL and for OCL it does not work, because
>>> I do not have a definition fitting to ATL.
>>> Also when I try to open the generated xmi file (from your transformation)
>>> with sample reflective ecore model editor in eclipse, I get a lot of
>>> PackageNotFoundExceptions and ClassNotFoundExceptions regarding OCL.
>>>
>>> Hoping for more help
>>> Josa
> You can't really re-open that XMI, I'm afraid. ATL does not register its
> namespace URIs with EMF. However, because you have EMFTVM installed, you can
> open .atl files directly in EMF editors (EMFTVM registers an EMF
> ResourceFactory for .atl files). Therefore, Henshin should also be able to
> open a .atl file as an EMF model.
>
> Regards,
> Dennis
Re: How to convert ATL-file to EMF-file? [message #904391 is a reply to message #902651] Tue, 28 August 2012 11:09 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hey guys, thanks a lot!
I managed to load the EMFTVM-Files of my transformation in Henshin after manually registering the ResourceFactory for EMFTVM.
So now via EMFTVM-Metamodel I am able to define my Higher Order Transformation and apply it on any EMFTVM-File.

Now I got one more question:
How can I go back from my (generated) EMFTVM-File to an ATL-Code-File?

Regards
Josa
Re: How to convert ATL-file to EMF-file? [message #908142 is a reply to message #902652] Tue, 04 September 2012 20:25 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 16-08-12 20:00, Ed Willink schreef:
> Hi Dennis
>
> Since ATL is not part of GMT any more you might plan to migrate the URIs to
> e.g. http://www.eclipse.org/atl/2012/ATL and e.g.
> .http://www.eclipse.org/atl/2012/OCL.
>
> You can always put in duplicate registrations to preserve backwards
> compatibility.
>
> Regards
>
> Ed Willink
>

Even though that's a sound plan for the future, that likely breaks quite a
number of tacit dependencies in ATL's parser and compiler... For now, no URI
is registered at all with EMF. This is because ATL's parser insists on loading
the ATL metamodel from file/input stream, bypassing the EMF URI resolving
machinery. Registering ATL's URI with EMF will give you the false idea that
you've loaded the correct ATL metamodel, whereas any parsed .atl file will
actually be loaded against a //different instance// of the same metamodel.

Probably this situation needs to be resolved first. It also needs to be
resolved in a way that works without having the EMF registry available (i.e.
standalone).

The reason that EMFTVM can still use ATL namespace URI, is because by parsing
the .atl file into an EMF ResourceSet, the ATL metamodel is implicitly
registered under its namespace URI within that ResourceSet. Also, ATL's
namespace URI is read from the .ecore file in this case, which prevents
registering more than one namespace URI.

Regards,
Dennis
Re: How to convert ATL-file to EMF-file? [message #908148 is a reply to message #904391] Tue, 04 September 2012 20:35 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 28-08-12 13:09, jo W schreef:
> Hey guys, thanks a lot! I managed to load the EMFTVM-Files of my
> transformation in Henshin after manually registering the ResourceFactory for
> EMFTVM.
> So now via EMFTVM-Metamodel I am able to define my Higher Order Transformation
> and apply it on any EMFTVM-File.
>
> Now I got one more question:
> How can I go back from my (generated) EMFTVM-File to an ATL-Code-File?
>
> Regards
> Josa

Wait! You used the compiled ATL file (.emftvm) as input for Henshin? Also
cool, but not what you want ;-). Try opening a .atl file with the "Sample
Reflective Ecore Editor" that comes with EMF. EMFTVM makes .atl files
dynamically available as EMF models (AtlParser actually always did this, but
kept it hidden from the end-user).

Cheers,
Dennis
Re: How to convert ATL-file to EMF-file? [message #909032 is a reply to message #908148] Thu, 06 September 2012 12:49 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi,
I can load the .atl-file in Sample Reflective Ecore Editor, but not in Henshin. With the additionally registered Resource Factory for EMFTVM (EMFTVMResourceFactoryImpl.java) I can load the .emftvm-file in Henshin, but for .atl it says "wrong magic". I guess that it's just the wrong Resource Factory, but can't find one for ATL.
Also I fear, that I would get into the same old trouble again with the ATL-metamodell that has to be registered in Henshin for defining the transformation. For EMFTVM it was quite easy to add the metamodell to my Henshin transformation.
Thanks again
Josa
Re: How to convert ATL-file to EMF-file? [message #912021 is a reply to message #909032] Wed, 12 September 2012 19:59 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 06/09/12 14:49, jo W schreef:
> Hi, I can load the .atl-file in Sample Reflective Ecore Editor, but not in
> Henshin. With the additionally registered Resource Factory for EMFTVM
> (EMFTVMResourceFactoryImpl.java) I can load the .emftvm-file in Henshin, but
> for .atl it says "wrong magic". I guess that it's just the wrong Resource
> Factory, but can't find one for ATL.
> Also I fear, that I would get into the same old trouble again with the
> ATL-metamodell that has to be registered in Henshin for defining the
> transformation. For EMFTVM it was quite easy to add the metamodell to my
> Henshin transformation.
> Thanks again
> Josa

It's called org.eclipse.m2m.atl.emftvm.compiler.AtlResourceFactoryImpl:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2m/org.eclipse.m2m.atl/plugins/org.eclipse.m2m.atl.emftvm.compiler/src/org/eclipse/m2m/atl/emftvm/compiler/AtlResourceFactoryImpl.java?view=markup&root=Modeling_Project

Cheers,
Dennis
Re: How to convert ATL-file to EMF-file? [message #912548 is a reply to message #912021] Thu, 13 September 2012 18:53 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
I just found out that I was using ATL version 3.3.0 and that there is a newer one. Now with version 3.3.1 I could fill in the AtlResourceFactoryImpl which seemed to be missing before.
When I used Emftvm as input model I had to include EmftvmPackage (import org.eclipse.m2m.atl.emftvm.EmftvmPackage) into my Java-code, now I cannot find something like AtlPackage. Do I have to add this or does the EmftvmPackage work?

Also I get the following error:
Loading atl2henshin transformation system...
Loading ATL input model in 'Class2RDBMS.atl'
Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/runtime/TokenSource
at org.eclipse.m2m.atl.dsls.tcs.injector.ParserLauncher.parse(ParserLauncher.java:63)
at org.eclipse.m2m.atl.dsls.core.EMFTCSInjector.inject(EMFTCSInjector.java:88)
at org.eclipse.m2m.atl.engine.parser.AtlParser.inject(AtlParser.java:145)
at org.eclipse.m2m.atl.emftvm.compiler.AtlResourceImpl.doLoad(AtlResourceImpl.java:126)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.emf.henshin.model.resource.HenshinResourceSet.getResource(HenshinResourceSet.java:161)
at org.eclipse.emf.henshin.model.resource.HenshinResourceSet.getObject(HenshinResourceSet.java:173)
at atl2henshinTrigger.Atl2Henshin.run(Atl2Henshin.java:60)
at atl2henshinTrigger.Atl2Henshin.main(Atl2Henshin.java:106)
Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.TokenSource
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more

Any suggestions?
Thanks
Josa
Re: How to convert ATL-file to EMF-file? [message #913502 is a reply to message #912548] Sat, 15 September 2012 20:44 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 13/09/12 20:53, jo W schreef:
> I just found out that I was using ATL version 3.3.0 and that there is a newer
> one. Now with version 3.3.1 I could fill in the AtlResourceFactoryImpl which
> seemed to be missing before.
> When I used Emftvm as input model I had to include EmftvmPackage (import
> org.eclipse.m2m.atl.emftvm.EmftvmPackage) into my Java-code, now I cannot find
> something like AtlPackage. Do I have to add this or does the EmftvmPackage work?
>
> Also I get the following error:
> Loading atl2henshin transformation system...
> Loading ATL input model in 'Class2RDBMS.atl'
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/antlr/runtime/TokenSource
> at
> org.eclipse.m2m.atl.dsls.tcs.injector.ParserLauncher.parse(ParserLauncher.java:63)
>
> at
> org.eclipse.m2m.atl.dsls.core.EMFTCSInjector.inject(EMFTCSInjector.java:88)
> at org.eclipse.m2m.atl.engine.parser.AtlParser.inject(AtlParser.java:145)
> at
> org.eclipse.m2m.atl.emftvm.compiler.AtlResourceImpl.doLoad(AtlResourceImpl.java:126)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
>
> at
> org.eclipse.emf.henshin.model.resource.HenshinResourceSet.getResource(HenshinResourceSet.java:161)
>
> at
> org.eclipse.emf.henshin.model.resource.HenshinResourceSet.getObject(HenshinResourceSet.java:173)
>
> at atl2henshinTrigger.Atl2Henshin.run(Atl2Henshin.java:60)
> at atl2henshinTrigger.Atl2Henshin.main(Atl2Henshin.java:106)
> Caused by: java.lang.ClassNotFoundException: org.antlr.runtime.TokenSource
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 13 more
>
> Any suggestions?
> Thanks
> Josa

ATL requires ANTLR to parse the ATL textual format: you should include the
org.antlr.runtime plugin from Eclipse Orbit (version 3.0).

Dennis

P.S. Just out of curiousity: why do you need to run Henshin outside Eclipse?
Henshin is also an Eclipse plugin, right?
Re: How to convert ATL-file to EMF-file? [message #915475 is a reply to message #913502] Mon, 17 September 2012 11:07 Go to previous messageGo to next message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi Dennis,

I got it! ANTLR was already there, but I had to add it to my projects build path.
I am using Henshin as Eclipse plugin, i think there isn't even a standalone version.

Now I am back to my old metamodel problem. When I loaded my input for the transformation from .emftvm I was able to use the EMFTVM-metamodel for defining the transformation. As an example for a very basic transformation, I was able to read the Module from my input and define a Henshin Transformation System of the same name as output.
Now with the ATL file directly loaded as input I tried both the Module-type from the EMFTVM-metamodel and the one from ATL-0.2.ecore, but in both cases the Module could not be found in my input.

Is there any way to solve this issue? Any metamodel that is matching to my input created directly from the .atl-file?

Regards
Josa
Re: How to convert ATL-file to EMF-file? [message #916228 is a reply to message #915475] Tue, 18 September 2012 19:00 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Op 17-09-12 13:07, jo W schreef:
> Hi Dennis,
>
> I got it! ANTLR was already there, but I had to add it to my projects build path.
> I am using Henshin as Eclipse plugin, i think there isn't even a standalone
> version.

Then you can use Eclipse's plug-in dependency resolution, right? If your
project is a plug-in project, it can simply depend on
org.eclipse.m2m.atl.emftvm.*, and it will pull in all transitive dependencies
(just like Maven - the competition ;-)).

>
> Now I am back to my old metamodel problem. When I loaded my input for the
> transformation from .emftvm I was able to use the EMFTVM-metamodel for
> defining the transformation. As an example for a very basic transformation, I
> was able to read the Module from my input and define a Henshin Transformation
> System of the same name as output.
> Now with the ATL file directly loaded as input I tried both the Module-type
> from the EMFTVM-metamodel and the one from ATL-0.2.ecore, but in both cases
> the Module could not be found in my input.

Ah, Henshin also requires you to load a meta-model *before* you load the
model, is that right? ATL used to do that, which causes trouble for dynamic
metamodels (i.e. the ones for which you did not generate EMF plug-ins).

What likely goes wrong is the following:
- You (or Henshin) create(s) a ResourceSet.
- You load the ATL meta-model into this ResourceSet.
- The AtlParser loads the ATL file (model) into its own private ResourceSet,
based on its own instance of the ATL metamodel.
- You put the ATL file (model) into your ResourceSet.

You now have a situation where the ATL file (model) does *not* conform to the
ATL metamodel you loaded. Instead, it conforms to the ATL metamodel that the
*AtlParser* loaded. In ASCII graphics:

|--- Your ResourceSet ---| |--- AtlParser ResourceSet ---|
| ATL.ecore | | |
| transf.atl --------------> ATL.ecore |
|------------------------| |-----------------------------|

This problem is specific to AtlParser, which will not use your ResourceSet
with pre-loaded ATL metamodel.

>
> Is there any way to solve this issue? Any metamodel that is matching to my
> input created directly from the .atl-file?
>
> Regards
> Josa

In ATL EMFTVM this has been fixed by postponing the loading of metamodels by
namespace URI until after all models have been loaded. This way,
AtlResourceImpl will have had the opportunity to register the (namespace URIs
of the) ATL metamodel with your ResourceSet instance.

The Henshin example invocation code shows that its API exposes the ResourceSet:

http://dev.eclipse.org/svnroot/modeling/org.eclipse.emft.henshin/trunk/plugins/org.eclipse.emf.henshin.examples/src/org/eclipse/emf/henshin/examples/bank/BankExample.java

Try loading the ATL file into the ResourceSet *before* loading the Henshin
module. That way, Henshin should reuse the pre-registered version of the ATL
metamodel.

Regards,
Dennis
Re: How to convert ATL-file to EMF-file? [message #919774 is a reply to message #916228] Sat, 22 September 2012 10:24 Go to previous message
jo W is currently offline jo WFriend
Messages: 9
Registered: July 2012
Junior Member
Hi Dennis,

thank you so much. You were really a great help and kind of kept me going.
Now Christian Krause from Henshin development team could solve this problem for me with a rather complicated workaround that adds every element from the ATL model to the Henshin transformation system.

Regards
Josa

This is it:

package main;

import java.util.Iterator;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.henshin.interpreter.EGraph;
import org.eclipse.emf.henshin.interpreter.Engine;
import org.eclipse.emf.henshin.interpreter.RuleApplication;
import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
import org.eclipse.emf.henshin.interpreter.impl.EngineImpl;
import org.eclipse.emf.henshin.interpreter.impl.LoggingApplicationMonitor;
import org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl;
import org.eclipse.emf.henshin.model.Attribute;
import org.eclipse.emf.henshin.model.Edge;
import org.eclipse.emf.henshin.model.Node;
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.TransformationSystem;
import org.eclipse.emf.henshin.model.resource.HenshinResourceSet;
import org.eclipse.m2m.atl.emftvm.compiler.AtlResourceFactoryImpl;

public class ATL2Henshin {

public static final String RESULT = "generated-henshin.henshin";

public static void main(String[] args) {

HenshinResourceSet resourceSet = new HenshinResourceSet("model");

// Now we need to register the ATL resource factory:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("atl", new AtlResourceFactoryImpl());

// We are ready to load an ATL file now:
EObject atlModel = resourceSet.getObject("examples/test.atl");
System.out.println("Loaded ATL model: " + atlModel);

// Load the HOT:
TransformationSystem system = resourceSet.getTransformationSystem("atl2henshin.henshin");

// !!! WORKAROUND !!! //
injectAtlClasses(system);

// Create an EGraph and add the ATL model:
EGraph graph = new EGraphImpl();
graph.addTree(atlModel);

// Create an engine and a rule application:
Engine engine = new EngineImpl();

Rule testRule = system.findRuleByName("test");
RuleApplication app = new RuleApplicationImpl(engine);
app.setEGraph(graph);
app.setRule(testRule);

// Execute:
app.execute(new LoggingApplicationMonitor());

// THE RULE SHOULD BE SUCCESSFULLY APPLIED!!

// Get the result:
EObject result = (EObject) app.getResultParameterValue("t");
System.out.println("Result: " + result);
resourceSet.saveObject(result, RESULT);
System.out.println("Saved generated henshin transformation model in '" + RESULT + "'");

}


/* ==== WORKAROUND ==== */

private static void injectAtlClasses(TransformationSystem system) {
ResourceSet resourceSet = system.eResource().getResourceSet();
Iterator<EObject> it = system.eAllContents();
while (it.hasNext()) {
EObject obj = it.next();
if (obj instanceof Node) {
Node n = (Node) obj;
EPackage real = getRealAtlPackage(n.getType().getEPackage(), resourceSet);
if (real!=null) {
n.setType((EClass) real.getEClassifier(n.getType().getName()));
}
}
else if (obj instanceof Edge) {
Edge e = (Edge) obj;
EPackage real = getRealAtlPackage(e.getType().getEContainingClass().getEPackage(), resourceSet);
if (real!=null) {
EClass owner = (EClass) real.getEClassifier(e.getType().getEContainingClass().getName());
e.setType((EReference) owner.getEStructuralFeature(e.getType().getName()));
}
}
else if (obj instanceof Attribute) {
Attribute a = (Attribute) obj;
EPackage real = getRealAtlPackage(a.getType().getEContainingClass().getEPackage(), resourceSet);
if (real!=null) {
EClass owner = (EClass) real.getEClassifier(a.getType().getEContainingClass().getName());
a.setType((EAttribute) owner.getEStructuralFeature(a.getType().getName()));
}
}
}
}

private static EPackage getRealAtlPackage(EPackage epackage, ResourceSet resourceSet) {
if (epackage.getNsURI().toString().indexOf("gmt")>=0) {
return (EPackage) resourceSet.getPackageRegistry().get(epackage.getNsURI());
}
return null;
}

}
Previous Topic:Enumeration data type #in
Next Topic:One to many transformation
Goto Forum:
  


Current Time: Fri Dec 19 14:39:17 GMT 2014

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

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