Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Lazy rules and multiple instantiations
[ATL] Lazy rules and multiple instantiations [message #560036] Mon, 20 September 2010 16:58 Go to next message
Eclipse UserFriend
Hello everybody,

can me anybody explain why lazy rules with multiple instantiations do not working?

I try someting like this (I tryed to do such things in some parts of my project, but the result is the same):


rule r1 {
from
a : A!Model
to
m: B!Pool ( packagedElement<-A!Class.allInstances()->collect(a | thisModule.r2(a))
)
}

unique lazy rule r2 {
from
a : A!Class
to
s: B!Data (),
t: B!Data (),
flow: B!SequenceFlow (
fSource<-s,
fTarget<-t
)
}

I get as Output such structure:
<model>
<data/>
</model>
<data/>
<sequenceFlow/>

How can I get such structure?:
<model>
<data/>
<data/>
<sequenceFlow/>
</model>

Is it possible at all? If yes, how? If not, why?

Thanks everybody for your answer.

Best regards,
Katja
Re: [ATL] Lazy rules and multiple instantiations [message #560077 is a reply to message #560036] Tue, 21 September 2010 03:05 Go to previous messageGo to next message
Eclipse UserFriend
Your lazy rule only returns the first element.
So when you call that rule (->collect(a | thisModule.r2(a))), this returns the Data aliased s and only that.
Still, the data t and the flow are created but not affected so are placed at the root of the resulting model.

To solve this you can either use a called rule to specify what it should return :
rule r2(a : A!Class){
	to
		s: B!Data (),
			t: B!Data (),
				flow: B!SequenceFlow (
					fSource<-s,
					fTarget<-t
				)
	do{
		--here you specify what the rule must return :
		Sequence{s,t,flow};
	}
}
You'll lose the "unique" behavior though.

You can also use three unique lazy rules instead of just one :
rule r1 {
	from
		a : A!Model
	to
		m: B!Pool ( 
			packagedElement<-A!Class.allInstances()
								->collect(a | 
									let dataS : B!Data = thisModule.dataS(a) in
									let dataT : B!Data = thisModule.dataT(a) in
									let flow : B!SequenceFlow = thisModule.flow(a,dataS,dataT) in
									Sequence{dataS,dataT,flow}
								)
		)
}

unique lazy rule dataS {
	from
		a : A!Class
	to
		s: B!Data ()
}

unique lazy rule dataT {
	from
		a : A!Class
	to
		t: B!Data ()
}

unique lazy rule flow {
	from
		a : A!Class, s : B!Data, t : B!Data
	to
		flow: B!SequenceFlow (
			fSource<-s,
			fTarget<-t
		)
}

[Updated on: Tue, 21 September 2010 03:07] by Moderator

Re: [ATL] Lazy rules and multiple instantiations [message #603728 is a reply to message #560077] Tue, 21 September 2010 15:28 Go to previous message
Eclipse UserFriend
Thank you, Sylvain, for a such detailed and clear answer!
Previous Topic:[ATL] auto-completion
Next Topic:[ATL] Two input models with cross references into one output model
Goto Forum:
  


Current Time: Wed Jul 23 11:02:42 EDT 2025

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

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

Back to the top