|
Re: [QVTO] Unbound mappings not reentrant? [message #521071 is a reply to message #521067] |
Tue, 16 March 2010 12:00 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi Uwe,
Your problem is caused by repeated mapping calls on the same
input, which causes to fetch existing result from traces,
the mapping actually gets executed just once for the given
input.
Consequently, the 'map createTable('A')' call performed on behalf of
different schemas results just in moving the single Table instance
created by that mapping first invocation into the 'elements' reference
of the last schema. That is what you can see in your out model.
The inlined object expression works because no traces are created in this
case.
You can modify your table mapping as the following:
mapping inout Schema::addTable(tableName : String) : rdb::Table
In this case the input to the mapping is represented by the schema to
be modified and the tableName, which is a unique combination for
every schema building.
Note that creating columns is analogous case.
Regards,
/Radek
On Tue, 16 Mar 2010 12:30:13 +0100, Uwe Ritzmann <Uwe.Ritzmann@dhl.com>
wrote:
> Dear QVTO Experts,
>
> I struggle with some intricacies between inline object creation and
> object creation thru calling an unbound mapping.
>
> The following transformation script:
> modeltype rdb uses
> "http://www.eclipse.org/qvt/1.0.0/Operational/examples/rdb";
>
> transformation CreateRdb(out rdbModel : rdb);
>
> main()
> {
> map createModel('model1');
> }
>
> mapping createModel(modelName : String) : rdb::Model
> {
> result.name := modelName;
> result.schemas += map createSchema('s1');
> result.schemas += map createSchema('s2');
> result.schemas += map createSchema('s3');
> }
>
> mapping createSchema(schemaName : String) : rdb::Schema
> {
> result.name := schemaName;
> result.elements += map createTable('A');
> result.elements += map createTable('B');
> result.elements += map createTable('C');
> }
>
> mapping createTable(tableName : String) : rdb::Table
> {
> result.name := tableName;
> result.columns += map createColumn('c1');
> result.columns += map createColumn('c2');
> result.columns += object rdb::TableColumn { name := 'c3'; }
> }
>
> mapping createColumn(columnName : String) : rdb:: TableColumn
> {
> result.name := columnName;
> }
>
> renders this results:
> <?xml version="1.0" encoding="UTF-8"?>
> <rdb:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:rdb="http://www.eclipse.org/qvt/1.0.0/Operational/examples/rdb"
> name="model1">
> <schemas name="s1"/>
> <schemas name="s2"/>
> <schemas name="s3">
> <elements xsi:type="rdb:Table" name="A">
> <columns name="c3"/>
> </elements>
> <elements xsi:type="rdb:Table" name="B">
> <columns name="c3"/>
> </elements>
> <elements xsi:type="rdb:Table" name="C">
> <columns name="c1"/>
> <columns name="c2"/>
> <columns name="c3"/>
> </elements>
> </schemas>
> </rdb:Model>
>
> which I did not expect. Schemes s1 and s2 are completly
> empty, tables s3.A and s3.B have only the column that was generated thru
> inline object creation.
>
> I did not find the place in the specs that would explain that behaviour.
>
> Can anyone enlighten me?
>
> I am running eclipse-modelling-galileo-SR1-win32 with no outstanding
> updates.
>
> Many thanks in advance.
>
> Best Regards,
>
> Uwe
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04555 seconds