[QVTO] Early mapping of metamodel elements [message #97861] |
Tue, 20 January 2009 08:22  |
Eclipse User |
|
|
|
Hi everyone,
Is there a typical way to map existing model elements in 2 metamodels
before performing the mapping. For example, mapping UML primitive types
to Ecore primitive types and make them available for the transformation
context before starting the mapping.
Thanks,
Hossam Karim
|
|
|
|
Re: [QVTO] Early mapping of metamodel elements [message #97982 is a reply to message #97861] |
Wed, 21 January 2009 06:54   |
Eclipse User |
|
|
|
Hi Hossam Karim,
You can do it as the QVT code bellow:
Regards,
/Radek
-- the actual primitive type mapping
mapping UML::PrimitiveType::toEPrimitive() : ECORE::EDataType {
init {
var eTypeName := getEPrimitiveTypeName(self.name);
result := map
ecorePackage().getEClassifier(eTypeName).oclAsType(ECORE::ED ataType);
if(result.oclIsUndefined()) then {
result := map unresolvedPrimitiveType();
} endif;
}
}
-- ecore package access singleton, a mapping executed only once
mapping ecorePackage() : EPackage {
init {
var helperPackage := object EPackage {};
result := helperPackage.eClass().ePackage;
rdb.removeElement(helperPackage);
}
}
-- unresolved type singleton, can be queried to check for unmapped
primitive types
mapping unresolvedPrimitiveType() : EDataType {
name := 'unresolved';
}
helper getEPrimitiveTypeName(in umlTypeName : String) : String {
return switch {
case (umlTypeName = 'Integer') 'EInt';
case (umlTypeName = 'Boolean') 'EBoolean';
case (umlTypeName = 'String') 'EString';
-- add more
else null;
}
}
On Tue, 20 Jan 2009 14:22:52 +0100, Hossam Karim <hossam.karim@gmail.com>
wrote:
> Hi everyone,
> Is there a typical way to map existing model elements in 2 metamodels
> before performing the mapping. For example, mapping UML primitive types
> to Ecore primitive types and make them available for the transformation
> context before starting the mapping.
>
>
> Thanks,
> Hossam Karim
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05379 seconds