[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.mdt.uml2.ocl] Re: OCL: Exception and unexpected evaluation result when accessing the enum property of a stereotype

Hi, Andy,

I suspect that what is happening is that the OCL parser is "seeing" two
different representations of the same enumeration CIM_InheritanceRule:  one
as the type of the CIM_QualifierType::InheritanceRule property, and another
as the type of the enumeration literal expression
TestProfile2::CIM_InheritanceRule::ToSubclass.

Because these are two distinct enumerations, their literals would never be
considered equal.

If you send me your test project, I could confirm this in the debugger (or,
you could, too: just compare the object IDs of the 'type' properties of the
PropertyCallExp and EnumerationLiteralExp sub-expressions of the Test1
constraint).  This looks like a bug in RSA's UML support for OCL, possibly
not correctly accounting for multiple references to the same enumeration
literal in a different model/profile than the context of the constraint.

HTH,

Christian


Andreas Maier wrote:

> Hi,
> I have an unexpected behavior for an OCL statement that accesses the
> enum property of a stereotype. The stereotype extends the property of
> another stereotype.
> 
> The scenario looks as follows:
> 
> Profile TestProfile2, which
>    owns Stereotype CIM_QualifierType, which
>      extends Property;
>      owns Enumeration CIM_InheritanceRule, which
>        defines Literals Restricted and ToSubclass;
>      owns Property InheritanceRule, which
>        is of type CIM_InheritanceRule;
>      owns Constraint Test1 in OCL;
>      owns Constraint Test2 in OCL;
> 
> Profile TestProfile, which
>    extends TestProfile2;
>    owns Stereotype CIM_Class, which
>      owns Property QualifierR, which
>        has applied stereotype CIM_QualifierType
>          whose InheritanceRule = Restricted;
>      owns Property QualifierT, which
>        has applied stereotype CIM_QualifierType
>          whose InheritanceRule = ToSubclass;
> 
> Model TestModel, which
>    extends TestProfile;
>    owns Class Class1, which
>      has applied Stereotype CIM_Class;
> 
> 
> The OCL constraints are supposed to access the InheritanceRule property,
> and for the sake of simplicity they just test for a particular value,
> let's say equality to the enum literal ToSubclass.
> 
> 
> OCL constraint Test1 looks as follows:
> 
>    self.InheritanceRule
>      = TestProfile2::CIM_InheritanceRule::ToSubclass
> 
> It parses successfully, but when executed, it raises the exception:
> 
> "Nonconforming arguments for type (CIM_InheritanceRule) and operation
> (=)."
> 
> -> What is wrong with this OCL statement to warrant this exception ?
> 
> 
> OCL constraint Test2 overcomes this exception by using a type cast and
> looks as follows:
> 
>    self.InheritanceRule.oclAsType(TestProfile2::CIM_InheritanceRule)
>      = TestProfile2::CIM_InheritanceRule::ToSubclass
> 
> It parses successfully (the OCL editor even properly offers both enum
> literals as choices in its syntax popup when entering the second colon
> after CIM_InheritanceRule), it also executes without exception, but when
> validating the profile TestProfile, it evaluates to false in both
> CIM_Class stereotype properties, even though one of them has a value of
> ToSubclass.
> 
> -> Why does this test not reveal the intended result (i.e. true on
> QualifierT, false on QualifierR)?
> 
> -> How can I test the InheritanceRule property values so that it works ?
> 
> 
> I have this scenario in a small test project for RSA, which I can send
> if needed.
> 
> Andy