Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] called rules
[ATL] called rules [message #89471] Mon, 01 September 2008 04:09 Go to next message
Eclipse UserFriend
Hello, I have a problem so if somebody could help me it will be very nice.
I have to do the transformation SYSML -> UML.

You can see a part of my code:

module sysml2uml; -- Module Template
create OUT : UML from IN : SYSML;

rule namedElement(type_name : String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name) {
do{
targetVariable.name <- sourceVariable.name;
targetVariable.visibility <- sourceVariable.visibility;
targetVariable.clientDependency <- sourceVariable.clientDependency;
--targetVariable.qualifiedName <- sourceVariable.qualifiedName;
--targetVariable.namespace <- sourceVariable.namespace;
}
}

rule nameSpace(type_name : String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name){
do{
targetVariable.elementImport <- sourceVariable.elementImport;
targetVariable.ownedRule <- sourceVariable.ownedRule;
targetVariable.packageImport <- sourceVariable.packageImport;
--targetVariable.importedMember <-sourceVariable.importedMember;
--targetVariable.member <- sourceVariable.member;
--targetVariable.ownedMember <- sourceVariable.ownedMember;
}
}

rule element(type_name : String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name){
do{
targetVariable.ownedComment <- sourceVariable.ownedComment;
--targetVariable.ownedElement <- sourceVariable.ownedElement;
--targetVariable.owner <- sourceVariable.owner;
}
}

rule packageableElement (type_name : String, sourceVariable :
SYSML!type_name, targetVariable : UML!type_name){
do{
targetVariable.visibility <- sourceVariable.visibility;
}
}

rule model extends package{
from package : SYSML!Model (package.oclIsTypeOf(SYSML!Model))
to paquetage : UML!Model( -- Model
viewpoint <- package.viewpoint
)
do{ -- Model -> Package
-- Package -> Namespace
thisModule.nameSpace('Model',package,paquetage);
-- Package -> PackageableElement
thisModule.packageableElement('Model',package,paquetage);
-- Namespace,PackageableElement -> NamedElement
thisModule.namedElement('Model',package,paquetage);
-- NamedElement -> Element
thisModule.element('Model',package,paquetage);
}
}

rule package{
from package : SYSML!Package
to paquetage : UML!Package ( -- Package
packageMerge <- package.packageMerge,
nestingPackage <- package.nestingPackage,
packagedElement <- package.packagedElement
--ownedComment <- package.ownedComment
--nestedPackage <- package.nestedPackage
--paquetage.ownedType <- package.ownedType
)
do {
thisModule.nameSpace('Package',package,paquetage);
-- Package -> PackageableElement
thisModule.packageableElement('Package',package,paquetage);
-- Namespace,PackageableElement -> NamedElement
thisModule.namedElement('Package',package,paquetage);
-- NamedElement -> Element
thisModule.element('Package',package,paquetage);
'salu'.toString().println();
}
}

rule comment{
from comment : SYSML!Comment
to commentaire : UML!Comment ( -- Comment
body <- comment.body,
annotatedElement <- comment.annotatedElement
)
do {
-- Comment -> Element
thisModule.element('Comment',comment,commentaire);
}
}

I enter a SYSML diagram which contains this hierarch:

- <Model> diagSysML
- <Package> diagSysML
- <Comment> Comment1

After the transformation, I obtain a UML diagram which contains this
hierarch:

- <Comment> Comment1
- <Model> diagSysML
- <Package> diagSysML

but I want to obtain the same hierarch:

- <Model> diagSysML
- <Package> diagSysML
- <Comment> Comment1

It means that the called rule element doesn't run:

rule element(type_name : String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name){
do{
targetVariable.ownedComment <- sourceVariable.ownedComment;
--targetVariable.ownedElement <- sourceVariable.ownedElement;
--targetVariable.owner <- sourceVariable.owner;
}
}

Do you know why?

Thank you very much if you help me.

Monica.
Re: [ATL] called rules [message #89489 is a reply to message #89471] Mon, 01 September 2008 07:09 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

The rule runs, but you don;t store it's result in package. try something
like this:
package.ownedComment <- thisModule.element('Package',package,paquetage);


Regards,

Alfons


"Monica Clement" <monica.clement@gmail.com> schreef in bericht
news:dbec6d3c9ab3958aa5fa8f0b677da382$1@www.eclipse.org...
> Hello, I have a problem so if somebody could help me it will be very nice.
> I have to do the transformation SYSML -> UML.
>
> You can see a part of my code:
> module sysml2uml; -- Module Template
> create OUT : UML from IN : SYSML;
> rule namedElement(type_name : String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name) {
> do{
> targetVariable.name <- sourceVariable.name;
> targetVariable.visibility <- sourceVariable.visibility;
> targetVariable.clientDependency <- sourceVariable.clientDependency;
> --targetVariable.qualifiedName <- sourceVariable.qualifiedName;
> --targetVariable.namespace <- sourceVariable.namespace;
> }
> }
>
> rule nameSpace(type_name : String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name){
> do{
> targetVariable.elementImport <- sourceVariable.elementImport;
> targetVariable.ownedRule <- sourceVariable.ownedRule;
> targetVariable.packageImport <- sourceVariable.packageImport;
> --targetVariable.importedMember <-sourceVariable.importedMember;
> --targetVariable.member <-
> sourceVariable.member; --targetVariable.ownedMember <-
> sourceVariable.ownedMember; }
> }
>
> rule element(type_name : String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name){
> do{
> targetVariable.ownedComment <- sourceVariable.ownedComment;
> --targetVariable.ownedElement <- sourceVariable.ownedElement;
> --targetVariable.owner <- sourceVariable.owner; }
> }
>
> rule packageableElement (type_name : String, sourceVariable :
> SYSML!type_name, targetVariable : UML!type_name){
> do{
> targetVariable.visibility <- sourceVariable.visibility;
> }
> }
>
> rule model extends package{
> from package : SYSML!Model (package.oclIsTypeOf(SYSML!Model))
> to paquetage : UML!Model( -- Model
> viewpoint <- package.viewpoint
> )
> do{ -- Model -> Package
> -- Package -> Namespace
> thisModule.nameSpace('Model',package,paquetage); -- Package ->
> PackageableElement
> thisModule.packageableElement('Model',package,paquetage); --
> Namespace,PackageableElement -> NamedElement
> thisModule.namedElement('Model',package,paquetage); -- NamedElement ->
> Element
> thisModule.element('Model',package,paquetage); }
> }
>
> rule package{
> from package : SYSML!Package to paquetage : UML!Package ( -- Package
> packageMerge <- package.packageMerge,
> nestingPackage <- package.nestingPackage,
> packagedElement <- package.packagedElement
> --ownedComment <- package.ownedComment
> --nestedPackage <- package.nestedPackage
> --paquetage.ownedType <- package.ownedType
> )
> do { thisModule.nameSpace('Package',package,paquetage); -- Package ->
> PackageableElement
> thisModule.packageableElement('Package',package,paquetage);
> -- Namespace,PackageableElement -> NamedElement
> thisModule.namedElement('Package',package,paquetage); -- NamedElement ->
> Element
> thisModule.element('Package',package,paquetage);
> 'salu'.toString().println(); }
> }
>
> rule comment{ from comment : SYSML!Comment to commentaire : UML!Comment
> ( -- Comment
> body <- comment.body, annotatedElement <-
> comment.annotatedElement
> )
> do {
> -- Comment -> Element
> thisModule.element('Comment',comment,commentaire);
> }
> } I enter a SYSML diagram which contains this hierarch:
>
> - <Model> diagSysML
> - <Package> diagSysML
> - <Comment> Comment1
> After the transformation, I obtain a UML diagram which contains this
> hierarch:
>
> - <Comment> Comment1
> - <Model> diagSysML
> - <Package> diagSysML
>
> but I want to obtain the same hierarch:
>
> - <Model> diagSysML
> - <Package> diagSysML
> - <Comment> Comment1
>
> It means that the called rule element doesn't run:
>
> rule element(type_name : String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name){
> do{
> targetVariable.ownedComment <- sourceVariable.ownedComment;
> --targetVariable.ownedElement <- sourceVariable.ownedElement;
> --targetVariable.owner <- sourceVariable.owner; }
> }
>
> Do you know why?
>
> Thank you very much if you help me.
>
> Monica.
>
>
>
>
>
>
Re: [ATL] called rules [message #89504 is a reply to message #89489] Mon, 01 September 2008 07:44 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your response Alfons.

However, I store the result :

rule element(type_name : String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name){
do{
targetVariable.ownedComment <- sourceVariable.ownedComment;
--targetVariable.ownedElement <- sourceVariable.ownedElement;
--targetVariable.owner <- sourceVariable.owner;
}
}

My others called rules run, I have a problem only with element...

Monica.
Re: [ATL] called rules [message #89550 is a reply to message #89504] Mon, 01 September 2008 10:21 Go to previous messageGo to next message
Eclipse UserFriend
Monica,
I'm not 100 sure, but ATL executes transformations in two steps; one create
targetmodel elements and two create their properties. This makes it in most
cases difficult to navigate elements of the target model. I would advice you
to look for another solution. Why do you use called rules in this fashion,
can't you create normal rules fopr each model element in this case? That way
you leave the execution order to the VM, which can do this in a nice manner,
given that there are not too many conflicting imperative operation in the
transformation.


Regards,

Alfons

PS
Whats wrong with this?
-- @atlcompiler atl2006
module sysml2uml; -- Module Template
create OUT : UML from IN : SYSML;

rule package{
from package : SYSML!Package
to paquetage : UML!Package ( -- Package
packageMerge <- package.packageMerge,
nestingPackage <- package.nestingPackage,
packagedElement <- package.packagedElement

ownedComment <- package.ownedComment;
)
}

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


"Monica Clement" <monica.clement@gmail.com> schreef in bericht
news:10485d0ac30ed8a3bd31f93fc828820f$1@www.eclipse.org...
> Thank you for your response Alfons.
>
> However, I store the result :
>
> rule element(type_name : String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name){
> do{
> targetVariable.ownedComment <- sourceVariable.ownedComment;
> --targetVariable.ownedElement <- sourceVariable.ownedElement;
> --targetVariable.owner <- sourceVariable.owner; }
> }
> My others called rules run, I have a problem only with element...
>
> Monica.
>
Re: [ATL] called rules [message #89565 is a reply to message #89550] Mon, 01 September 2008 12:40 Go to previous messageGo to next message
Eclipse UserFriend
Firstly, thank you very much for your help Alfons. It is very nice.

I agree with you when you said I should write a rule for every metaclasse.
I already began but it is very very long. I have to write a lot of rule in
order to do my transformation SYSML -> UML. The common part between SYSML
and UML is very vast, so I have to write a lot of rules.

It is for this reason I tried to optimize the code.

I used "called rule" because I can't write a rule for an abstract
metaclass (I get an error).

I need to write the same attributes in a lot of rules, so I research a
mean to evoid it...

Do you know how to use "refining"? Maybe it would help me. I don't
understand the documentation.

Thank you Alfons,

Monica.
Re: [ATL] called rules [message #89579 is a reply to message #89565] Mon, 01 September 2008 20:21 Go to previous messageGo to next message
Eclipse UserFriend
What you describe is rule inheritance. William explained it to you in the
other thread, why don't you use that?


Kind regards,

Alfons

"Monica Clement" <monica.clement@gmail.com> schreef in bericht
news:85ac01672d2184664fd07671d9fe223f$1@www.eclipse.org...
> Firstly, thank you very much for your help Alfons. It is very nice.
> I agree with you when you said I should write a rule for every metaclasse.
> I already began but it is very very long. I have to write a lot of rule in
> order to do my transformation SYSML -> UML. The common part between SYSML
> and UML is very vast, so I have to write a lot of rules.
>
> It is for this reason I tried to optimize the code.
> I used "called rule" because I can't write a rule for an abstract
> metaclass (I get an error).
> I need to write the same attributes in a lot of rules, so I research a
> mean to evoid it...
>
> Do you know how to use "refining"? Maybe it would help me. I don't
> understand the documentation.
> Thank you Alfons,
>
> Monica.
>
Re: [ATL] called rules [message #89661 is a reply to message #89579] Tue, 02 September 2008 09:00 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alfons, thank you again for your response. When I tried to write a
rule for an abstract metaclass:

rule namedElement{
from namedElement:SYSML!NamedElement
to nommeElement:UML!NamedElement (
name <- namedElement.name,
visibility <- namedElement.visibility,
clientDependency <- namedElement.clientDependency)
}

I get this error: GRAVE: The class 'NamedElement' is not a valid classifier

It is the reason why I use "called rule":

rule namedElement(type_name :String, sourceVariable : SYSML!type_name,
targetVariable : UML!type_name) {
do{
targetVariable.name <- sourceVariable.name;
targetVariable.visibility <- sourceVariable.visibility;
targetVariable.clientDependency <-sourceVariable.clientDependency;
--targetVariable.qualifiedName <- sourceVariable.qualifiedName;
--targetVariable.namespace <- sourceVariable.namespace;
}
}

Monica
Re: [ATL] called rules [message #89669 is a reply to message #89661] Tue, 02 September 2008 09:21 Go to previous messageGo to next message
Eclipse UserFriend
-- @atlcompiler atl2006


Alfons

"Monica Clement" <monica.clement@gmail.com> schreef in bericht
news:7174af66eca6990b869ba6e695398500$1@www.eclipse.org...
> Hello Alfons, thank you again for your response. When I tried to write a
> rule for an abstract metaclass:
>
> rule namedElement{
> from namedElement:SYSML!NamedElement
> to nommeElement:UML!NamedElement ( name <- namedElement.name,
> visibility <- namedElement.visibility,
> clientDependency <- namedElement.clientDependency)
> }
>
> I get this error: GRAVE: The class 'NamedElement' is not a valid
> classifier
>
> It is the reason why I use "called rule":
>
> rule namedElement(type_name :String, sourceVariable : SYSML!type_name,
> targetVariable : UML!type_name) {
> do{
> targetVariable.name <- sourceVariable.name;
> targetVariable.visibility <- sourceVariable.visibility;
> targetVariable.clientDependency <-sourceVariable.clientDependency;
> --targetVariable.qualifiedName <- sourceVariable.qualifiedName;
> --targetVariable.namespace <- sourceVariable.namespace;
> }
> }
>
> Monica
>
Re: [ATL] called rules [message #89681 is a reply to message #89669] Tue, 02 September 2008 09:45 Go to previous message
Eclipse UserFriend
I already write -- @atlcompiler atl2006, so it is not the problem.

Thanks.

Monica.
Previous Topic:[ATL]Leaf metaclass donŽt run in rule
Next Topic:[ATL] How to define an ATL library file
Goto Forum:
  


Current Time: Thu May 08 08:47:34 EDT 2025

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

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

Back to the top