Home » Modeling » M2T (model-to-text transformation) » [Xtend] problem in m2m transformation(random type (if any) after transformation)
[Xtend] problem in m2m transformation [message #525888] |
Thu, 08 April 2010 08:03 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Hi,
I'm still trying my transformation from object to relationnal model, but my relationnal model (the destination model) is incomplete.
This is my Xtend m2m file :
import metamodel;
import relationnel;
extension metamodel::Extensions reexport;
extension object2relationnal::SQLExtensions reexport;
//takes a Package as parameter, and creating a Database from it
create relationnel::Base transform (metamodel::Package p) :
this.setTables(p.classes().createTable());
// transforms all classes into SQL tables
create relationnel::Table createTable (metamodel::Class c) :
this.setName(c.name) ->
this.setColumn(c.attributs().createColumn());
// create a Column for every attribute which is not a composition or agregation
create relationnel::Column createColumn(metamodel::Attribute a) :
this.setName(a.name) ->
this.setType(a.type.createType());
create relationnel::RBool createType(metamodel::GBool t):
this.setName(t.name);
create relationnel::RString createType(metamodel::GString t):
this.setName(t.name);
create relationnel::RFloat createType(metamodel::GFloat t):
this.setName(t.name);
create relationnel::RInteger createType(metamodel::GInteger t):
this.setName(t.name);
create relationnel::LimitedString createType(metamodel::LimitedString t):
this.setName(t.name) ->
this.setSize(t.size);
create relationnel::UnlimitedString createType(metamodel::UnlimitedString t):
this.setName(t.name);
create relationnel::Datatype createType(metamodel::Type t):
this.setName(t.name);
I have tried with every type in my model, and whenever the type is GString in my source model, the type in my destination model is either nonexistant, or RString (but mostly nonexistant).
Something else I've realized, in the following m2t transformation, the final printed type for every Column without type (those that should be RString) is a random type.
To print the type in the Xpand template, I defined a tosql function.
I defined tosql for every possible type in my metamodel :
«DEFINE tosql FOR RInteger»INTEGER«ENDDEFINE»
«DEFINE tosql FOR RBool»BOOLEAN«ENDDEFINE»
One day I shall master M2T, but that day has yet to come...
|
|
| |
Re: [Xtend] problem in m2m transformation [message #526212 is a reply to message #525888] |
Fri, 09 April 2010 09:14 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Adding the stdlib jar and the info(t.name) didn't change anything (I couldn't see any difference), and looking back at my model, I think I have found why.
In my model, I have to define types outside of classes, so I can use them multiple times in the classes.
All thoses types have Datatype as ESuper Type, but I don't know how to define an Xtend function that would get all Datatypes objects and all objects that have Datatype as a ESuper Type (recursively).
Also, once that is donne, how can I merge two List (one list consists of Datatypes, the other of Tables, both of which are Type)?
One day I shall master M2T, but that day has yet to come...
|
|
| |
Re: [Xtend] problem in m2m transformation [message #526521 is a reply to message #526520] |
Mon, 12 April 2010 07:17 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Darius Jockel wrote on Mon, 12 April 2010 08:59 |
anyObject.eRootContainer.eAllContents.typeSelect(ESuperType)
|
Ok, I know what was wrong. I have Datatype in both my models, and the transformation used the wrong one. I'll change all names in my metamodel so that never happens again
Darius Jockel wrote on Mon, 12 April 2010 08:59 |
Quote: |
Also, once that is donne, how can I merge two List (one list consists of Datatypes, the other of Tables, both of which are Type)?
|
list1.addAll(list2)
|
Thanks.
Regards,
Maxime
One day I shall master M2T, but that day has yet to come...
|
|
|
Re: [Xtend] problem in m2m transformation [message #526556 is a reply to message #525888] |
Mon, 12 April 2010 09:45 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Darius Jockel wrote on Thu, 08 April 2010 11:43 |
create relationnel::RString createType(metamodel::GString t):
info(t.name) ->
this.setName(t.name);
to prove if this extension is executed for every GString in your model.
Maybe the every type in your model is a containment of your property.
So every type has an exclisive owner.
In this case, you should remove the containment flag.
|
750 INFO IOExtensions -
That line got added to my Console when running the workflow
As I have 5 OString, shouldn't there be 4 of those lines ?
My problem is that when I remove the containment flag, I get following error.
782 ERROR WorkflowRunner - Workflow interrupted. Reason: Problems writing xmi file to src-gen/outModel.xmi : The object 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@9be79a (eClass: org.eclipse.emf.ecore.impl.EClassImpl@161dfb5 (name: RDatatype) (instanceClassName: null) (abstract: false, interface: false))' is not contained in a resource.
But the file that get's generated is nearly what I want.
Without the containment flag, I get the error and all types inheriting form ODatatype are transformed as should be.
With the containment flag, the ODatatypes are transformed as should be, but I get my initial problem, only one instance for each EClass inheriting from ODatatype is transformed as should be.
One day I shall master M2T, but that day has yet to come...
|
|
| | | |
Re: [Xtend] problem in m2m transformation [message #526877 is a reply to message #526660] |
Tue, 13 April 2010 11:36 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
There might be a difference in the way both models handle types.
In my OMetamodel, the EClass OAttribute has an EReference type (to OType), and Containment is false.
In the RMetamodel, the Eclass RColumn has an EReference type (to RType), and if Containment is false the workflow states an error, and if true I get my problems with multiple use of a type.
When I wrote my model, I had to create my OType (OString or OBool or others) outside of OAttribute to refer to it.
I thought I could do the same in my destination model from my m2m transformation, apparently not, or at least not that way.
Regards,
Maxime
One day I shall master M2T, but that day has yet to come...
[Updated on: Tue, 13 April 2010 11:37] Report message to a moderator
|
|
| | | | |
Re: [Xtend] problem in m2m transformation [message #527419 is a reply to message #525888] |
Thu, 15 April 2010 08:34 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Problem solved !
I did not resolve types for my OTypedef when creating a RColumn, only when creating RDatatypes, so i was trying to make a reference to some OMetamodel types in my RModel.
Thank you.
Maxime
One day I shall master M2T, but that day has yet to come...
|
|
|
Goto Forum:
Current Time: Tue Sep 24 10:36:12 GMT 2024
Powered by FUDForum. Page generated in 0.05774 seconds
|