blob: b9b3c7d460998934b409d3652c203854e96468e6 [file] [log] [blame]
module Assign_Type_Conf_Sim; -- Module Template
create OUT : AMW from IN : AMW, left : MOF, right : MOF;
helper def: methodName : String = 'Cardinality and containment';
helper context MOF!EModelElement def: similarityType(right : MOF!EModelElement) : Real =
if self.oclIsKindOf(MOF!ETypedElement) and right.oclIsKindOf(MOF!ETypedElement) then
if self.eType.name = right.eType.name then
1
else
0
endif
else
0
endif;
helper context MOF!EModelElement def: similarityContainer(right : MOF!EModelElement) : Real =
if self.oclIsTypeOf(MOF!EReference) and right.oclIsTypeOf(MOF!EReference) then
if self.containment and right.containment then
1
else
0
endif
else
0
endif;
helper context MOF!EModelElement def: similarityConformance(right : MOF!EModelElement) : Real =
if self.oclType() = right.oclType() then
1
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.similarityConformance(right) +
left.similarityType(right) +
left.similarityContainer(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
)
}