Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]
[ATL] [message #87500] Wed, 06 August 2008 14:48 Go to next message
Monica ClÃ?©ment is currently offline Monica ClÃ?©mentFriend
Messages: 14
Registered: July 2009
Junior Member
Hello, I am trying to translate metamodels : UML <-> SYSML. I use ATL. I
have some questions if somebody can help me!

1) translation SYSML -> UML
As SYSML reuse a lot of UML metaclasses,have I to write a rule for all
metaclasses?

ex:
rule comment {
from comment : SYSML!Comment
to commentaire : UML!Comment (body <- comment.body, annotatedElement <-
comment.annotatedElement)
}

Is there a mean more simple?

2) In ATL, can we found something which permit to get back the name of the
target metamodel from the name of the source metamodel?

ex: can I obtain commentaire from comment? Can we found a primitive which
permit that?

Thank you very much if you help me.

Monica.
Re: [ATL] [message #87591 is a reply to message #87500] Wed, 06 August 2008 16:18 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

Clément Monica a écrit :
> Hello, I am trying to translate metamodels : UML <-> SYSML. I use ATL. I
> have some questions if somebody can help me!
>
> 1) translation SYSML -> UML
> As SYSML reuse a lot of UML metaclasses,have I to write a rule for all
> metaclasses?
>
> ex:
> rule comment {
> from comment : SYSML!Comment to commentaire : UML!Comment (body
> <- comment.body, annotatedElement <- comment.annotatedElement)
> }
> Is there a mean more simple?
>

I'm afraid not... perhaps somebody has any solution ?
What I may do in that case would be to generate the ATL file (i.e. for
each metaclass, write the corresponding rule).

> 2) In ATL, can we found something which permit to get back the name of
> the target metamodel from the name of the source metamodel?
> ex: can I obtain commentaire from comment? Can we found a primitive
> which permit that?
>

I'm not sure to understand, but you can use the resolveTemp() function
to retrieve a target element from its matching source element.

ex : if you add this to the rule comment
do{
thisModule.resolveTemp(comment, 'commentaire').debug('sourceElement');
}
it will display the source comment element. This exemple is a bit dummy,
but it becomes interesting when you have several elements in the "to"
section, and you want to retrieve one of them in any other rule.

Best regards,

William

> Thank you very much if you help me.
>
> Monica.
Re: [ATL] resolveTemp [message #87681 is a reply to message #87591] Thu, 07 August 2008 09:24 Go to previous messageGo to next message
Monica ClÃ?©ment is currently offline Monica ClÃ?©mentFriend
Messages: 14
Registered: July 2009
Junior Member
Hello, thank you very much for your response William.

About the question 2) :

You can see this example: (I am sorry for the indentation)

module testATL;
create OUT : UML from IN : SYSML;

rule package{
from package : SYSML!Package(package.oclIsTypeOf(SYSML!Package))
to paquetage : UML!Package(name <- package.name)
do {
for (p in package.packagedElement){
if (not p.oclIsUndefined()){
if(p.oclIsTypeOf(SYSML!Block))
paquetage.packagedElement<-thisModule.resolveTemp(p, 'classe' ) ;
if(p.oclIsTypeOf(SYSML!Actor))
paquetage.packagedElement<-thisModule.resolveTemp(p,'acteur' ) ;
if(p.oclIsTypeOf(SYSML!Package))
paquetage.packagedElement<-thisModule.resolveTemp(p, 'paquetage' ) ;
}
}

}
}


rule block {
from block : SYSML!Block
to classe : UML!Class(name <- block.name)
}

rule actor {
from actor : SYSML!Actor
to acteur : UML!Actor(name <- actor.name)
}

This solution runs, but my problem is that I need to use (if then else) in
order to found the name of the target metaclass in order to apply
resolveTemp.
Unfortunately, the Package metaclass can contain a lot of mataclasses...
So, I reseach a mean to retrieve the target element from the source
element ( find class from block, find acteur from actor). It would be
something like that:

