Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Early mapping of metamodel elements
[QVTO] Early mapping of metamodel elements [message #97861] Tue, 20 January 2009 08:22 Go to next message
Eclipse UserFriend
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 #97953 is a reply to message #97861] Wed, 21 January 2009 06:26 Go to previous messageGo to next message
Eclipse UserFriend
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 06:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: [QVTO] Early mapping of metamodel elements [message #648214 is a reply to message #97982] Tue, 11 January 2011 14:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi Radomil,

I am trying to get access to the types as discussed in this post. I am not successful since the following line does not compile in my QVTO:

helperPackage.eClass().ePackage


I can' t seem to get at the package that holds the classifiers.

Any help would be greatly appreciated.

Ken Sayers
Re: [QVTO] Early mapping of metamodel elements [message #648334 is a reply to message #97861] Wed, 12 January 2011 08:38 Go to previous message
Eclipse UserFriend
Hi All,

Rich G. gave me the answer to this.

add this import to the qvto:

import emf.tools;


Then, use something like:

result := helperPackage.asEObject().eClass().ePackage;


Everything should then work as described by Radomil.

Ken
Previous Topic:[ATL] Rule inheritance gives nullpointer exception ?
Next Topic:[ATL] Parallel Combined Fragments question.
Goto Forum:
  


Current Time: Sun Jul 06 23:29:23 EDT 2025

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

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

Back to the top