[Xtend] modifying a model [message #537083] |
Tue, 01 June 2010 09:30 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
Hi,
For a m2m transformation using Xtend, I created an extension to transform from a model to another.
Quote: | create relationnel::Schema transform (metamodel::Package p) :
let opprelation=p.classes().birelations().relationsWithOpposites () :
// creates a RDatatype for every ODatatype
setTypes(p.datatypes().createType()) ->
// adds a RInteger to model, all keys will reference it
types.add(getKey()) ->
// creates a RTable for every OClass, with their foreign keys
types.addAll(p.classes().createTable()) ->
// creates a RTable for every opposite relation, with it's foreign keys
types.addAll(opprelation.collect(r|r.createLinkTable(
this.tables().select(e| (e.name.toLowerCase() == r.opposite.type.name.toLowerCase() || e.name.toLowerCase() == r.type.name.toLowerCase()))))) ->
// adds a foreign key for every composition
p.classes().compositions().getRTable(this) ->
// create a RTable for every agregation, whose cardinality is different from 0..1
types.addAll(p.classes().agregations().createAgregateTable(t his,p)) ->
// adds a foreign key for every reference
p.classes().references().addReferences(this,p) ->
this.tables().collect(e|e.addInheritance(this,p)) ->
this;
|
I thought that with the getRTable extension, I could modify the Schema, but I realised modification have not been taken into account once transformation is over. How can I make the transformation last ?
Quote: | getRTable(OAttribute a,Schema s) :
// select the tables in which the foreign key is to be added (should return a List with one element)
let compotable = s.tables().select(e|e.name == a.opposite.type.name) :
// select the table that is to be added as foreign key
let newkey = s.tables().select(e|e.name == a.type.name) :
compotable.collect(e|e.addForeignKeys(newkey.first())) ->
newkey.info();
// adds RTable c as a foreign key to RTable t, called by getRTable
addForeignKeys(RTable t,RTable c):
t.info()->
t.foreignKeys.add(c) ->
t.setComposed(true);
|
One day I shall master M2T, but that day has yet to come...
|
|
|
|
|
|
|
Re: [Xtend] modifying a model [message #537167 is a reply to message #537083] |
Tue, 01 June 2010 14:29 |
MaximeLecourt Messages: 108 Registered: February 2010 Location: France |
Senior Member |
|
|
I found out I had a bug in my m2m.
Well now I have two, as I got the results I needed, so whatever failed here is added somewhere else where it shouldn't be on another test.
One day I shall master M2T, but that day has yet to come...
|
|
|
Powered by
FUDForum. Page generated in 0.02726 seconds