Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] three basic problems about ATL transfromer
[ATL] three basic problems about ATL transfromer [message #82266] Mon, 26 May 2008 23:41 Go to next message
Eclipse UserFriend
Originally posted by: ZhuangGuotao.hotmail.com

Dear all,

I am a beginner at ATL Programming. Now I meet three problems which are
not sloved by myself. I expect help to solve these. Thanks a lot.

For describing my problems, I firstly makes two very simple MetaModel.
These structures are following:

MMA( MetaModel A)

RootA( The root element of MetaModel A) (Element number bound: 1)
„¥ EAA( Element A of MetaModel A) (Element number bound: 0..*)
„€ EAB( Element B of MetaModel A) (Element number bound: 1..*)

MMA ( MetaModel B)

RootB( The root element of MetaModel B) (Element number bound: 1)
„¥ EBA( Element A of MetaModel B) (Element number bound: 0..1)
„¥ EBB( Element B of MetaModel B) (Element number bound: 1..*)
„¥ EBC( Element C of MetaModel B) (Element number bound: 0..*)
„€ EBD( Element D of MetaModel B) (Element number bound: 1)


I plan to transfer MMA to MMB. The rules are following:

EAA ---> EBA
EAB ---> EBB
EAB ---> EBC
EBD is a new element.

The three problems are following:

1. How to write this rule which is about transfering EAA to EBA. if the
EAA exists, then generates one EBA, otherwise doesn't generate EBA.

2. The EBB and EBC are generated by EAB. In this MetaModel B, the EBB and
EBC are all contained by RootB, In fact, EBB and EBC maybe be contained by
different complex element.

So the general way maybe not suit for this case. The general way likes as
following:

rule EAB2EBBC {
from
ab : MMA!EAB
to
bb : MMB!EBB (
....
),
bc : MMB!EBC (
....
)
}

In the practice case, the EBB and EBC maybe be contained by different
complex element. I need this distributed way to transfer element:

rule EAB2EBB {
from
ab : MMA!EAB
to
bb : MMB!EBB (
....
)
}

rule EAB2EBC {
from
ab : MMA!EAB
to
bb : MMB!EBC (
....
)
}

If I use this distributed way in my transformer, the transformer will be
not correct. But I looked a example which is Class2Relational(
http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational[v00.01].pdf).

In the Class2Relational, the Class!Attribute generate several target
elements by this distributed way.

rule SingleValuedDataTypeAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!DataType) and not a.multiValued
)
to
out : Relational!Column (
name <- a.name,
type <- a.type
-- explicit use of implicit tracking links
-- (first expected syntax, then present actual syntax)
-- owner <- [Class2Type.key]a.owner
-- owner <- thisModule.resolveTemp(a.owner, 'key')
)
}
rule MultiValuedDataTypeAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!DataType) and a.multiValued
)
to
out : Relational!Table (
name <- a.owner.name + '_' + a.name,
col <- Sequence {id, value}
),
id : Relational!Column (
name <- a.owner.name.firstToLower() + 'Id',
type <- thisModule.objectIdType
),
value : Relational!Column (
name <- a.name,
type <- a.type
)
}
rule ClassAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!Class) and not a.multiValued
)
to
out : Relational!Column (
name <- a.name + 'Id',
type <- thisModule.objectIdType
)
}



3. How to write this rule which is reference to EBD which is generated by
a called rule.

if the called rule likes this :

rule genEBD() {
to
bd : MMB!EBD (
....
)
}

I try the follow way, but failed.

