Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Transform Ecore model to UML model(Include UML Primitive Types in the destination model)
Transform Ecore model to UML model [message #1701575] Tue, 14 July 2015 08:46 Go to next message
André Ribeiro is currently offline André RibeiroFriend
Messages: 55
Registered: January 2013
Member
Hi everyone,

I need to convert Ecore models to their equivalent representation in UML. For that purpose I'm trying to use the atl script in the following link (http://emftriple.googlecode.com/svn/tags/0.6.1/com.emf4sw.uml/src/com/emf4sw/uml/resources/Ecore2UML.atl).
It works fine with the exception of not setting the types of UML Properties. I've allowed inter-model references and then I got the following exception which I understand but do not know how to fix:
org.eclipse.emf.ecore.impl.EDataTypeImpl cannot be cast to org.eclipse.uml2.uml.Type


which is caused by this rule:
rule EAttribute2Property {
	from e: Ecore!EAttribute
	to
		u: UML!Property (
			name <- e.name,
			type <- e.eType,
			upper <- e.upperBound,
			lower <- e.lowerBound
		)
}


I understand that an ecore type cannot be directly mapped to a UML type. What I need is a function that checks the ecore type and then returns the corresponding UML primitive type.
I've tried the following test, but since I do not have the UML primitive types loaded it does not returns nothing:
type <- UML!PrimitiveType.allInstances() -> select(e | e.name = 'String').first()


In addition, I know that the destination model (UML) must contain the following XML in order to import the UML primitive types:
<packageImport xmi:id="_ZhW94SBFEeO_m-zgIyufMQ">
      <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
 </packageImport>


Can anyone help me with this?

Thanks in advance!


André Ribeiro
IST Lisbon
Portugal
Re: Transform Ecore model to UML model [message #1702802 is a reply to message #1701575] Fri, 24 July 2015 17:24 Go to previous message
André Ribeiro is currently offline André RibeiroFriend
Messages: 55
Registered: January 2013
Member
I solved this issue last week by importing the model with the UMLPrimitiveTypes and then I've defined a helper that receives the Ecore type and return its corresponding UML type.

helper def : getMappingType(input : Ecore!ETypedElement) : UML!Type =
if(input.name = 'EString') then Library!PrimitiveType.allInstancesFrom('IN_Library')->any(e|e.name='String')
else if(input.name = 'EBoolean') then Library!PrimitiveType.allInstancesFrom('IN_Library')->any(e|e.name='Boolean')
else if(input.name = 'EInt') then Library!PrimitiveType.allInstancesFrom('IN_Library')->any(e|e.name='Integer')
else if(input.name = 'EDouble') then Library!PrimitiveType.allInstancesFrom('IN_Library')->any(e|e.name='Real')
else OclUndefined
endif endif endif endif;

rule EAttribute2Property {
	from e: Ecore!EAttribute
	to
		u: UML!Property (
			name <- e.name,
			type <- thisModule.getMappingType(e.eType),
			upper <- e.upperBound,
			lower <- e.lowerBound
		)
}


Thanks anyway!


André Ribeiro
IST Lisbon
Portugal
Previous Topic:On which OCL-Specifiacation is ATL based on?
Next Topic:Superimposition of multiple modules
Goto Forum:
  


Current Time: Tue Sep 19 11:52:18 GMT 2017

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

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