Skip to main content



      Home
Home » Modeling » ATL » 2 models to model transformation
2 models to model transformation [message #1735635] Tue, 21 June 2016 10:09 Go to next message
Eclipse UserFriend
Hi everyone,

someone has an example of transformation merging 2 ecore classes into a new one, joining subclasses?

Att
Re: 2 models to model transformation [message #1735807 is a reply to message #1735635] Wed, 22 June 2016 16:59 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: 2 models to model transformation [message #1736924 is a reply to message #1735807] Mon, 04 July 2016 07:54 Go to previous message
Eclipse UserFriend
Hi Dennis, thanks for your response.

No, I don't want to migrate the references, I want to create a new model with the union of two other classes, including subclasses, attributes, etc.

e.g.:

Class CarA with attributes
- year(int)
- chassi(int)

Subclass Motor from CarA with attributes
- potency(int)

Class CarB with attributes:
- year(int)
- chassi(int)

Subclass Motor from CarB with attributes
- potency(int)

Subclass Door from CarB with attributes
- position(int)

The new class that I want to generate is the merge of class CarA with CarB
Class MergeClassACarB with attributes:
- year(int)
- chassi(int)

Subclass Motor
- potency(int)

Subclass Door
- position(int)


I really need any example code for this.

Att,

Previous Topic:Problem with simple ATL transformation
Next Topic:UML primitive types
Goto Forum:
  


Current Time: Fri Jul 25 01:06:07 EDT 2025

Powered by FUDForum. Page generated in 0.06953 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top