| -- @atlcompiler atl2006 |
| |
| module Assign_Model_Sim; -- Module Template |
| create OUT : AMW from IN : AMW, left : MOF, right : MOF, rightModel: right, leftModel: left; |
| |
| helper def: methodName : String = 'Model values'; |
| |
| helper context MOF!EModelElement def: similarityData(right : MOF!EModelElement) : Real = |
| if self.oclIsTypeOf(MOF!EAttribute) and right.oclIsTypeOf(MOF!EAttribute) then |
| let value : Real = |
| |
| self.eContainingClass.allInstances()->iterate(instClass1; acc1 : Real = 0.0 | |
| acc1 + right.eContainingClass.allInstances()->iterate( instClass2; acc2 : Real = 0.0 | |
| if instClass1.refGetValue(self.name) = instClass2.refGetValue(right.name) then |
| acc2 + 1 |
| else |
| acc2 + 0 |
| endif |
| ) |
| ) |
| in |
| value |
| 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.similarityData(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 |
| ) |
| } |