[ATL]How to add a binding in if-else statement [message #481783] |
Mon, 24 August 2009 09:58 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: crajiz3rc.gmail.com
Hi All,
I have the following grammar rule.
module UMLToCLASS; -- Module Template
create OUT : CLASS from IN : UML;
helper context UML!Participant def: getName(): Set(String) =
self.bind->collect(e|e.name).asSet();
rule ParticipantToComponent
{
from
p :UML!Participant
to
c :CLASS!Component(name<-p.name),
s :CLASS!Service(provide<-prList),
prList:distinct DS!Tprovide foreach(prName in p.getName())
(name<-prName)
-- if (not prList.isEmpty()) then
-- do
-- {
-- c.service<-s;
-- }
-- else
-- false
-- endif
}
I am transforming Participant to Component.
I would like to add the binding c.service<-s if prList isNotEmpty else i
should not add this binding. (Something similar to the commented lines,
however this code does not work because i dont know what the return value
should be. Can anyone please suggest how i can write this binding rule
here.
Thank you very much
Kind Regards
Rajalaxmi
|
|
|
Re: [ATL]How to add a binding in if-else statement [message #482463 is a reply to message #481783] |
Wed, 26 August 2009 16:15 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
William Piers![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=william.piers%40obeo.fr) Messages: 303 Registered: July 2009 |
Senior Member |
|
|
Hello,
You can try this solution (assuming that p.getName() returns a Sequence):
rule ParticipantToComponent {
from
p : UML!Participant
to
c : CLASS!Component (
name<-p.name,
service <- if (not p.getName().isEmpty())
then s
else OclUndefined
endif
),
s : CLASS!Service (
provide<-prList
),
prList :distinct DS!Tprovide foreach(prName in p.getName())(
name<-prName
)
}
Best regards,
William
Rajalaxmi a écrit :
> Hi All,
>
> I have the following grammar rule.
> module UMLToCLASS; -- Module Template
> create OUT : CLASS from IN : UML;
>
> helper context UML!Participant def: getName(): Set(String) =
> self.bind->collect(e|e.name).asSet();
> rule ParticipantToComponent
> {
> from p :UML!Participant
> to
> c :CLASS!Component(name<-p.name),
> s :CLASS!Service(provide<-prList),
> prList:distinct DS!Tprovide foreach(prName in p.getName())
> (name<-prName)
>
> -- if (not prList.isEmpty()) then
> -- do
> -- {
> -- c.service<-s;
> -- }
> -- else
> -- false
> -- endif
> }
>
>
> I am transforming Participant to Component.
> I would like to add the binding c.service<-s if prList isNotEmpty else i
> should not add this binding. (Something similar to the commented lines,
> however this code does not work because i dont know what the return
> value should be. Can anyone please suggest how i can write this binding
> rule here.
>
> Thank you very much
>
> Kind Regards
>
> Rajalaxmi
>
|
|
|
Powered by
FUDForum. Page generated in 0.03782 seconds