Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Call lazy rule not for a collection
[ATL] Call lazy rule not for a collection [message #671859] Thu, 19 May 2011 07:54 Go to next message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
I am using following example to call a lazy rule for a collection:

create OUT : B from IN : A;

rule RootElement {
from
billOfMaterial : A!BillOfMaterial
to
target : B!BCModel (
categories <- billOfMaterial.armature.parts->collect(e | thisModule.Part2Category(e))
)
}

lazy rule Part2Category {
from
s : A!Part
to
t : B!Category(

)
}

Can anybody tell me how to call a lazy rule for a single object? In my case i want to call it for billOfMaterial.armature(which is not a collection), but did not find such a case in the documentation.

Second problem is how to get information from billOfMaterial to that lazy rule function??

Sorry for my stupid questions, in my opinion ATL is quite difficult to understand for beginners.

Cheers
Patrick

[Updated on: Thu, 19 May 2011 07:56]

Report message to a moderator

Re: [ATL] Call lazy rule not for a collection [message #671927 is a reply to message #671859] Thu, 19 May 2011 11:40 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
As simple as thisModule.yourLazyRule(billOfMaterial.armature).

For you second question, you can have multiple from for a lazy rule.
thisModule.yourLazyRule(billOfMaterial, billOfMaterial.armature)

lazy rule yourLazyRule{
from
s : A!C, u : A!D
to
t : B!F(

)
}
Re: [ATL] Call lazy rule not for a collection [message #671999 is a reply to message #671927] Thu, 19 May 2011 14:36 Go to previous messageGo to next message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
I solved to problem in that way:

rule RootElement {
	from
		billOfMaterial : A!BillOfMaterial
	to
		target : B!BCModel	(
				categories <- billOfMaterial.addArmature(billOfMaterial.armature)
				)

}


helper context A!BillOfMaterial def : addArmature(arm : A!Armature) : B!Category =
	if not self.armature.oclIsUndefined() then
			B!Category.newInstance()	
	else
		OclUndefined
	endif;



But i cant set the name of my Category Instance, any suggestion to find a better way ?

Re: [ATL] Call lazy rule not for a collection [message #672024 is a reply to message #671999] Thu, 19 May 2011 15:36 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
rule RootElement {
	from
		billOfMaterial : A!BillOfMaterial
	to
		target : B!BCModel	(
			categories <- if billOfMaterial.armature.oclIsUndefined() then OclUndefined else thisModule.addArmature() endif
		)

}


lary rule addArmature{
from arm : A!Armature
to t : B!Category()
}
Re: [ATL] Call lazy rule not for a collection [message #672033 is a reply to message #672024] Thu, 19 May 2011 16:06 Go to previous messageGo to next message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
Thx a lot.

Because of the huge possibilites of that language I feel its not so easy get the proper way using ATL.
Re: [ATL] Call lazy rule not for a collection [message #672197 is a reply to message #672024] Fri, 20 May 2011 09:36 Go to previous messageGo to next message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
Sylvain EVEILLARD wrote on Thu, 19 May 2011 11:36
rule RootElement {
	from
		billOfMaterial : A!BillOfMaterial
	to
		target : B!BCModel	(
			categories <- if billOfMaterial.armature.oclIsUndefined() then OclUndefined else thisModule.addArmature() endif
		)

}


lary rule addArmature{
from arm : A!Armature
to t : B!Category()
}



I have again a question:

Lets assume category object contains a list of "Distributors". I want to fill that list with new "Distributor" objects. Theese objects have to get filled with information from "Part" objects. The "Part" instances are children from billOfMaterial.armature.

What expressions do i have to use for such use cases ? I am playing with ATL without getting a working result, so i would be very pleased for some hints.

[Updated on: Fri, 20 May 2011 09:38]

Report message to a moderator

Re: [ATL] Call lazy rule not for a collection [message #672211 is a reply to message #672197] Fri, 20 May 2011 10:40 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
A lazy rule can call another lazy rule which is probably what you need here
Re: [ATL] Call lazy rule not for a collection [message #672235 is a reply to message #672211] Fri, 20 May 2011 12:20 Go to previous messageGo to next message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
Yes a lazy rule is basicly working. But i dont know how to get data from source model objects which are one or two lazy rules above used.
Re: [ATL] Call lazy rule not for a collection [message #672242 is a reply to message #672235] Fri, 20 May 2011 12:46 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
just pass the object from a lazy rule to an other
Re: [ATL] Call lazy rule not for a collection [message #672286 is a reply to message #672242] Fri, 20 May 2011 14:27 Go to previous message
Patrick Schmitt is currently offline Patrick SchmittFriend
Messages: 87
Registered: July 2009
Member
It was a hard way to find out, but I'm doing some steps in the right direction.

thanks
Previous Topic:[Xtend] Setting class attributes which are of a custom EDataType type.
Next Topic:ATL transformation called in java does not work for all cases
Goto Forum:
  


Current Time: Sat Apr 20 01:18:08 GMT 2024

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

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

Back to the top