Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] How to Clone/Copy source elements to multiple target elements
[ATL] How to Clone/Copy source elements to multiple target elements [message #516524] Wed, 24 February 2010 10:58 Go to next message
Tim  is currently offline Tim Friend
Messages: 7
Registered: December 2009
Junior Member
Hi all,

In my ATL transformation I have a location class that contains a set of invariant expressions. I would like to transform the model in such a way that the new invariant set in the target model contains all the source invariant expressions AND a copy of each of the expressions. So {exp1} must be transformed to {exp1,exp1}.

Currently I've tried to transform the source to target expressions using match rules and tried to create the extra/copied expressions using lazy rules. This unfortunately didn't work.
What happens is that the lazy rule Number2 is executed first, whereafter the match rule Number1 is not executed once, but twice. Does anyone have an explanation for this? I know that it can be solved by placing the Number1 rule above the Location rule. So it probably is the case that the expression created by the lazy rule is seen as a source element by the matched rule.

I currently use both match and lazy rules. Does anybody know a better way to create the two instances in the target model? What I would like to have is just one match rule, and then something of a cloning rule/action, but I don't know if this is possible.

Any help would be greatly appreciated.
Best regards,

Tim

--copy location
rule Location{
from s : cif!Location
to t : cif!Location(
invariant <- s.invariant->union(s.invariant->collect(inv| inv.getExpression()))
)
}

--copy number
rule Number1{
from s : cif!Number
to t : cif!Number(
value <- s.value + 'new',
type <- s.type
)
}

--copy nat type
rule NatType1{
from s : cif!NatType
to t : cif!NatType()
}

helper context cif!Number def: getExpression() : cif!Expression =
thisModule.Number(self);

--copy number
lazy rule Number2{
from s : cif!Number
to t : cif!Number(
value <- s.value,
type <- s.type.getStaticType()
)
}

helper context cif!NatType def: getStaticType(): cif!StaticType =
thisModule.NatType(self);

--copy nat type
lazy rule NatType2{
from s : cif!NatType
to t : cif!NatType()
}
Re: [ATL] How to Clone/Copy source elements to multiple target elements [message #516621 is a reply to message #516524] Wed, 24 February 2010 15:39 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can use multiple target elements in each rule and use resolveTemp to get both target elements instead of just the first one.
I'm afraid it's the only available solution in a declarative way.

That would be :

--copy location
rule Location{
from s : cif!Location
to t : cif!Location(
invariant <- s.invariant->collect(e | Sequence{thisModule.resolveTemp(e,'t'),thisModule.resolveTem p(e,'copy')})- >flatten()
)
}

--copy number
rule Number1{
from s : cif!Number
to t : cif!Number(
value <- s.value,
type <- s.type
),
copy : cif!Number(
value <- s.value + 'new',
type <- thisModule.resolveTemp(s.type,'copy')
)
}

--copy nat type
rule NatType1{
from s : cif!NatType
to t : cif!NatType(),
copy : cif!NatType(),
}

You could also use called rules.
Re: [ATL] How to Clone/Copy source elements to multiple target elements [message #516836 is a reply to message #516524] Thu, 25 February 2010 10:29 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You could even write your transformation in the normal way and write a custom HOT to generate the 'copy' version of your transformation Smile
Previous Topic:[M2M] How to transform UML2 model to EMF model
Next Topic:[ATL] The simpliest ATL-Sample doesnt launch
Goto Forum:
  


Current Time: Fri Apr 26 19:07:18 GMT 2024

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

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

Back to the top