Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] ecore to ecore transformation
[ATL] ecore to ecore transformation [message #63873] Fri, 12 October 2007 14:35 Go to next message
Eclipse UserFriend
Originally posted by: n.toublanc.laposte.net

Hi all,

I'm trying to write my first ATL project using Eclipse 3.3. Here is my
first ATL file :

module ClassModel2DAClassModel; -- Module Template
create da : MOF from dto : MOF;

rule Package{
from
ip :MOF!EPackage
to
op :MOF!EPackage(
name <- ip.name + '.da.hibernate.impl'
)
}

rule Class {
from
ic : MOF!EClass
to
oc : MOF!EClass (
name <- ic.name + 'DAImpl'
)
}

The result is that the packages and the classes are created with the
suffixes I specified.

Example :
- km3 format of my ecore input
package "com.mdd.test" {

class Project {
attribute name[0-1] : ;
attribute beginDate[0-1] : ;
attribute endDate[0-1] : ;
attribute id[0-1] : ;
}
- km3-like format of my ecore output
package "com.mdd.test.da.impl" {

}
class ProjectImpl {
}


So, it's not too bad to begin. The first problem is that my classes are
not in the package. How could I do that in my ATL file?

Then, I would like to add some methods in my MyClassDAImpl like :

public List<MyClass> getAll(){
}

How could I do that?

I will try to read the ATL guide to understand that myself, but I you
can simply explain me the concepts I need to know to do that, it would
really help me.


Thanks for your help.

Regards
Re: [ATL] ecore to ecore transformation [message #63896 is a reply to message #63873] Fri, 12 October 2007 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: freddy.allilaire.univ-nantes.fr

Hi Nicolas,

I advise you to take a look to the following article/example:
http://www.eclipse.org/m2m/atl/basicExamples_Patterns/Tree2L ist/
(especially section 6).

Regards,
Freddy.

Nicolas Toublanc a écrit :
> Hi all,
>
> I'm trying to write my first ATL project using Eclipse 3.3. Here is my
> first ATL file :
>
> module ClassModel2DAClassModel; -- Module Template
> create da : MOF from dto : MOF;
>
> rule Package{
> from
> ip :MOF!EPackage
> to
> op :MOF!EPackage(
> name <- ip.name + '.da.hibernate.impl'
> )
> }
>
> rule Class {
> from
> ic : MOF!EClass
> to
> oc : MOF!EClass (
> name <- ic.name + 'DAImpl'
> )
> }
>
> The result is that the packages and the classes are created with the
> suffixes I specified.
>
> Example :
> - km3 format of my ecore input
> package "com.mdd.test" {
>
> class Project {
> attribute name[0-1] : ;
> attribute beginDate[0-1] : ;
> attribute endDate[0-1] : ;
> attribute id[0-1] : ;
> }
> - km3-like format of my ecore output
> package "com.mdd.test.da.impl" {
>
> }
> class ProjectImpl {
> }
>
>
> So, it's not too bad to begin. The first problem is that my classes are
> not in the package. How could I do that in my ATL file?
>
> Then, I would like to add some methods in my MyClassDAImpl like :
>
> public List<MyClass> getAll(){
> }
>
> How could I do that?
>
> I will try to read the ATL guide to understand that myself, but I you
> can simply explain me the concepts I need to know to do that, it would
> really help me.
>
>
> Thanks for your help.
>
> Regards


--
Freddy Allilaire - ATLAS Group (INRIA & LINA)
http://www.sciences.univ-nantes.fr/lina/atl/contrib/allilair e
Re: [ATL] ecore to ecore transformation [message #63920 is a reply to message #63873] Fri, 12 October 2007 14:48 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000408080103040109060308
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

To link classes with packages, you must create the containment link in
the rule. In your case, you can add a binding in the "Package" rule,
like this :
eClassifiers <- ip.eClassifiers

Then to create an operation in a class, you have to add a binding in the
class to rely the operation, and to describe the operation creation.
Here is an example :


rule Class {
from
ic : MOF!EClass
to
oc : MOF!EClass (
name <- ic.name + 'DAImpl'
)
}
operations <- Sequence{getAllOperation}

and then in the same rule

rule Operation {
from
io : MOF!EOperation
to
oo : MOF!EOperation (
name <- io.name,
parameters <- io.eParameters,
type <- io.eType
)
}

Nicolas Toublanc a
Re: [ATL] ecore to ecore transformation [message #63942 is a reply to message #63920] Fri, 12 October 2007 14:51 Go to previous message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060402080805000202060001
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sorry, I encountered a bug and didn't finish my answer...
:-)

So I wanted to describe the class rule which adds an operation to the
class element :

rule Class {
from
ic : MOF!EClass
to
oc : MOF!EClass (
name <- ic.name + 'DAImpl',
operations <- Sequence{getAllOperation}
),
getAllOperation : MOF!EOperation (
name <- 'getAll'
....
etc...
)
}


Regards

--------------060402080805000202060001
Content-Type: text/x-vcard; charset=utf-8;
name="william.piers.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="william.piers.vcf"

begin:vcard
fn:William Piers
n:Piers;William
org:Obeo
adr:2 rue Robert Schumann;;lot 24;NANTES;;44408;France
email;internet:william.piers@obeo.fr
title:MDA Consultant
tel;work:+33 (0)2 51 13 51 82
tel;cell:+33 (0)6 20 31 75 98
url:http://www.obeo.fr
version:2.1
end:vcard


--------------060402080805000202060001--
Previous Topic:[QVTOM] Mapping calls in strict mode
Next Topic:antlr/TokenStream error
Goto Forum:
  


Current Time: Wed Apr 14 18:19:18 GMT 2021

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

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

Back to the top