rule package{
from package : SYSML!Package(package.oclIsTypeOf(SYSML!Package))
to paquetage : UML!Package(name <- package.name)
do {
for (p in package.packagedElement){
if (not p.oclIsUndefined()){
paquetage.packagedElement<-thisModule.resolveTemp(p, p.???? );
}
}
}
}

rule block {
from block : SYSML!Block
to classe : UML!Class(name <- block.name)
}

rule actor {
from actor : SYSML!Actor
to acteur : UML!Actor(name <- actor.name)
}

I want to eliminate all the uses of if then else.

I hope it is more clear.

Thank you for your help!

Monica.
Re: [ATL] resolveTemp [message #87696 is a reply to message #87681] Thu, 07 August 2008 10:06 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

Answers below :

Monica Clement a écrit :
> Hello, thank you very much for your response William.
> About the question 2) :
>
> You can see this example: (I am sorry for the indentation)
>
> module testATL; create OUT : UML from IN : SYSML;
>
> rule package{
> from package : SYSML!Package(package.oclIsTypeOf(SYSML!Package))
> to paquetage : UML!Package(name <- package.name)
> do {
> for (p in package.packagedElement){
> if (not p.oclIsUndefined()){
> if(p.oclIsTypeOf(SYSML!Block))
> paquetage.packagedElement<-thisModule.resolveTemp(p,
> 'classe' ) ;
> if(p.oclIsTypeOf(SYSML!Actor))
>
> paquetage.packagedElement<-thisModule.resolveTemp(p,'acteur' ) ;
> if(p.oclIsTypeOf(SYSML!Package))
> paquetage.packagedElement<-thisModule.resolveTemp(p,
> 'paquetage' ) ;
> }
> }
>
> }
> }
>

Here you don't need to use an imperative section : you can simply use
the implicit traceability mechanism of ATL, like :

rule package{
from package : SYSML!Package(package.oclIsTypeOf(SYSML!Package))
to paquetage : UML!Package(
name <- package.name,
packagedElement <- package.packagedElement
)
}

It will systematically take the first output element of the matching
rule, corresponding to a given packaged element.

>
> rule block {
> from block : SYSML!Block
> to classe : UML!Class(name <- block.name)
> }
>
> rule actor {
> from actor : SYSML!Actor
> to acteur : UML!Actor(name <- actor.name)
> }
>
> This solution runs, but my problem is that I need to use (if then else)
> in order to found the name of the target metaclass in order to apply
> resolveTemp.

ResolveTemp is only a precise way to access traceability links.

Best regards,

William

> Unfortunately, the Package metaclass can contain a lot of mataclasses...
> So, I reseach a mean to retrieve the target element from the source
> element ( find class from block, find acteur from actor). It would be
> something like that:
>
> rule package{
> from package : SYSML!Package(package.oclIsTypeOf(SYSML!Package))
> to paquetage : UML!Package(name <- package.name)
> do {
> for (p in package.packagedElement){
> if (not p.oclIsUndefined()){
> paquetage.packagedElement<-thisModule.resolveTemp(p, p.???? );
> }
> }
> }
> }
>
> rule block {
> from block : SYSML!Block
> to classe : UML!Class(name <- block.name)
> }
>
> rule actor {
> from actor : SYSML!Actor
> to acteur : UML!Actor(name <- actor.name)
> }
>
> I want to eliminate all the uses of if then else.
>
> I hope it is more clear.
>
> Thank you for your help!
> Monica.
>
Re: [ATL] resolveTemp [message #87902 is a reply to message #87696] Fri, 08 August 2008 11:57 Go to previous message
Monica ClÃ?©ment is currently offline Monica ClÃ?©mentFriend
Messages: 14
Registered: July 2009
Junior Member
It runs. Thank you very much for your help William.

Monica.
Previous Topic:[ATL] NullPointerException--ERROR
Next Topic:ATL: Problems working with BigInteger
Goto Forum:
  


Current Time: Fri Apr 26 03:11:23 GMT 2024

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

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

Back to the top