Skip to main content



      Home
Home » Modeling » ATL » transformation with multiple inputs
transformation with multiple inputs [message #1064131] Mon, 17 June 2013 14:30 Go to next message
Eclipse UserFriend
Hi,

In my transformation, I create an output model from two input uml models. In a part of the transformation, I have a rule that for each class in input model 1 that has Stereotype C1, it checks in the second input model if there is an association (AS) between this class and another class with stereotype C2. If so, then the association and the corresponding class will be added in the output.
I wrote the transformation like this, but the last condition is always false and it generates an empty model. What is my mistake?

rule check {
from
source: MM!Class, --C1 in Input M1
source1:MM1!Class, --C1 in Input M2
source2:MM1!Association, --AS
source3:MM1! Class --C2 in input M2

(source.getAppliedStereotypes()->collect(st |st.name)-> at(1)='C1'
and source1.getAppliedStereotypes()->collect(st |st.name)-> at(1)='C1'
and source.name = source1.name
and source3.getAppliedStereotypes()->collect(st |st.name)-> at(1)='C2'
and source2.getAppliedStereotypes()->collect(st |st.name)-> at(1)='AS'
and source2.memberEnd -> select(c|c.type.hasStereotype('C2'))-> notEmpty()
and source2.memberEnd -> collect (n|n.type)->debug ('membername:')-> includes (source->debug('source'))->debug ('result:')
)

to
target: MM2!Class (
name <- source.name ,
package <- source.package,
ownedAttribute<- source.ownedAttribute
),

t1: MM2! C1 (
base_Class <- target
),
target1: MM2! Class (
name <- source3.name ,
package <- source3.package,
ownedAttribute<- source3.ownedAttribute

),
target11: MM2! C2 (
base_Class <- target1

),
t2: MM2!Association (
name <- 'as',
package <- source2.package,
memberEnd<- Set{p1,p2},
ownedEnd <- source2.ownedEnd
),
t3: MM2!AS (
base_Association <- t2
),
p1: MM2!Property(
name<-'p1',
type<- target,
association<- t2
),
p2: MM2!Property(
name<-'p22',
type<- target1,
association<- t2
)
}

Thank you
Re: transformation with multiple inputs [message #1064238 is a reply to message #1064131] Tue, 18 June 2013 07:11 Go to previous messageGo to next message
Eclipse UserFriend
You can use multiple inputs for lazy rules only, not for matched ones as you are trying.

[Updated on: Tue, 18 June 2013 08:51] by Moderator

Re: transformation with multiple inputs [message #1064255 is a reply to message #1064131] Tue, 18 June 2013 08:53 Go to previous messageGo to next message
Eclipse UserFriend
The edit of my previous message seems to have failed; here it is once more:

You can use multiple inputs for lazy rules only, not for matched ones as you are trying.
Re: transformation with multiple inputs [message #1064269 is a reply to message #1064255] Tue, 18 June 2013 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

You can of course have a multiple inputs pattern in a matched rule.
Such a match rule will be applied on the Cartesian product of the input model elements matching this input pattern (including the condition).
If your matched rule is never matched while executing your transformation, it is because the condition you have defined is probably too restrictive or somehow incorrect.
Re: transformation with multiple inputs [message #1064368 is a reply to message #1064269] Tue, 18 June 2013 19:09 Go to previous message
Eclipse UserFriend
Yes, It is because of the last constraint. Although the name of the classes are the same, this constraint is always false. because the models are different. So I changed it to the following and it works.

and source2.endType-> collect (n|n.name) -> includes (source.name)
Previous Topic:TCS plugin
Next Topic:[ATL] Wrong XML output with EMF metamodel conform XSD
Goto Forum:
  


Current Time: Tue Jul 22 18:16:52 EDT 2025

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

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

Back to the top