Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Filtering target elements based on global variable
[ATL] Filtering target elements based on global variable [message #87225] Thu, 31 July 2008 10:54 Go to next message
Eclipse UserFriend
Originally posted by: xxx.tull.no

I use ATL to do a model refactoring from and to UML2 activity models.

I need to set global variables which then should limit the remaining
target elements to be produced. The global variable "applied" is set
correctly as I have tested this by assigning it to some target attribute
value.

However, it does not seem to work when I try to make filter conditions on
target elements based on this global variable.

In my simplified example I have the global variable "applied" which is set
to 'true' (initially it is 'false') in the CallOperationAction rule.
Afterwards when I produce control flow edges I want to ensure that the
'applied' variable has been set, by adding (thisModule.applied) to the
condition of the ControlFlow rule. The problem is that it always refers to
the initial value!??
Due to this, no control flow edges are produced in the attached example,
while I expected all of them to be produced.

How do I solve this the right way?

(Don't bother that the example in its simplified version does not make
sense, but I do not a way to do this in the full scale example)

=== ATL source code ====

-- @atlcompiler atl2006
module RemGoto; -- Module Template

create OUT : UML2 from IN : UML2;

helper def : applied : Boolean = false; -- to ensure that T2 is only
applied once.

rule Package {
from INPack : UML2 ! Package
to OUTPack : UML2 ! Package (
packagedElement <- Set{ UML2!Activity.allInstances()}
)
}

rule Activity {
from INAct : UML2 ! Activity
to OUTAct : UML2 ! Activity (
name <- INAct.name,
node <- Set{UML2 ! CallOperationAction.allInstances()},
edge <- Set{UML2 ! ControlFlow.allInstances()}
)
}

rule CallOperationAction {
from succ : UML2 ! CallOperationAction
to pre: UML2 ! CallOperationAction (
name <- succ.name
)
do { thisModule.applied <- true;
}
}

-- All control flow excluding all that involved the succ node.
rule ControlFlow {
from inCF : UML2 ! ControlFlow (thisModule.applied)
to outCF: UML2 ! ControlFlow (
source <- inCF.source,
target <- thisModule.succ, --inCF.target,
guard <- if (inCF.guard->oclIsUndefined()) then inCF.guard else
thisModule.LiteralString(inCF.guard) endif
)
}

lazy rule LiteralString {
from inGuard : UML2 ! LiteralString
to outGuard : UML2 ! LiteralString (
value <- inGuard.value
)
}
Re: [ATL] Filtering target elements based on global variable [message #87515 is a reply to message #87225] Wed, 06 August 2008 11:43 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

Answer below :

Roy Grønmo a écrit :
> I use ATL to do a model refactoring from and to UML2 activity models.
> I need to set global variables which then should limit the remaining
> target elements to be produced. The global variable "applied" is set
> correctly as I have tested this by assigning it to some target attribute
> value.
>
> However, it does not seem to work when I try to make filter conditions
> on target elements based on this global variable.
> In my simplified example I have the global variable "applied" which is
> set to 'true' (initially it is 'false') in the CallOperationAction rule.
> Afterwards
*snip*

The rules execution order is independant of the order they are written,
so you can't status on what has been executed or not.
To apply a rule only once, you can use an unique lazy rule (unique lazy
rule RULE_NAME {...} ).

Best regards,

William

when I produce control flow edges I want to ensure that the
> 'applied' variable has been set, by adding (thisModule.applied) to the
> condition of the ControlFlow rule. The problem is that it always refers
> to the initial value!??
> Due to this, no control flow edges are produced in the attached example,
> while I expected all of them to be produced.
>
> How do I solve this the right way?
>
> (Don't bother that the example in its simplified version does not make
> sense, but I do not a way to do this in the full scale example)
>
> === ATL source code ====
>
> -- @atlcompiler atl2006
> module RemGoto; -- Module Template
>
> create OUT : UML2 from IN : UML2;
>
> helper def : applied : Boolean = false; -- to ensure that T2 is only
> applied once.
>
> rule Package {
> from INPack : UML2 ! Package
> to OUTPack : UML2 ! Package (
> packagedElement <- Set{ UML2!Activity.allInstances()}
> )
> }
>
> rule Activity {
> from INAct : UML2 ! Activity
> to OUTAct : UML2 ! Activity (
> name <- INAct.name,
> node <- Set{UML2 ! CallOperationAction.allInstances()},
> edge <- Set{UML2 ! ControlFlow.allInstances()}
> )
> }
>
> rule CallOperationAction {
> from succ : UML2 ! CallOperationAction
> to pre: UML2 ! CallOperationAction (
> name <- succ.name
> )
> do { thisModule.applied <- true; }
> }
>
> -- All control flow excluding all that involved the succ node.
> rule ControlFlow {
> from inCF : UML2 ! ControlFlow (thisModule.applied) to
> outCF: UML2 ! ControlFlow (
> source <- inCF.source,
> target <- thisModule.succ, --inCF.target,
> guard <- if (inCF.guard->oclIsUndefined()) then inCF.guard
> else thisModule.LiteralString(inCF.guard) endif
> )
> }
>
> lazy rule LiteralString {
> from inGuard : UML2 ! LiteralString
> to outGuard : UML2 ! LiteralString (
> value <- inGuard.value
> )
> }
>
Re: [ATL] Filtering target elements based on global variable [message #87667 is a reply to message #87515] Thu, 07 August 2008 04:18 Go to previous message
Eclipse UserFriend
Originally posted by: xxx.tull.no

Thanks a lot William.

My transformation now works fine, when I use lazy rules in the appropriate
places.
Previous Topic:emof:Package
Next Topic:[ATL] NullPointerException--ERROR
Goto Forum:
  


Current Time: Tue Jul 22 16:23:36 EDT 2025

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

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

Back to the top