|
Re: [QVTO] Early mapping of metamodel elements [message #97953 is a reply to message #97861] |
Wed, 21 January 2009 11:26 |
Eclipse User |
|
|
|
Originally posted by: mahdider.students.uni-mainz.de
Hello,
I guess you want to transform a model a which conforms to metamodel A to
a model b which conforms to metamodel B.
I dont't know a fully automated solution to this problem, because there
ar usually semantics involved in metamodels, which cannot be understood
automatically.
What you can do is something like this (example):
/*
Maps a given Java Class to its UML representation.
*/
mapping JAVA::Class::class2Class() : SIMPLE_UML::UmlClass {
init {
result := map singleClassifier(self.name);
}
umlGeneral := self._extends->map class2Class()->asSet();
attributes := self.fields->map field2Attribute()->asSet();
methods := self.methods->map method2Method()->asSet();
}
Now I am not sure if this is exactly what you wanted, but I hope it
helps. :-)
Best Regards,
Mahdi D-Manesh
Hossam Karim schrieb:
> 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 11:54 |
Radomil Dvorak Messages: 249 Registered: July 2009 |
Senior Member |
|
|
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.03259 seconds