EBD <- thisModule.genEBD()
Re: [ATL] three basic problems about ATL transfromer [message #82413 is a reply to message #82266] Tue, 27 May 2008 22:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: freddy.allilaire.univ-nantes.fr

This is a multi-part message in MIME format.
--------------070502050203020802080903
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

Comments below,

Zhuang Guotao a écrit :
> Dear all,
>
> I am a beginner at ATL Programming. Now I meet three problems which are
> not sloved by myself. I expect help to solve these. Thanks a lot.
>
> For describing my problems, I firstly makes two very simple MetaModel.
> These structures are following:
>
> MMA( MetaModel A)
>
> RootA( The root element of MetaModel A) (Element number bound: 1)
> �¥ EAA( Element A of MetaModel A) (Element number bound: 0..*)
> �€ EAB( Element B of MetaModel A) (Element number bound: 1..*)
>
> MMA ( MetaModel B)
>
> RootB( The root element of MetaModel B) (Element number bound: 1)
> �¥ EBA( Element A of MetaModel B) (Element number bound: 0..1)
> �¥ EBB( Element B of MetaModel B) (Element number bound: 1..*)
> �¥ EBC( Element C of MetaModel B) (Element number bound: 0..*)
> �€ EBD( Element D of MetaModel B) (Element number bound: 1)
>
>
> I plan to transfer MMA to MMB. The rules are following:
> EAA ---> EBA
> EAB ---> EBB
> EAB ---> EBC
> EBD is a new element.
>
> The three problems are following:
>
> 1. How to write this rule which is about transfering EAA to EBA. if the
> EAA exists, then generates one EBA, otherwise doesn't generate EBA.

With the following rule, if your source model doesn't contain EAA
element, no EBA element will be created in your target model:

rule EAA2EBA {
from
ab : MMA!EAA
to
bb : MMB!EBA (
....
)
}

>
> 2. The EBB and EBC are generated by EAB. In this MetaModel B, the EBB
> and EBC are all contained by RootB, In fact, EBB and EBC maybe be
> contained by different complex element.
>
> So the general way maybe not suit for this case. The general way likes
> as following:
>
> rule EAB2EBBC {
> from
> ab : MMA!EAB
> to
> bb : MMB!EBB (
> ....
> ),
> bc : MMB!EBC (
> ....
> )
> }
>
> In the practice case, the EBB and EBC maybe be contained by different
> complex element. I need this distributed way to transfer element:
>
> rule EAB2EBB {
> from
> ab : MMA!EAB
> to
> bb : MMB!EBB (
> ....
> )
> }
>
> rule EAB2EBC {
> from
> ab : MMA!EAB
> to
> bb : MMB!EBC (
> ....
> )
> }
>

You could not write this in ATL. The same source model element could not
be matched by several rules.

You may write something like this:
rule EAB2EBBC {
from
ab : MMA!EAB
to
bb : MMB!EBB (
....
),
bc : MMB!EBC (
....
)
}

The "containment problem" should be manage at container level thanks to
ATL Resolve Algorithm (section 6 of
http://www.eclipse.org/m2m/atl/basicExamples_Patterns/articl e.php?file=Tree2List/index.html
for more details).
For example,

rule RootA2RootB {
from
rootA : MMA!RootA
to
rootB : MMB!RootB (
ebbList <- rootA.eabList,
ebcList <- rootA.eabList
)
}

If your use case is more complex, you may need to use a resolveTemp().

> If I use this distributed way in my transformer, the transformer will be
> not correct. But I looked a example which is Class2Relational(
> http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational[v00.01].pdf).
>
>
> In the Class2Relational, the Class!Attribute generate several target
> elements by this distributed way.
>
> rule SingleValuedDataTypeAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!DataType) and not a.multiValued
> )
> to
> out : Relational!Column (
> name <- a.name,
> type <- a.type
> -- explicit use of implicit tracking links
> -- (first expected syntax, then present actual syntax)
> -- owner <- [Class2Type.key]a.owner
> -- owner <- thisModule.resolveTemp(a.owner, 'key')
> )
> }
> rule MultiValuedDataTypeAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!DataType) and a.multiValued
> )
> to
> out : Relational!Table (
> name <- a.owner.name + '_' + a.name,
> col <- Sequence {id, value}
> ),
> id : Relational!Column (
> name <- a.owner.name.firstToLower() + 'Id',
> type <- thisModule.objectIdType
> ),
> value : Relational!Column (
> name <- a.name,
> type <- a.type
> )
> }
> rule ClassAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!Class) and not a.multiValued
> )
> to
> out : Relational!Column (
> name <- a.name + 'Id',
> type <- thisModule.objectIdType
> )
> }
>
>
>
> 3. How to write this rule which is reference to EBD which is generated
> by a called rule.
>
> if the called rule likes this :
>
> rule genEBD() {
> to
> bd : MMB!EBD (
> ....
> )
> }
>

I'm not sure you need to use a called rule in your case.
Maybe you can do something like this:

rule RootA2RootB {
from
rootA : MMA!RootA
to
rootB : MMB!RootB (
....
ebd <- bd
),
bd : MMB!EBD (
....
)
}

> I try the follow way, but failed.
>
> EBD <- thisModule.genEBD()
>

Regards,
Freddy
OBEO

--------------070502050203020802080903
Content-Type: text/x-vcard; charset=utf-8;
name="freddy.allilaire.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="freddy.allilaire.vcf"

