|
Re: 2 models to model transformation [message #1735807 is a reply to message #1735635] |
Wed, 22 June 2016 20:59 |
|
I understand you want to migrate all references from the source ecore classes to the merged ecore class? ATL only supports reference migration scenarios in EMFTVM using the "remap()" operation in refining mode:
-- @atlcompiler emftvm
-- @nsURI ECORE=http://www.eclipse.org/emf/2002/Ecore
module MergeEClass;
create OUT: ECORE refining IN: ECORE;
rule Package {
from
s : ECORE!EPackage
to
t : ECORE!EPackage (
-- remap() will replace 'dropped' by 'retained', so 'retained' is excluded to prevent duplicates
eClassifiers <- s.eClassifiers ->
excluding(s.eClassifiers -> any(c | c.name = 'Retained'))
)
}
rule MergeClass {
from
retainedClass: ECORE!EClass,
droppedClass: ECORE!EClass (
retainedClass.name = 'Retained' and
droppedClass.name = 'Dropped'
)
to
t : ECORE!EClass mapsTo retainedClass (
eSuperTypes <- droppedClass.remap(retainedClass).eSuperTypes ->
asOrderedSet() -> union(droppedClass.eSuperTypes -> asOrderedSet())
)
}
rule DeleteGenericType {
from
s : ECORE!EGenericType (
let c : OclAny = s.refImmediateComposite() in
c.oclIsKindOf(ECORE!EClass) and c.name = 'Dropped'
)
}
Separate rules 'Package' and 'DeleteGenericType' are required to deal with quirks in the Ecore metamodel implementation (EPackage.eClassifiers must be unique, and each EClass has implicit EGenericType instances for each of its superclass references). Attached you'll find an example Eclipse project.
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.02945 seconds