Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Explicit invocation of ETL rule
Explicit invocation of ETL rule [message #581621] Thu, 08 October 2009 10:41
Eclipse User
Originally posted by: c.k.holmes.lboro.ac.uk

Dear All,
I have two transformation rules of the form:

rule LogAttributesType2LogAttributesSwitchType
transform logAtts1 : Source!LOGATTRIBUTESType
to switchType : Target!LogAttributesSwitchType {
guard : logAtts1.type = Source!LogAttType#CODE and
logAtts1.codeType = Source!CodeType#SWITCH
'LogAttributesType2LogAttributesSwitchType'.println();
--<blah/>
switchType.switchValues := logAtts1.cODEVAL.collect(v |
v.transformCodeVal2SwitchVal());
}

rule LogAttributesType2LogAttributesEnumType
transform logAtts1 : Source!LOGATTRIBUTESType
to enumType : Target!LogAttributesEnumType {
guard : logAtts1.type = Source!LogAttType#CODE and
logAtts1.codeType = Source!CodeType#ENUM
'LogAttributesType2LogAttributesEnumType'.println();
--<blah/>
enumType.enumeratedValues := logAtts1.cODEVAL.collect(v |
v.transformCodeVal2EnumVal());
}

The 'cODEVAL' attribute on the source class is the same in both cases,
however I want to apply different transformation rules to this attribute
depending of which transformation is currently being invoked.

I have defined the two transformation operations as:

operation Source!CODEVALType transformCodeVal2EnumVal() : Target!EnumVal {
var result : Target!EnumVal;
'transformCodeVal2EnumVal'.println();
(self.eClass().name).println();
result.value := self.value;
result.meaning := self.meaning;
return result;
}

operation Source!CODEVALType transformCodeVal2SwitchVal() :
Target!SwitchVal {
var result : Target!SwitchVal;
'transformCodeVal2SwitchVal'.println();
(self.eClass().name).println();
result.value := self.value;
result.meaning := self.meaning;
return result;
}

The execution trace shows the following error message:
transformCodeType2LogAttCodeType
transformCodeVal2EnumVal
CODEVALType
EXCEPTION: Called feature value on undefined object
(C:\EclipseWorkspaces\Blah\MyTransformation.etl@lineNo)

The appropriate transformation operation has been invoked
(transformCodeVal2EnumVal), and self is of the expected type
(CODEVALType), however it appears to suggest that the receiver (self) is
undefined when I try to access one of the attributes.

Using the following 'generic' transformation runs without throwing an
error (although it doesn't provide me with the flexibility of specifying
when to return an EnumVal object and when to return a SwitchVal object):

rule CodeVal2EnumVal
transform cv1 : Source!CODEVALType
to ev2 : Target!EnumVal {
ev2.value := cv1.value;
ev2.meaning := cv1.meaning;
}

So I guess I have two questions:
1. Why does self.eClass().name return the expected type (CODEVALType),
and yet on the very next line when I try to access self.value does self
appear to be undefined?
2. Is there an easier way to achieve the explicit invocation of one rule
from another?

Best Wishes
Chris
Previous Topic:Visibility of link when i click group element in the diagram
Next Topic:Null Pointer Exception when invoking .asOrderedSet in EOL query
Goto Forum:
  


Current Time: Sat Oct 25 03:35:42 GMT 2014

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

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