YmVnaW46dmNhcmQNCmZuOkZyZWRkeSBBbGxpbGFpcmUNCm46QWxsaWxhaXJl O0ZyZWRkeQ0K
b3JnOk9CRU8NCmFkcjo7OztOYW50ZXM7OzQ0NDAwO0ZyYW5jZQ0KZW1haWw7 aW50ZXJuZXQ6
ZnJlZGR5LmFsbGlsYWlyZUBvYmVvLmZyDQp0aXRsZTpSJkQgRW5naW5lZXIN CnVybDpodHRw
Oi8vd3d3Lm9iZW8uZnINCnZlcnNpb246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------070502050203020802080903--
Re: [ATL] three basic problems about ATL transfromer [message #82459 is a reply to message #82413] Wed, 28 May 2008 09:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ZhuangGuotao.hotmail.com

Dear Freddy,

I am very happy for rapid reply. But I am sorry that some answers are not
answers which I want.

1. The MMB only contains one EBA element. so your rule solution is not
suitable.

2. To the second problem, I really want to ask how to repeatly use one
source element in "from" part of many different rules, which likes some
syntax in the Class2Relational example(
http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational[v00.01].pdf).

rule SingleValuedDataTypeAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!DataType) and not a.multiValued
)
to
out : Relational!Column (
name <- a.name,
type <- a.type
-- explicit use of implicit tracking links
-- (first expected syntax, then present actual syntax)
-- owner <- [Class2Type.key]a.owner
-- owner <- thisModule.resolveTemp(a.owner, 'key')
)
}
rule MultiValuedDataTypeAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!DataType) and a.multiValued
)
to
out : Relational!Table (
name <- a.owner.name + '_' + a.name,
col <- Sequence {id, value}
),
id : Relational!Column (
name <- a.owner.name.firstToLower() + 'Id',
type <- thisModule.objectIdType
),
value : Relational!Column (
name <- a.name,
type <- a.type
)
}
rule ClassAttribute2Column {
from
a : Class!Attribute (
a.type.oclIsKindOf(Class!Class) and not a.multiValued
)
to
out : Relational!Column (
name <- a.name + 'Id',
type <- thisModule.objectIdType
)
}

To pay attention to the "from" part. These three rules all use the same
one source element which is "Class!Attribute" in the "from" part. I also
need write the simular syntax in my transformer for making my rules more
clear. I write like the following, but it did not work. I want to ask the
reason, and the correct way how to write this type rule.

rule EAB2EBB {
from
ab : MMA!EAB
to
bb : MMB!EBB (
....
)
}

rule EAB2EBC {
from
ab : MMA!EAB
to
bb : MMB!EBC (
....
)
}


3. I have used the same solution as your suggestion. But I have looked
some examples. The element can reference the subelement which is generated
by called rule, which like the following syntax:

rule ruleName {
from
....
to
e : MMB!RootB (
....
,
EBD <- thisModule.genEBD()
)
}

rule genEBD() {
to
bd : MMB!EBD (
....
)
}


But it can not work in my project. I want to ask why my way is not
correct, and how to correctly reference the subelement which is generated
by called rule

Thanks a lot.

If other experts know the answer, pls tell me. I really expect to solve
these problems.

Best regards

Zhuang Guotao
Re: [ATL] three basic problems about ATL transfromer [message #82615 is a reply to message #82459] Wed, 28 May 2008 15:29 Go to previous messageGo to next message
urs zeidler is currently offline urs zeidlerFriend
Messages: 91
Registered: July 2009
Member
>
> rule SingleValuedDataTypeAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!DataType) and not a.multiValued
> )
1. maps if type is a Class!DataType and if it is not multiValued


> rule MultiValuedDataTypeAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!DataType) and a.multiValued
> )
2. maps if type is a Class!DataType and if it is multiValued


> rule ClassAttribute2Column {
> from
> a : Class!Attribute (
> a.type.oclIsKindOf(Class!Class) and not a.multiValued
> )
3. maps if type is a Class!Class and if it is not multiValued

so all rules match to other elements, thats what the guardians are for.
Re: [ATL] three basic problems about ATL transfromer [message #82721 is a reply to message #82615] Thu, 29 May 2008 21:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ZhuangGuotao.hotmail.com

Dear urs zeidler,

Thanks a lot for your reply.

I think the Class!Attribute which is in the "from" part is a Data Type. I
don't know if it can be repeatly used ?

According to your descibing, the source element only can be used on time
in the "from" part of the rule? Can you tell me where can I find this
reference from the ATL user guide? Thanks a lot.

Expect the solution about these three question.

Best regards.

Zhuang Guotao
Re: [ATL] three basic problems about ATL transfromer [message #82790 is a reply to message #82721] Thu, 29 May 2008 23:48 Go to previous message
Eclipse UserFriend
Originally posted by: me.urszeidler.de

Zhuang Guotao wrote:
> Dear urs zeidler,
>
> Thanks a lot for your reply.
>
> I think the Class!Attribute which is in the "from" part is a Data Type.
> I don't know if it can be repeatly used ?
>
> According to your descibing, the source element only can be used on time
> in the "from" part of the rule? Can you tell me where can I find this
> reference from the ATL user guide? Thanks a lot.
>
> Expect the solution about these three question.
> Best regards.
>
> Zhuang Guotao
>
Each rule transforms a type T1 of the input meta model MM1 (from MM1!T1)
to a type T2 of the output meta model MM2 (to MM2!T2). A set of rules
(the transformation) is applied to a model M1 which conforms to MM1.
This means for each instance of M1 a rule responsible for the type will
be applied if the guardian matches. So you could have several rules for
an input type distinguished by the guard expression.
You transform instance of types, not the types itself.
Take a look at the manual.

greetings urs.
Previous Topic:[ATL] Launch a transformation programmaticaly with the EMF VM
Next Topic:[ATL] problem with UML and GMF
Goto Forum:
  


Current Time: Fri Apr 26 06:34:15 GMT 2024

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

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

Back to the top