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

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