Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Accessing Enum Literals from ETL
Accessing Enum Literals from ETL [message #525350] Tue, 06 April 2010 05:22 Go to next message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi,
I am transforming an instance of metamodel A into metamodel B using ETL
under the control of Ant.

Metamodel A is auto-generated from the relevant XML schema, Metamodel B
is specified in a single Emfatic file and has the following structure:

@namespace (blah)
package Parent;
import "Stuff";
class Thing extends Stuff.Other {
attr String name = "";
}
@namespace (blah/Parent)
package Child {
class Foo {
attr String name = "";
attr BarType bar = "T";
}
enum BarType {
T = 0;
NT = 1;
}
}

I invoke the transformation 'Tx.etl' using
<property name="TargetFile" value="dirSpecForOutputFile"/>
<property name="TargetModelUri" value="aUrl"/>
<property name="TargetModel" value="Parent"/>
....
<epsilon.loadModel name="${TargetModel}" type="EMF">
<parameter name="modelFile" file="${TargetFile}"/>
<parameter name="metamodelUri" value="${TargetModelUri}"/>
<parameter name="readOnLoad" value="true"/>
<parameter name="storeOnDisposal" value="true"/>
</epsilon.loadModel>
....
<epsilon.etl src="${MyEtlFile}">
<model ref="${SourceName}" as="Source"/>
<model ref="${TargetModel}" as="Target"/>
</epsilon.etl>

From within the ETL file I can transform the source metamodel items
into (e.g.) instances of Thing and Foo via:
rule aRule1
transform itemIn : Source!SourceType1
to itemOut : Target!Thing {
itemOut.name := itemIn.name;
}
And
rule aRule2
transform itemIn : Source!SourceType2
to itemOut : Target!Foo {
itemOut.name := itemIn.name;
}

Hence, I can access the classes within my metamodel structure via
Target!<myClass>. However, if I try to access the enumeration literals
of BarType in a similar fashion:
rule aNewRule2
transform itemIn : Source!SourceType2
to itemOut : Target!Foo {
itemOut.name := itemIn.name;
itemOut.bar := itemIn.bar.transformInBarToOutBar();
}
operation String transformInBarToOutBar() {
if (self = 'T') {
return Target!BarType#T;
} else if (self = 'NT') {
return Target!BarType#NT;
} else {
throw 'Error';
}
}

Then it does not appear possible to access BarType via Target!BarType,
even though I can access Foo via Target!Foo and they're both in the same
namespace. ETL reports that it cannot find the enumeration literal
BarType#T. How should I access BarType such that I can assign the
relevant enumeration literal to the slot foo.bar?

Is there an error in my code or is this a bug in ETL?

Regards
Chris
Re: Accessing Enum Literals from ETL [message #525354 is a reply to message #525350] Tue, 06 April 2010 05:50 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

At a first glance your code looks fine. Could you possibly put together
a minimal running example that reproduces this so that I can have a
closer look at this?

Cheers,
Dimitris

On 06/04/2010 13:08, Chris Holmes wrote:
> Hi,
> I am transforming an instance of metamodel A into metamodel B using ETL
> under the control of Ant.
>
> Metamodel A is auto-generated from the relevant XML schema, Metamodel B
> is specified in a single Emfatic file and has the following structure:
>
> @namespace (blah)
> package Parent;
> import "Stuff";
> class Thing extends Stuff.Other {
> attr String name = "";
> }
> @namespace (blah/Parent)
> package Child {
> class Foo {
> attr String name = "";
> attr BarType bar = "T";
> }
> enum BarType {
> T = 0;
> NT = 1;
> }
> }
>
> I invoke the transformation 'Tx.etl' using
> <property name="TargetFile" value="dirSpecForOutputFile"/>
> <property name="TargetModelUri" value="aUrl"/>
> <property name="TargetModel" value="Parent"/>
> ...
> <epsilon.loadModel name="${TargetModel}" type="EMF">
> <parameter name="modelFile" file="${TargetFile}"/>
> <parameter name="metamodelUri" value="${TargetModelUri}"/>
> <parameter name="readOnLoad" value="true"/>
> <parameter name="storeOnDisposal" value="true"/>
> </epsilon.loadModel>
> ...
> <epsilon.etl src="${MyEtlFile}">
> <model ref="${SourceName}" as="Source"/>
> <model ref="${TargetModel}" as="Target"/>
> </epsilon.etl>
>
> From within the ETL file I can transform the source metamodel items
> into (e.g.) instances of Thing and Foo via:
> rule aRule1
> transform itemIn : Source!SourceType1
> to itemOut : Target!Thing {
> itemOut.name := itemIn.name;
> }
> And
> rule aRule2
> transform itemIn : Source!SourceType2
> to itemOut : Target!Foo {
> itemOut.name := itemIn.name;
> }
>
> Hence, I can access the classes within my metamodel structure via
> Target!<myClass>. However, if I try to access the enumeration literals
> of BarType in a similar fashion:
> rule aNewRule2
> transform itemIn : Source!SourceType2
> to itemOut : Target!Foo {
> itemOut.name := itemIn.name;
> itemOut.bar := itemIn.bar.transformInBarToOutBar();
> }
> operation String transformInBarToOutBar() {
> if (self = 'T') {
> return Target!BarType#T;
> } else if (self = 'NT') {
> return Target!BarType#NT;
> } else {
> throw 'Error';
> }
> }
>
> Then it does not appear possible to access BarType via Target!BarType,
> even though I can access Foo via Target!Foo and they're both in the same
> namespace. ETL reports that it cannot find the enumeration literal
> BarType#T. How should I access BarType such that I can assign the
> relevant enumeration literal to the slot foo.bar?
>
> Is there an error in my code or is this a bug in ETL?
>
> Regards
> Chris
Re: Accessing Enum Literals from ETL [message #526043 is a reply to message #525354] Thu, 08 April 2010 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi Dimitris,
I've created a simple example which demonstrates that, whilst access to
classes appears to work consistently from any package in the hierarchy,
one appears only to be able to access enumerations defined in the
outermost package only. Please let me know which of your e-mail
addresses you would like me to use.

Best Wishes
Chris

Dimitris Kolovos wrote:
> Hi Chris,
>
> At a first glance your code looks fine. Could you possibly put together
> a minimal running example that reproduces this so that I can have a
> closer look at this?
>
> Cheers,
> Dimitris
>
> On 06/04/2010 13:08, Chris Holmes wrote:
>> Hi,
>> I am transforming an instance of metamodel A into metamodel B using ETL
>> under the control of Ant.
>>
>> Metamodel A is auto-generated from the relevant XML schema, Metamodel B
>> is specified in a single Emfatic file and has the following structure:
>>
>> @namespace (blah)
>> package Parent;
>> import "Stuff";
>> class Thing extends Stuff.Other {
>> attr String name = "";
>> }
>> @namespace (blah/Parent)
>> package Child {
>> class Foo {
>> attr String name = "";
>> attr BarType bar = "T";
>> }
>> enum BarType {
>> T = 0;
>> NT = 1;
>> }
>> }
>>
>> I invoke the transformation 'Tx.etl' using
>> <property name="TargetFile" value="dirSpecForOutputFile"/>
>> <property name="TargetModelUri" value="aUrl"/>
>> <property name="TargetModel" value="Parent"/>
>> ...
>> <epsilon.loadModel name="${TargetModel}" type="EMF">
>> <parameter name="modelFile" file="${TargetFile}"/>
>> <parameter name="metamodelUri" value="${TargetModelUri}"/>
>> <parameter name="readOnLoad" value="true"/>
>> <parameter name="storeOnDisposal" value="true"/>
>> </epsilon.loadModel>
>> ...
>> <epsilon.etl src="${MyEtlFile}">
>> <model ref="${SourceName}" as="Source"/>
>> <model ref="${TargetModel}" as="Target"/>
>> </epsilon.etl>
>>
>> From within the ETL file I can transform the source metamodel items
>> into (e.g.) instances of Thing and Foo via:
>> rule aRule1
>> transform itemIn : Source!SourceType1
>> to itemOut : Target!Thing {
>> itemOut.name := itemIn.name;
>> }
>> And
>> rule aRule2
>> transform itemIn : Source!SourceType2
>> to itemOut : Target!Foo {
>> itemOut.name := itemIn.name;
>> }
>>
>> Hence, I can access the classes within my metamodel structure via
>> Target!<myClass>. However, if I try to access the enumeration literals
>> of BarType in a similar fashion:
>> rule aNewRule2
>> transform itemIn : Source!SourceType2
>> to itemOut : Target!Foo {
>> itemOut.name := itemIn.name;
>> itemOut.bar := itemIn.bar.transformInBarToOutBar();
>> }
>> operation String transformInBarToOutBar() {
>> if (self = 'T') {
>> return Target!BarType#T;
>> } else if (self = 'NT') {
>> return Target!BarType#NT;
>> } else {
>> throw 'Error';
>> }
>> }
>>
>> Then it does not appear possible to access BarType via Target!BarType,
>> even though I can access Foo via Target!Foo and they're both in the same
>> namespace. ETL reports that it cannot find the enumeration literal
>> BarType#T. How should I access BarType such that I can assign the
>> relevant enumeration literal to the slot foo.bar?
>>
>> Is there an error in my code or is this a bug in ETL?
>>
>> Regards
>> Chris
>
Re: Accessing Enum Literals from ETL [message #526252 is a reply to message #526043] Fri, 09 April 2010 11:28 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
To summarize the offline discussion, this was a bug indeed
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=308627) and has now been
fixed in the SVN and in the latest interim release (0.8.8.201004091412).

Cheers,
Dimitris

On 08/04/2010 18:06, Chris Holmes wrote:
> Hi Dimitris,
> I've created a simple example which demonstrates that, whilst access to
> classes appears to work consistently from any package in the hierarchy,
> one appears only to be able to access enumerations defined in the
> outermost package only. Please let me know which of your e-mail
> addresses you would like me to use.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> At a first glance your code looks fine. Could you possibly put
>> together a minimal running example that reproduces this so that I can
>> have a closer look at this?
>>
>> Cheers,
>> Dimitris
>>
>> On 06/04/2010 13:08, Chris Holmes wrote:
>>> Hi,
>>> I am transforming an instance of metamodel A into metamodel B using ETL
>>> under the control of Ant.
>>>
>>> Metamodel A is auto-generated from the relevant XML schema, Metamodel B
>>> is specified in a single Emfatic file and has the following structure:
>>>
>>> @namespace (blah)
>>> package Parent;
>>> import "Stuff";
>>> class Thing extends Stuff.Other {
>>> attr String name = "";
>>> }
>>> @namespace (blah/Parent)
>>> package Child {
>>> class Foo {
>>> attr String name = "";
>>> attr BarType bar = "T";
>>> }
>>> enum BarType {
>>> T = 0;
>>> NT = 1;
>>> }
>>> }
>>>
>>> I invoke the transformation 'Tx.etl' using
>>> <property name="TargetFile" value="dirSpecForOutputFile"/>
>>> <property name="TargetModelUri" value="aUrl"/>
>>> <property name="TargetModel" value="Parent"/>
>>> ...
>>> <epsilon.loadModel name="${TargetModel}" type="EMF">
>>> <parameter name="modelFile" file="${TargetFile}"/>
>>> <parameter name="metamodelUri" value="${TargetModelUri}"/>
>>> <parameter name="readOnLoad" value="true"/>
>>> <parameter name="storeOnDisposal" value="true"/>
>>> </epsilon.loadModel>
>>> ...
>>> <epsilon.etl src="${MyEtlFile}">
>>> <model ref="${SourceName}" as="Source"/>
>>> <model ref="${TargetModel}" as="Target"/>
>>> </epsilon.etl>
>>>
>>> From within the ETL file I can transform the source metamodel items
>>> into (e.g.) instances of Thing and Foo via:
>>> rule aRule1
>>> transform itemIn : Source!SourceType1
>>> to itemOut : Target!Thing {
>>> itemOut.name := itemIn.name;
>>> }
>>> And
>>> rule aRule2
>>> transform itemIn : Source!SourceType2
>>> to itemOut : Target!Foo {
>>> itemOut.name := itemIn.name;
>>> }
>>>
>>> Hence, I can access the classes within my metamodel structure via
>>> Target!<myClass>. However, if I try to access the enumeration literals
>>> of BarType in a similar fashion:
>>> rule aNewRule2
>>> transform itemIn : Source!SourceType2
>>> to itemOut : Target!Foo {
>>> itemOut.name := itemIn.name;
>>> itemOut.bar := itemIn.bar.transformInBarToOutBar();
>>> }
>>> operation String transformInBarToOutBar() {
>>> if (self = 'T') {
>>> return Target!BarType#T;
>>> } else if (self = 'NT') {
>>> return Target!BarType#NT;
>>> } else {
>>> throw 'Error';
>>> }
>>> }
>>>
>>> Then it does not appear possible to access BarType via Target!BarType,
>>> even though I can access Foo via Target!Foo and they're both in the same
>>> namespace. ETL reports that it cannot find the enumeration literal
>>> BarType#T. How should I access BarType such that I can assign the
>>> relevant enumeration literal to the slot foo.bar?
>>>
>>> Is there an error in my code or is this a bug in ETL?
>>>
>>> Regards
>>> Chris
>>
Re: Accessing Enum Literals from ETL [message #588223 is a reply to message #526043] Fri, 09 April 2010 11:28 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
To summarize the offline discussion, this was a bug indeed
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=308627) and has now been
fixed in the SVN and in the latest interim release (0.8.8.201004091412).

Cheers,
Dimitris

On 08/04/2010 18:06, Chris Holmes wrote:
> Hi Dimitris,
> I've created a simple example which demonstrates that, whilst access to
> classes appears to work consistently from any package in the hierarchy,
> one appears only to be able to access enumerations defined in the
> outermost package only. Please let me know which of your e-mail
> addresses you would like me to use.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> At a first glance your code looks fine. Could you possibly put
>> together a minimal running example that reproduces this so that I can
>> have a closer look at this?
>>
>> Cheers,
>> Dimitris
>>
>> On 06/04/2010 13:08, Chris Holmes wrote:
>>> Hi,
>>> I am transforming an instance of metamodel A into metamodel B using ETL
>>> under the control of Ant.
>>>
>>> Metamodel A is auto-generated from the relevant XML schema, Metamodel B
>>> is specified in a single Emfatic file and has the following structure:
>>>
>>> @namespace (blah)
>>> package Parent;
>>> import "Stuff";
>>> class Thing extends Stuff.Other {
>>> attr String name = "";
>>> }
>>> @namespace (blah/Parent)
>>> package Child {
>>> class Foo {
>>> attr String name = "";
>>> attr BarType bar = "T";
>>> }
>>> enum BarType {
>>> T = 0;
>>> NT = 1;
>>> }
>>> }
>>>
>>> I invoke the transformation 'Tx.etl' using
>>> <property name="TargetFile" value="dirSpecForOutputFile"/>
>>> <property name="TargetModelUri" value="aUrl"/>
>>> <property name="TargetModel" value="Parent"/>
>>> ...
>>> <epsilon.loadModel name="${TargetModel}" type="EMF">
>>> <parameter name="modelFile" file="${TargetFile}"/>
>>> <parameter name="metamodelUri" value="${TargetModelUri}"/>
>>> <parameter name="readOnLoad" value="true"/>
>>> <parameter name="storeOnDisposal" value="true"/>
>>> </epsilon.loadModel>
>>> ...
>>> <epsilon.etl src="${MyEtlFile}">
>>> <model ref="${SourceName}" as="Source"/>
>>> <model ref="${TargetModel}" as="Target"/>
>>> </epsilon.etl>
>>>
>>> From within the ETL file I can transform the source metamodel items
>>> into (e.g.) instances of Thing and Foo via:
>>> rule aRule1
>>> transform itemIn : Source!SourceType1
>>> to itemOut : Target!Thing {
>>> itemOut.name := itemIn.name;
>>> }
>>> And
>>> rule aRule2
>>> transform itemIn : Source!SourceType2
>>> to itemOut : Target!Foo {
>>> itemOut.name := itemIn.name;
>>> }
>>>
>>> Hence, I can access the classes within my metamodel structure via
>>> Target!<myClass>. However, if I try to access the enumeration literals
>>> of BarType in a similar fashion:
>>> rule aNewRule2
>>> transform itemIn : Source!SourceType2
>>> to itemOut : Target!Foo {
>>> itemOut.name := itemIn.name;
>>> itemOut.bar := itemIn.bar.transformInBarToOutBar();
>>> }
>>> operation String transformInBarToOutBar() {
>>> if (self = 'T') {
>>> return Target!BarType#T;
>>> } else if (self = 'NT') {
>>> return Target!BarType#NT;
>>> } else {
>>> throw 'Error';
>>> }
>>> }
>>>
>>> Then it does not appear possible to access BarType via Target!BarType,
>>> even though I can access Foo via Target!Foo and they're both in the same
>>> namespace. ETL reports that it cannot find the enumeration literal
>>> BarType#T. How should I access BarType such that I can assign the
>>> relevant enumeration literal to the slot foo.bar?
>>>
>>> Is there an error in my code or is this a bug in ETL?
>>>
>>> Regards
>>> Chris
>>
Previous Topic:Accessing Enum Literals from ETL
Next Topic:Passing Parameters into ETL from Ant
Goto Forum:
  


Current Time: Thu Mar 28 17:11:59 GMT 2024

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

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

Back to the top