Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Type problem in Ecore2UML transformation
[QVTO] Type problem in Ecore2UML transformation [message #103553] Wed, 15 April 2009 19:22 Go to next message
Eclipse UserFriend
Im performing a Ecore2UML transformation, but i cant find the right type
to set in properties(UML attributes) and parameters.

-- Ecore classes in UML classes
mapping Ecore::EClass::eClasses2classes() : UML::Class
{
name := self.name;
ownedAttribute += self.eAllAttributes.map eAttribute2property();
ownedAttribute += self.eAllReferences.map eReferences2property();
ownedOperation += self.eOperations.map eOperation2operation();
}

mapping Ecore::EReference::eReferences2property() : UML::Property
{
name := self.name;
lower := self.lowerBound;
upper := self.upperBound.oclAsType(UML::Integer);

type := self.?????? <------ PROBLEM
}

if self's type is an EDataType or EEnum, its ok, because the
PrimitiveType's and Enumeration's were previously mapped to output Package.
In this case, I can use:
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg03940.html

But in my example above, self's type is another EClass(attribute actually
is a EReference), I can't use that solution. Maybe the EClass(the
EReference's type) have not been mapped to a Class in output model yet.

Example:

EPackage package
EClass class1
EReference reference : class2
EClass class2
EAttribute attribute : Int

When the transformation is running the "reference" and your type, no one
class2 exists.

I was try:
type := self.eType; -- Error. eType:EClassifier != type : UML:Type
type := self.eType.oclAsType(UML::Class); -- No error, but not correct.
Nothing happens.

Thank you.
Hugo Melo.
Re: [QVTO] Type problem in Ecore2UML transformation [message #103581 is a reply to message #103553] Thu, 16 April 2009 05:34 Go to previous message
Eclipse UserFriend
Hi Hugo,

You might find useful the Ecore2UML example at
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.qvt.oml/examples/org.eclipse.m2m.qvt.oml.econ20 09.tutorial/projects/qvto.ecore2uml/transforms/Ecore2UML.qvt o?revision=1.4&root=Modeling_Project

This transf is simplified for the tutorial purposes, however shows to core
job
and outlines how to proceede in such cases.

As for your problem, you can freely call a type mapping operation just in
EReference::eReferences2property(), even though the target does not exist.

What will happen is that the resulting UML::Class just has no UML::Package
container
assigned at this moment. However, this UML::Class instance is reachable
via mapping and
resolve calls. The UML::Package container will be typically assigned
in a mapping like bellow:

mapping EPackage::toPackage() : UML::Package {
packagedElement := self.eClassifiers->map eClassifier2Type();
// do the rest of the job
}

The type mapping calls performed within the package mapping return either
a newly
created UML type object or fetch an existing one from the traces (already
created
by type mapping calls in eReferences2property()).

Obviously, one might insist on having all UML classes added to its package
just after creation
or have whatever other specific requirements, which typically are the
criteria for choosing
the optimal approach.
Another way could be using multiple passes or late resolve.

I'm happy to see you are trying to use QVTo but it's also
fair to mention that there is already existing converter Java class in
'org.eclipse.uml2',
see 'org.eclipse.uml2.uml.util.UMLUtil.Ecore2UMLConverter'.

Anyway, a good task for practising QVTo tranfs ;)

Regards,
/Radek



On Thu, 16 Apr 2009 01:22:46 +0200, Hugo Melo <hugofariamelo@gmail.com>
wrote:

> Im performing a Ecore2UML transformation, but i cant find the right type
> to set in properties(UML attributes) and parameters.
>
> -- Ecore classes in UML classes
> mapping Ecore::EClass::eClasses2classes() : UML::Class
> {
> name := self.name;
> ownedAttribute += self.eAllAttributes.map eAttribute2property();
> ownedAttribute += self.eAllReferences.map eReferences2property();
> ownedOperation += self.eOperations.map eOperation2operation();
> }
>
> mapping Ecore::EReference::eReferences2property() : UML::Property
> {
> name := self.name;
> lower := self.lowerBound;
> upper := self.upperBound.oclAsType(UML::Integer);
>
> type := self.?????? <------ PROBLEM
> }
>
> if self's type is an EDataType or EEnum, its ok, because the
> PrimitiveType's and Enumeration's were previously mapped to output
> Package.
> In this case, I can use:
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg03940.html
>
> But in my example above, self's type is another EClass(attribute
> actually is a EReference), I can't use that solution. Maybe the
> EClass(the EReference's type) have not been mapped to a Class in output
> model yet.
>
> Example:
>
> EPackage package
> EClass class1
> EReference reference : class2
> EClass class2
> EAttribute attribute : Int
>
> When the transformation is running the "reference" and your type, no one
> class2 exists.
>
> I was try:
> type := self.eType; -- Error. eType:EClassifier != type : UML:Type
> type := self.eType.oclAsType(UML::Class); -- No error, but not correct.
> Nothing happens.
>
> Thank you.
> Hugo Melo.
>
Previous Topic:[ATL] can we "cast" an EMFModel to an ASMModel?
Next Topic:[ATL]
Goto Forum:
  


Current Time: Wed Apr 30 00:07:09 EDT 2025

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

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

Back to the top