blob: 0f062fbf3d7800c78f8c97e8f4d8b72edd1c3cae [file] [log] [blame]
-- @atlcompiler atl2006
module Assign_Cardinality_Sim; -- Module Template
create OUT : AMW from IN : AMW, left : MOF, right : MOF;
helper def: methodName : String = 'Cardinality';
helper context MOF!EModelElement def: similarityUpper(right : MOF!EModelElement) : Real =
if self.oclIsKindOf(MOF!ETypedElement) and right.oclIsKindOf(MOF!ETypedElement) then
if self.upperBound = right.upperBound then
1
else
0
endif
else
0
endif;
helper context MOF!EModelElement def: similarityLower(right : MOF!EModelElement) : Real =
if self.oclIsKindOf(MOF!ETypedElement) and right.oclIsKindOf(MOF!ETypedElement) then
if self.lowerBound = right.lowerBound then
1
else
0
endif
else
0
endif;
rule UpdateSim {
from
mmw : AMW!Equivalent
using {
left : MOF!EModelElement = MOF!EModelElement.getInstanceById('left',mmw.left.element.ref);
right : MOF!EModelElement = MOF!EModelElement.getInstanceById('right',mmw.right.element.ref);
}
to
alink : AMW!Equivalent (
name <- mmw.name,
model <- mmw.model,
left <- mmw.left,
right <- mmw.right,
similarity <- mmw.similarity +
left.similarityLower(right) +
left.similarityUpper(right)
)
}
------------------------------copied rules---------------------------------------------------
rule leftElement {
from
mmw : AMW!LeftElement
to
out : AMW!LeftElement (
name <- mmw.name,
element <- mmw.element
)
}
rule rightElement {
from
mmw : AMW!RightElement
to
out : AMW!RightElement (
name <- mmw.name,
element <- mmw.element
)
}
rule ElementRefs {
from
mmw : AMW!ElementRef
to
out : AMW!ElementRef (
name <- mmw.name,
ref <- mmw.ref,
modelRef <- mmw.modelRef
)
}
rule matchmodel {
from
mmw: AMW!MatchModel
to
model : AMW!MatchModel (
name <- mmw.name,
leftM <- mmw.leftM,
rightM <- mmw.rightM,
methods <- mmw.methods->union(Sequence{method})
),
method : AMW!Method (
name <- thisModule.methodName
)
}
rule method {
from
mmw : AMW!Method
to
method : AMW!Method (
name <- mmw.name
)
}
rule modelref {
from
mmw : AMW!ModelRef
to
out : AMW!ModelRef (
name <- mmw.name,
ref <- mmw.ref
)
}