transformation with multiple inputs [message #1064131] |
Mon, 17 June 2013 14:30  |
Eclipse User |
|
|
|
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 #1064368 is a reply to message #1064269] |
Tue, 18 June 2013 19:09  |
Eclipse User |
|
|
|
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)
|
|
|
Powered by
FUDForum. Page generated in 0.22892 seconds