Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » ETL transformations involving enumerations
ETL transformations involving enumerations [message #488492] Mon, 28 September 2009 21:27 Go to next message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hello All,
How does one map enumerations in ETL?

E.G. I have a source model auto-generated from an XML schema of the form:
SIGNALType
secClass : SecClassType
<more attributes/>

SecClassType
RED = 0
GREEN = 1

I have a target model defined in Emfatic of the form:
class Signal {
attr SigSecClassType secClass = "GREEN";
<more attributes/>
}

enum SigSecClassType {
RED = 0;
GREEN = 1;
}

I want to define a transformation rule to map objects of type SIGNALType
to objects of type Signal such that:
Target!s.secClass := Source!s.secClass

How should the ETL be expressed?
rule SignalType2Signal
transform sig1 : Source!SIGNALType
to sig2 : Target!Signal {
'SignalType2Signal'.println();
sig2.name := sig1.name;
sig2.secClass := sig1.secClass;
<blah/>
}

Suppose for some bizarre reason I wanted to transform the enumeration
literal values such that Source!SigSecClassType#GREEN mapped to
Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
Target!SigSecClassType#GREEN; how would I express this in the ETL?

Best Wishes
Chris
Re: ETL transformations involving enumerations [message #488498 is a reply to message #488492] Mon, 28 September 2009 22:49 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

Enumeration literals are not objects and therefore you cannot define a
rule to transform between them. However you can use an operation like
the following

operation Any transformSigSecClassType() {
if (self = Source!SigSecClassType#GREEN) {
return Target!SigSecClassType#RED;
}
else {
return Target!SigSecClassType#GREEN;
}
}

(Ideally instead of Any, as context you should be able to specify
Source!SigSecClassType but enumerations are not valid contexts for EOL
operations)

Cheers,
Dimitris

Chris Holmes wrote:
> Hello All,
> How does one map enumerations in ETL?
>
> E.G. I have a source model auto-generated from an XML schema of the form:
> SIGNALType
> secClass : SecClassType
> <more attributes/>
>
> SecClassType
> RED = 0
> GREEN = 1
>
> I have a target model defined in Emfatic of the form:
> class Signal {
> attr SigSecClassType secClass = "GREEN";
> <more attributes/>
> }
>
> enum SigSecClassType {
> RED = 0;
> GREEN = 1;
> }
>
> I want to define a transformation rule to map objects of type SIGNALType
> to objects of type Signal such that:
> Target!s.secClass := Source!s.secClass
>
> How should the ETL be expressed?
> rule SignalType2Signal
> transform sig1 : Source!SIGNALType
> to sig2 : Target!Signal {
> 'SignalType2Signal'.println();
> sig2.name := sig1.name;
> sig2.secClass := sig1.secClass;
> <blah/>
> }
>
> Suppose for some bizarre reason I wanted to transform the enumeration
> literal values such that Source!SigSecClassType#GREEN mapped to
> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>
> Best Wishes
> Chris
Re: ETL transformations involving enumerations [message #488523 is a reply to message #488498] Tue, 29 September 2009 06:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi Dimitris,
Thanks for the reply. Would it be possible to access the source/target
enumeration literals by index? e.g.
Source!SecClass
RED // I assume this would have the default value 0
AMBER // 1?
GREEN // 2?

Target!enum SigSecClassType {
RED = 0;
AMBER = 1;
GREEN = 2;
}

If the mapping is simply:
Source!SecClass#RED => Target!SigSecClassType#RED
Source!SecClass#AMBER => Target!SigSecClassType#AMBER
Source!SecClass#GREEN => Target!SigSecClassType#GREEN

Then it would be more concise if I were to be able to define:
operation Nay transformSigSecClassType() : Integer {
return self.<how do I access the index of the enumeration literal?>
}

rule SignalType2Signal
transform sig1 : Source!SIGNALType
to sig2 : Target!Signal {
'SignalType2Signal'.println();
sig2.name := sig1.name;
sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
<blah/>
}

If this is possible, what is the syntax?

Best Wishes
Chris

Dimitris Kolovos wrote:
> Hi Chris,
>
> Enumeration literals are not objects and therefore you cannot define a
> rule to transform between them. However you can use an operation like
> the following
>
> operation Any transformSigSecClassType() {
> if (self = Source!SigSecClassType#GREEN) {
> return Target!SigSecClassType#RED;
> }
> else {
> return Target!SigSecClassType#GREEN;
> }
> }
>
> (Ideally instead of Any, as context you should be able to specify
> Source!SigSecClassType but enumerations are not valid contexts for EOL
> operations)
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hello All,
>> How does one map enumerations in ETL?
>>
>> E.G. I have a source model auto-generated from an XML schema of the form:
>> SIGNALType
>> secClass : SecClassType
>> <more attributes/>
>>
>> SecClassType
>> RED = 0
>> GREEN = 1
>>
>> I have a target model defined in Emfatic of the form:
>> class Signal {
>> attr SigSecClassType secClass = "GREEN";
>> <more attributes/>
>> }
>>
>> enum SigSecClassType {
>> RED = 0;
>> GREEN = 1;
>> }
>>
>> I want to define a transformation rule to map objects of type
>> SIGNALType to objects of type Signal such that:
>> Target!s.secClass := Source!s.secClass
>>
>> How should the ETL be expressed?
>> rule SignalType2Signal
>> transform sig1 : Source!SIGNALType
>> to sig2 : Target!Signal {
>> 'SignalType2Signal'.println();
>> sig2.name := sig1.name;
>> sig2.secClass := sig1.secClass;
>> <blah/>
>> }
>>
>> Suppose for some bizarre reason I wanted to transform the enumeration
>> literal values such that Source!SigSecClassType#GREEN mapped to
>> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
>> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>>
>> Best Wishes
>> Chris
Re: ETL transformations involving enumerations [message #488545 is a reply to message #488523] Tue, 29 September 2009 08:29 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

This is not possible I'm afraid. Could you please add an enhancement
request in the bugzilla so that we can keep track of this?

Cheers,
Dimitris

Chris Holmes wrote:
> Hi Dimitris,
> Thanks for the reply. Would it be possible to access the source/target
> enumeration literals by index? e.g.
> Source!SecClass
> RED // I assume this would have the default value 0
> AMBER // 1?
> GREEN // 2?
>
> Target!enum SigSecClassType {
> RED = 0;
> AMBER = 1;
> GREEN = 2;
> }
>
> If the mapping is simply:
> Source!SecClass#RED => Target!SigSecClassType#RED
> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>
> Then it would be more concise if I were to be able to define:
> operation Nay transformSigSecClassType() : Integer {
> return self.<how do I access the index of the enumeration literal?>
> }
>
> rule SignalType2Signal
> transform sig1 : Source!SIGNALType
> to sig2 : Target!Signal {
> 'SignalType2Signal'.println();
> sig2.name := sig1.name;
> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
> <blah/>
> }
>
> If this is possible, what is the syntax?
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> Enumeration literals are not objects and therefore you cannot define a
>> rule to transform between them. However you can use an operation like
>> the following
>>
>> operation Any transformSigSecClassType() {
>> if (self = Source!SigSecClassType#GREEN) {
>> return Target!SigSecClassType#RED;
>> }
>> else {
>> return Target!SigSecClassType#GREEN;
>> }
>> }
>>
>> (Ideally instead of Any, as context you should be able to specify
>> Source!SigSecClassType but enumerations are not valid contexts for EOL
>> operations)
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hello All,
>>> How does one map enumerations in ETL?
>>>
>>> E.G. I have a source model auto-generated from an XML schema of the
>>> form:
>>> SIGNALType
>>> secClass : SecClassType
>>> <more attributes/>
>>>
>>> SecClassType
>>> RED = 0
>>> GREEN = 1
>>>
>>> I have a target model defined in Emfatic of the form:
>>> class Signal {
>>> attr SigSecClassType secClass = "GREEN";
>>> <more attributes/>
>>> }
>>>
>>> enum SigSecClassType {
>>> RED = 0;
>>> GREEN = 1;
>>> }
>>>
>>> I want to define a transformation rule to map objects of type
>>> SIGNALType to objects of type Signal such that:
>>> Target!s.secClass := Source!s.secClass
>>>
>>> How should the ETL be expressed?
>>> rule SignalType2Signal
>>> transform sig1 : Source!SIGNALType
>>> to sig2 : Target!Signal {
>>> 'SignalType2Signal'.println();
>>> sig2.name := sig1.name;
>>> sig2.secClass := sig1.secClass;
>>> <blah/>
>>> }
>>>
>>> Suppose for some bizarre reason I wanted to transform the enumeration
>>> literal values such that Source!SigSecClassType#GREEN mapped to
>>> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
>>> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>>>
>>> Best Wishes
>>> Chris
Re: ETL transformations involving enumerations [message #488549 is a reply to message #488545] Tue, 29 September 2009 08:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi Dimitris,
OK, will do.

BTW what's the return type of the operation:
operation Any transformSigSecClassType() {
if (self = Source!SigSecClassType#GREEN) {
return Target!SigSecClassType#RED;
}
else {
return Target!SigSecClassType#GREEN;
}
}

i.e. what's the type of Target!SigSecClassType#<anyValidEnumLit>?

Best Wishes
Chris

Dimitris Kolovos wrote:
> Hi Chris,
>
> This is not possible I'm afraid. Could you please add an enhancement
> request in the bugzilla so that we can keep track of this?
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hi Dimitris,
>> Thanks for the reply. Would it be possible to access the source/target
>> enumeration literals by index? e.g.
>> Source!SecClass
>> RED // I assume this would have the default value 0
>> AMBER // 1?
>> GREEN // 2?
>>
>> Target!enum SigSecClassType {
>> RED = 0;
>> AMBER = 1;
>> GREEN = 2; }
>>
>> If the mapping is simply:
>> Source!SecClass#RED => Target!SigSecClassType#RED
>> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
>> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>>
>> Then it would be more concise if I were to be able to define:
>> operation Nay transformSigSecClassType() : Integer {
>> return self.<how do I access the index of the enumeration literal?>
>> }
>>
>> rule SignalType2Signal
>> transform sig1 : Source!SIGNALType
>> to sig2 : Target!Signal {
>> 'SignalType2Signal'.println();
>> sig2.name := sig1.name;
>> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
>> <blah/>
>> }
>>
>> If this is possible, what is the syntax?
>>
>> Best Wishes
>> Chris
>>
>> Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> Enumeration literals are not objects and therefore you cannot define
>>> a rule to transform between them. However you can use an operation
>>> like the following
>>>
>>> operation Any transformSigSecClassType() {
>>> if (self = Source!SigSecClassType#GREEN) {
>>> return Target!SigSecClassType#RED;
>>> }
>>> else {
>>> return Target!SigSecClassType#GREEN;
>>> }
>>> }
>>>
>>> (Ideally instead of Any, as context you should be able to specify
>>> Source!SigSecClassType but enumerations are not valid contexts for
>>> EOL operations)
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hello All,
>>>> How does one map enumerations in ETL?
>>>>
>>>> E.G. I have a source model auto-generated from an XML schema of the
>>>> form:
>>>> SIGNALType
>>>> secClass : SecClassType
>>>> <more attributes/>
>>>>
>>>> SecClassType
>>>> RED = 0
>>>> GREEN = 1
>>>>
>>>> I have a target model defined in Emfatic of the form:
>>>> class Signal {
>>>> attr SigSecClassType secClass = "GREEN";
>>>> <more attributes/>
>>>> }
>>>>
>>>> enum SigSecClassType {
>>>> RED = 0;
>>>> GREEN = 1;
>>>> }
>>>>
>>>> I want to define a transformation rule to map objects of type
>>>> SIGNALType to objects of type Signal such that:
>>>> Target!s.secClass := Source!s.secClass
>>>>
>>>> How should the ETL be expressed?
>>>> rule SignalType2Signal
>>>> transform sig1 : Source!SIGNALType
>>>> to sig2 : Target!Signal {
>>>> 'SignalType2Signal'.println();
>>>> sig2.name := sig1.name;
>>>> sig2.secClass := sig1.secClass;
>>>> <blah/>
>>>> }
>>>>
>>>> Suppose for some bizarre reason I wanted to transform the
>>>> enumeration literal values such that Source!SigSecClassType#GREEN
>>>> mapped to Target!SigSecClassType#RED, and Source!SigSecClassType#RED
>>>> mapped to Target!SigSecClassType#GREEN; how would I express this in
>>>> the ETL?
>>>>
>>>> Best Wishes
>>>> Chris
Re: ETL transformations involving enumerations [message #488568 is a reply to message #488549] Tue, 29 September 2009 09:31 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

The return type should be Any as well (again ideally it should be
Target!SigSecClassType but this is not supported in EOL)

Cheers,
Dimitris

Chris Holmes wrote:
> Hi Dimitris,
> OK, will do.
>
> BTW what's the return type of the operation:
> operation Any transformSigSecClassType() {
> if (self = Source!SigSecClassType#GREEN) {
> return Target!SigSecClassType#RED;
> }
> else {
> return Target!SigSecClassType#GREEN;
> }
> }
>
> i.e. what's the type of Target!SigSecClassType#<anyValidEnumLit>?
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is not possible I'm afraid. Could you please add an enhancement
>> request in the bugzilla so that we can keep track of this?
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hi Dimitris,
>>> Thanks for the reply. Would it be possible to access the
>>> source/target enumeration literals by index? e.g.
>>> Source!SecClass
>>> RED // I assume this would have the default value 0
>>> AMBER // 1?
>>> GREEN // 2?
>>>
>>> Target!enum SigSecClassType {
>>> RED = 0;
>>> AMBER = 1;
>>> GREEN = 2; }
>>>
>>> If the mapping is simply:
>>> Source!SecClass#RED => Target!SigSecClassType#RED
>>> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
>>> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>>>
>>> Then it would be more concise if I were to be able to define:
>>> operation Nay transformSigSecClassType() : Integer {
>>> return self.<how do I access the index of the enumeration literal?>
>>> }
>>>
>>> rule SignalType2Signal
>>> transform sig1 : Source!SIGNALType
>>> to sig2 : Target!Signal {
>>> 'SignalType2Signal'.println();
>>> sig2.name := sig1.name;
>>> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
>>> <blah/>
>>> }
>>>
>>> If this is possible, what is the syntax?
>>>
>>> Best Wishes
>>> Chris
>>>
>>> Dimitris Kolovos wrote:
>>>> Hi Chris,
>>>>
>>>> Enumeration literals are not objects and therefore you cannot define
>>>> a rule to transform between them. However you can use an operation
>>>> like the following
>>>>
>>>> operation Any transformSigSecClassType() {
>>>> if (self = Source!SigSecClassType#GREEN) {
>>>> return Target!SigSecClassType#RED;
>>>> }
>>>> else {
>>>> return Target!SigSecClassType#GREEN;
>>>> }
>>>> }
>>>>
>>>> (Ideally instead of Any, as context you should be able to specify
>>>> Source!SigSecClassType but enumerations are not valid contexts for
>>>> EOL operations)
>>>>
>>>> Cheers,
>>>> Dimitris
>>>>
>>>> Chris Holmes wrote:
>>>>> Hello All,
>>>>> How does one map enumerations in ETL?
>>>>>
>>>>> E.G. I have a source model auto-generated from an XML schema of the
>>>>> form:
>>>>> SIGNALType
>>>>> secClass : SecClassType
>>>>> <more attributes/>
>>>>>
>>>>> SecClassType
>>>>> RED = 0
>>>>> GREEN = 1
>>>>>
>>>>> I have a target model defined in Emfatic of the form:
>>>>> class Signal {
>>>>> attr SigSecClassType secClass = "GREEN";
>>>>> <more attributes/>
>>>>> }
>>>>>
>>>>> enum SigSecClassType {
>>>>> RED = 0;
>>>>> GREEN = 1;
>>>>> }
>>>>>
>>>>> I want to define a transformation rule to map objects of type
>>>>> SIGNALType to objects of type Signal such that:
>>>>> Target!s.secClass := Source!s.secClass
>>>>>
>>>>> How should the ETL be expressed?
>>>>> rule SignalType2Signal
>>>>> transform sig1 : Source!SIGNALType
>>>>> to sig2 : Target!Signal {
>>>>> 'SignalType2Signal'.println();
>>>>> sig2.name := sig1.name;
>>>>> sig2.secClass := sig1.secClass;
>>>>> <blah/>
>>>>> }
>>>>>
>>>>> Suppose for some bizarre reason I wanted to transform the
>>>>> enumeration literal values such that Source!SigSecClassType#GREEN
>>>>> mapped to Target!SigSecClassType#RED, and
>>>>> Source!SigSecClassType#RED mapped to Target!SigSecClassType#GREEN;
>>>>> how would I express this in the ETL?
>>>>>
>>>>> Best Wishes
>>>>> Chris


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Re: ETL transformations involving enumerations [message #581110 is a reply to message #488492] Mon, 28 September 2009 22:49 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

Enumeration literals are not objects and therefore you cannot define a
rule to transform between them. However you can use an operation like
the following

operation Any transformSigSecClassType() {
if (self = Source!SigSecClassType#GREEN) {
return Target!SigSecClassType#RED;
}
else {
return Target!SigSecClassType#GREEN;
}
}

(Ideally instead of Any, as context you should be able to specify
Source!SigSecClassType but enumerations are not valid contexts for EOL
operations)

Cheers,
Dimitris

Chris Holmes wrote:
> Hello All,
> How does one map enumerations in ETL?
>
> E.G. I have a source model auto-generated from an XML schema of the form:
> SIGNALType
> secClass : SecClassType
> <more attributes/>
>
> SecClassType
> RED = 0
> GREEN = 1
>
> I have a target model defined in Emfatic of the form:
> class Signal {
> attr SigSecClassType secClass = "GREEN";
> <more attributes/>
> }
>
> enum SigSecClassType {
> RED = 0;
> GREEN = 1;
> }
>
> I want to define a transformation rule to map objects of type SIGNALType
> to objects of type Signal such that:
> Target!s.secClass := Source!s.secClass
>
> How should the ETL be expressed?
> rule SignalType2Signal
> transform sig1 : Source!SIGNALType
> to sig2 : Target!Signal {
> 'SignalType2Signal'.println();
> sig2.name := sig1.name;
> sig2.secClass := sig1.secClass;
> <blah/>
> }
>
> Suppose for some bizarre reason I wanted to transform the enumeration
> literal values such that Source!SigSecClassType#GREEN mapped to
> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>
> Best Wishes
> Chris
Re: ETL transformations involving enumerations [message #581137 is a reply to message #488498] Tue, 29 September 2009 06:28 Go to previous message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi Dimitris,
Thanks for the reply. Would it be possible to access the source/target
enumeration literals by index? e.g.
Source!SecClass
RED // I assume this would have the default value 0
AMBER // 1?
GREEN // 2?

Target!enum SigSecClassType {
RED = 0;
AMBER = 1;
GREEN = 2;
}

If the mapping is simply:
Source!SecClass#RED => Target!SigSecClassType#RED
Source!SecClass#AMBER => Target!SigSecClassType#AMBER
Source!SecClass#GREEN => Target!SigSecClassType#GREEN

Then it would be more concise if I were to be able to define:
operation Nay transformSigSecClassType() : Integer {
return self.<how do I access the index of the enumeration literal?>
}

rule SignalType2Signal
transform sig1 : Source!SIGNALType
to sig2 : Target!Signal {
'SignalType2Signal'.println();
sig2.name := sig1.name;
sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
<blah/>
}

If this is possible, what is the syntax?

Best Wishes
Chris

Dimitris Kolovos wrote:
> Hi Chris,
>
> Enumeration literals are not objects and therefore you cannot define a
> rule to transform between them. However you can use an operation like
> the following
>
> operation Any transformSigSecClassType() {
> if (self = Source!SigSecClassType#GREEN) {
> return Target!SigSecClassType#RED;
> }
> else {
> return Target!SigSecClassType#GREEN;
> }
> }
>
> (Ideally instead of Any, as context you should be able to specify
> Source!SigSecClassType but enumerations are not valid contexts for EOL
> operations)
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hello All,
>> How does one map enumerations in ETL?
>>
>> E.G. I have a source model auto-generated from an XML schema of the form:
>> SIGNALType
>> secClass : SecClassType
>> <more attributes/>
>>
>> SecClassType
>> RED = 0
>> GREEN = 1
>>
>> I have a target model defined in Emfatic of the form:
>> class Signal {
>> attr SigSecClassType secClass = "GREEN";
>> <more attributes/>
>> }
>>
>> enum SigSecClassType {
>> RED = 0;
>> GREEN = 1;
>> }
>>
>> I want to define a transformation rule to map objects of type
>> SIGNALType to objects of type Signal such that:
>> Target!s.secClass := Source!s.secClass
>>
>> How should the ETL be expressed?
>> rule SignalType2Signal
>> transform sig1 : Source!SIGNALType
>> to sig2 : Target!Signal {
>> 'SignalType2Signal'.println();
>> sig2.name := sig1.name;
>> sig2.secClass := sig1.secClass;
>> <blah/>
>> }
>>
>> Suppose for some bizarre reason I wanted to transform the enumeration
>> literal values such that Source!SigSecClassType#GREEN mapped to
>> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
>> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>>
>> Best Wishes
>> Chris
Re: ETL transformations involving enumerations [message #581154 is a reply to message #488523] Tue, 29 September 2009 08:29 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

This is not possible I'm afraid. Could you please add an enhancement
request in the bugzilla so that we can keep track of this?

Cheers,
Dimitris

Chris Holmes wrote:
> Hi Dimitris,
> Thanks for the reply. Would it be possible to access the source/target
> enumeration literals by index? e.g.
> Source!SecClass
> RED // I assume this would have the default value 0
> AMBER // 1?
> GREEN // 2?
>
> Target!enum SigSecClassType {
> RED = 0;
> AMBER = 1;
> GREEN = 2;
> }
>
> If the mapping is simply:
> Source!SecClass#RED => Target!SigSecClassType#RED
> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>
> Then it would be more concise if I were to be able to define:
> operation Nay transformSigSecClassType() : Integer {
> return self.<how do I access the index of the enumeration literal?>
> }
>
> rule SignalType2Signal
> transform sig1 : Source!SIGNALType
> to sig2 : Target!Signal {
> 'SignalType2Signal'.println();
> sig2.name := sig1.name;
> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
> <blah/>
> }
>
> If this is possible, what is the syntax?
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> Enumeration literals are not objects and therefore you cannot define a
>> rule to transform between them. However you can use an operation like
>> the following
>>
>> operation Any transformSigSecClassType() {
>> if (self = Source!SigSecClassType#GREEN) {
>> return Target!SigSecClassType#RED;
>> }
>> else {
>> return Target!SigSecClassType#GREEN;
>> }
>> }
>>
>> (Ideally instead of Any, as context you should be able to specify
>> Source!SigSecClassType but enumerations are not valid contexts for EOL
>> operations)
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hello All,
>>> How does one map enumerations in ETL?
>>>
>>> E.G. I have a source model auto-generated from an XML schema of the
>>> form:
>>> SIGNALType
>>> secClass : SecClassType
>>> <more attributes/>
>>>
>>> SecClassType
>>> RED = 0
>>> GREEN = 1
>>>
>>> I have a target model defined in Emfatic of the form:
>>> class Signal {
>>> attr SigSecClassType secClass = "GREEN";
>>> <more attributes/>
>>> }
>>>
>>> enum SigSecClassType {
>>> RED = 0;
>>> GREEN = 1;
>>> }
>>>
>>> I want to define a transformation rule to map objects of type
>>> SIGNALType to objects of type Signal such that:
>>> Target!s.secClass := Source!s.secClass
>>>
>>> How should the ETL be expressed?
>>> rule SignalType2Signal
>>> transform sig1 : Source!SIGNALType
>>> to sig2 : Target!Signal {
>>> 'SignalType2Signal'.println();
>>> sig2.name := sig1.name;
>>> sig2.secClass := sig1.secClass;
>>> <blah/>
>>> }
>>>
>>> Suppose for some bizarre reason I wanted to transform the enumeration
>>> literal values such that Source!SigSecClassType#GREEN mapped to
>>> Target!SigSecClassType#RED, and Source!SigSecClassType#RED mapped to
>>> Target!SigSecClassType#GREEN; how would I express this in the ETL?
>>>
>>> Best Wishes
>>> Chris
Re: ETL transformations involving enumerations [message #581175 is a reply to message #488545] Tue, 29 September 2009 08:42 Go to previous message
Eclipse UserFriend
Originally posted by: c.k.holmes.lboro.ac.uk

Hi Dimitris,
OK, will do.

BTW what's the return type of the operation:
operation Any transformSigSecClassType() {
if (self = Source!SigSecClassType#GREEN) {
return Target!SigSecClassType#RED;
}
else {
return Target!SigSecClassType#GREEN;
}
}

i.e. what's the type of Target!SigSecClassType#<anyValidEnumLit>?

Best Wishes
Chris

Dimitris Kolovos wrote:
> Hi Chris,
>
> This is not possible I'm afraid. Could you please add an enhancement
> request in the bugzilla so that we can keep track of this?
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hi Dimitris,
>> Thanks for the reply. Would it be possible to access the source/target
>> enumeration literals by index? e.g.
>> Source!SecClass
>> RED // I assume this would have the default value 0
>> AMBER // 1?
>> GREEN // 2?
>>
>> Target!enum SigSecClassType {
>> RED = 0;
>> AMBER = 1;
>> GREEN = 2; }
>>
>> If the mapping is simply:
>> Source!SecClass#RED => Target!SigSecClassType#RED
>> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
>> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>>
>> Then it would be more concise if I were to be able to define:
>> operation Nay transformSigSecClassType() : Integer {
>> return self.<how do I access the index of the enumeration literal?>
>> }
>>
>> rule SignalType2Signal
>> transform sig1 : Source!SIGNALType
>> to sig2 : Target!Signal {
>> 'SignalType2Signal'.println();
>> sig2.name := sig1.name;
>> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
>> <blah/>
>> }
>>
>> If this is possible, what is the syntax?
>>
>> Best Wishes
>> Chris
>>
>> Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> Enumeration literals are not objects and therefore you cannot define
>>> a rule to transform between them. However you can use an operation
>>> like the following
>>>
>>> operation Any transformSigSecClassType() {
>>> if (self = Source!SigSecClassType#GREEN) {
>>> return Target!SigSecClassType#RED;
>>> }
>>> else {
>>> return Target!SigSecClassType#GREEN;
>>> }
>>> }
>>>
>>> (Ideally instead of Any, as context you should be able to specify
>>> Source!SigSecClassType but enumerations are not valid contexts for
>>> EOL operations)
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hello All,
>>>> How does one map enumerations in ETL?
>>>>
>>>> E.G. I have a source model auto-generated from an XML schema of the
>>>> form:
>>>> SIGNALType
>>>> secClass : SecClassType
>>>> <more attributes/>
>>>>
>>>> SecClassType
>>>> RED = 0
>>>> GREEN = 1
>>>>
>>>> I have a target model defined in Emfatic of the form:
>>>> class Signal {
>>>> attr SigSecClassType secClass = "GREEN";
>>>> <more attributes/>
>>>> }
>>>>
>>>> enum SigSecClassType {
>>>> RED = 0;
>>>> GREEN = 1;
>>>> }
>>>>
>>>> I want to define a transformation rule to map objects of type
>>>> SIGNALType to objects of type Signal such that:
>>>> Target!s.secClass := Source!s.secClass
>>>>
>>>> How should the ETL be expressed?
>>>> rule SignalType2Signal
>>>> transform sig1 : Source!SIGNALType
>>>> to sig2 : Target!Signal {
>>>> 'SignalType2Signal'.println();
>>>> sig2.name := sig1.name;
>>>> sig2.secClass := sig1.secClass;
>>>> <blah/>
>>>> }
>>>>
>>>> Suppose for some bizarre reason I wanted to transform the
>>>> enumeration literal values such that Source!SigSecClassType#GREEN
>>>> mapped to Target!SigSecClassType#RED, and Source!SigSecClassType#RED
>>>> mapped to Target!SigSecClassType#GREEN; how would I express this in
>>>> the ETL?
>>>>
>>>> Best Wishes
>>>> Chris
Re: ETL transformations involving enumerations [message #581190 is a reply to message #488549] Tue, 29 September 2009 09:31 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

The return type should be Any as well (again ideally it should be
Target!SigSecClassType but this is not supported in EOL)

Cheers,
Dimitris

Chris Holmes wrote:
> Hi Dimitris,
> OK, will do.
>
> BTW what's the return type of the operation:
> operation Any transformSigSecClassType() {
> if (self = Source!SigSecClassType#GREEN) {
> return Target!SigSecClassType#RED;
> }
> else {
> return Target!SigSecClassType#GREEN;
> }
> }
>
> i.e. what's the type of Target!SigSecClassType#<anyValidEnumLit>?
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is not possible I'm afraid. Could you please add an enhancement
>> request in the bugzilla so that we can keep track of this?
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hi Dimitris,
>>> Thanks for the reply. Would it be possible to access the
>>> source/target enumeration literals by index? e.g.
>>> Source!SecClass
>>> RED // I assume this would have the default value 0
>>> AMBER // 1?
>>> GREEN // 2?
>>>
>>> Target!enum SigSecClassType {
>>> RED = 0;
>>> AMBER = 1;
>>> GREEN = 2; }
>>>
>>> If the mapping is simply:
>>> Source!SecClass#RED => Target!SigSecClassType#RED
>>> Source!SecClass#AMBER => Target!SigSecClassType#AMBER
>>> Source!SecClass#GREEN => Target!SigSecClassType#GREEN
>>>
>>> Then it would be more concise if I were to be able to define:
>>> operation Nay transformSigSecClassType() : Integer {
>>> return self.<how do I access the index of the enumeration literal?>
>>> }
>>>
>>> rule SignalType2Signal
>>> transform sig1 : Source!SIGNALType
>>> to sig2 : Target!Signal {
>>> 'SignalType2Signal'.println();
>>> sig2.name := sig1.name;
>>> sig2.secClass.<attrib?> := sig1.secClasstransformSigSecClassType();
>>> <blah/>
>>> }
>>>
>>> If this is possible, what is the syntax?
>>>
>>> Best Wishes
>>> Chris
>>>
>>> Dimitris Kolovos wrote:
>>>> Hi Chris,
>>>>
>>>> Enumeration literals are not objects and therefore you cannot define
>>>> a rule to transform between them. However you can use an operation
>>>> like the following
>>>>
>>>> operation Any transformSigSecClassType() {
>>>> if (self = Source!SigSecClassType#GREEN) {
>>>> return Target!SigSecClassType#RED;
>>>> }
>>>> else {
>>>> return Target!SigSecClassType#GREEN;
>>>> }
>>>> }
>>>>
>>>> (Ideally instead of Any, as context you should be able to specify
>>>> Source!SigSecClassType but enumerations are not valid contexts for
>>>> EOL operations)
>>>>
>>>> Cheers,
>>>> Dimitris
>>>>
>>>> Chris Holmes wrote:
>>>>> Hello All,
>>>>> How does one map enumerations in ETL?
>>>>>
>>>>> E.G. I have a source model auto-generated from an XML schema of the
>>>>> form:
>>>>> SIGNALType
>>>>> secClass : SecClassType
>>>>> <more attributes/>
>>>>>
>>>>> SecClassType
>>>>> RED = 0
>>>>> GREEN = 1
>>>>>
>>>>> I have a target model defined in Emfatic of the form:
>>>>> class Signal {
>>>>> attr SigSecClassType secClass = "GREEN";
>>>>> <more attributes/>
>>>>> }
>>>>>
>>>>> enum SigSecClassType {
>>>>> RED = 0;
>>>>> GREEN = 1;
>>>>> }
>>>>>
>>>>> I want to define a transformation rule to map objects of type
>>>>> SIGNALType to objects of type Signal such that:
>>>>> Target!s.secClass := Source!s.secClass
>>>>>
>>>>> How should the ETL be expressed?
>>>>> rule SignalType2Signal
>>>>> transform sig1 : Source!SIGNALType
>>>>> to sig2 : Target!Signal {
>>>>> 'SignalType2Signal'.println();
>>>>> sig2.name := sig1.name;
>>>>> sig2.secClass := sig1.secClass;
>>>>> <blah/>
>>>>> }
>>>>>
>>>>> Suppose for some bizarre reason I wanted to transform the
>>>>> enumeration literal values such that Source!SigSecClassType#GREEN
>>>>> mapped to Target!SigSecClassType#RED, and
>>>>> Source!SigSecClassType#RED mapped to Target!SigSecClassType#GREEN;
>>>>> how would I express this in the ETL?
>>>>>
>>>>> Best Wishes
>>>>> Chris


--
Spread the word: http://www.eclipse.org/gmt/epsilon/spreadtheword
Follow Epsilon on Twitter: http://twitter.com/epsilonews
Previous Topic:ETL transformations involving enumerations
Next Topic:ETL: creation of arbitrary number of target traceable elements
Goto Forum:
  


Current Time: Sat Apr 20 01:36:34 GMT 2024

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

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

Back to the top