Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]How to add a binding in if-else statement
[ATL]How to add a binding in if-else statement [message #481783] Mon, 24 August 2009 09:58 Go to next message
Eclipse UserFriend
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
William Piers is currently offline William PiersFriend
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
>
Previous Topic:[QVTO] Help with syntax for assigning values to attributes defined as a certain datatype.
Next Topic:[ATL] OrderedSet.indexOf operation not found
Goto Forum:
  


Current Time: Tue Jan 14 00:47:39 GMT 2025

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

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

Back to the top