I created a model and within it an enumeration E with two properties e1
and e2.
In this model I created a class C with a property c1 of type E.
I would like to check if the value of the c1 is e1 or e2 using an ocl
constraint defined in the plugin.xml file (like in the OCL Validation
Constraints Tutorial).
Expression applied to C class
self.c1 = 'e1'
returns an error.
Any idea how I can compare a property against the value of an Enumeration?
What would be the ocl syntax in my example?
The correct OCL syntax for an enumeration literal is E::e1 not 'e1', so try
self.c1 = E::e1
Regards
Ed Willink
Szymon wrote:
> Hi,
>
> I created a model and within it an enumeration E with two properties e1
> and e2.
> In this model I created a class C with a property c1 of type E.
> I would like to check if the value of the c1 is e1 or e2 using an ocl
> constraint defined in the plugin.xml file (like in the OCL Validation
> Constraints Tutorial).
> Expression applied to C class
> self.c1 = 'e1'
> returns an error.
> Any idea how I can compare a property against the value of an
> Enumeration? What would be the ocl syntax in my example?
>
> thank you for help.
> Szymon
>
The only way I got this type of constraint to work in my application was
to use this syntax:
self.c1 = #E::e1
I am using OCL 1.2.3 under Eclipse Ganymede.
Thanks,
JT
Ed Willink wrote:
> Hi Szymon
> The correct OCL syntax for an enumeration literal is E::e1 not 'e1', so try
> self.c1 = E::e1
> Regards
> Ed Willink
> Szymon wrote:
>> Hi,
>>
>> I created a model and within it an enumeration E with two properties e1
>> and e2.
>> In this model I created a class C with a property c1 of type E.
>> I would like to check if the value of the c1 is e1 or e2 using an ocl
>> constraint defined in the plugin.xml file (like in the OCL Validation
>> Constraints Tutorial).
>> Expression applied to C class
>> self.c1 = 'e1'
>> returns an error.
>> Any idea how I can compare a property against the value of an
>> Enumeration? What would be the ocl syntax in my example?
>>
>> thank you for help.
>> Szymon
>>
John T.E. Timm wrote:
> The only way I got this type of constraint to work in my application was
> to use this syntax:
>
> self.c1 = #E::e1
>
> I am using OCL 1.2.3 under Eclipse Ganymede.
I find this very difficult to understand. Using MDT-OCL 1.3.0 on Galileo
(and I don't think anything has changed here) and the RoyalAndLoyal.ocl
example from org.eclipse.qvt.declarative.examples.ocl.royalandloyal.
The constraint:
Search the sources the # character is only used as a fragment separator
in comment hyper links and as a miscellaneous string character, so I
cannot understand how you get something tyo work by using it.
Please submit a full 'working' example using # as a Bugzilla.
I have a minimal working example using the '#' under OCL 1.2.3. I will
submit a bugzilla.
Thanks,
JT
Ed Willink wrote:
> John T.E. Timm wrote:
>> The only way I got this type of constraint to work in my application was
>> to use this syntax:
>>
>> self.c1 = #E::e1
>>
>> I am using OCL 1.2.3 under Eclipse Ganymede.
> I find this very difficult to understand. Using MDT-OCL 1.3.0 on Galileo
> (and I don't think anything has changed here) and the RoyalAndLoyal.ocl
> example from org.eclipse.qvt.declarative.examples.ocl.royalandloyal.
> The constraint:
> Search the sources the # character is only used as a fragment separator
> in comment hyper links and as a miscellaneous string character, so I
> cannot understand how you get something tyo work by using it.
> Please submit a full 'working' example using # as a Bugzilla.
Thanks for providing your source. It is an example of an informal guide
that when accurate is very helpful. Unfortunately it contains many
errors, so I would recommend not consulting it further. Buy the Warmer
and Kleppe book; it's very readable.
It appears that the current MDT-OCL is working correctly. The only issue
is whether the previous release temporarily supported an obsolete
syntax. Since the current release correctly rejects #, there is little
point raising a bugzilla that I instantly reject as INVALID.
Regards
Ed Willink
John T.E. Timm wrote:
> The older version of OCL, appears to have supported the '#' in front of
> an enum literal name:
>
> http://www.csci.csusb.edu/dick/samples/ocl.html#Grammar
>
> I have a minimal working example using the '#' under OCL 1.2.3. I will
> submit a bugzilla.
>
> Thanks,
>
> JT
>
> Ed Willink wrote:
>
>> John T.E. Timm wrote:
>>> The only way I got this type of constraint to work in my application
>>> was to use this syntax:
>>>
>>> self.c1 = #E::e1
>>>
>>> I am using OCL 1.2.3 under Eclipse Ganymede.
>
>> I find this very difficult to understand. Using MDT-OCL 1.3.0 on Galileo
>> (and I don't think anything has changed here) and the RoyalAndLoyal.ocl
>> example from org.eclipse.qvt.declarative.examples.ocl.royalandloyal.
>> The constraint:
>
>> inv invariant_Customer7 :
>> (self.gender = Gender::male) implies self.title = 'Mr.'
>
>> works fine, but fails if Gender::male is misspelled or #-prefixed.
>> (The error message for the #-prefix needs improvement -
>> raised as https://bugs.eclipse.org/bugs/show_bug.cgi?id=283509).
>
>> Search the sources the # character is only used as a fragment separator
>> in comment hyper links and as a miscellaneous string character, so I
>> cannot understand how you get something tyo work by using it.
>
>> Please submit a full 'working' example using # as a Bugzilla.
>
>> Regards
>
>> Ed Willink
>
>
Thank you for the feedback and your recommended book. I will check it out.
JT
Ed Willink wrote:
> Hi John
> Thanks for providing your source. It is an example of an informal guide
> that when accurate is very helpful. Unfortunately it contains many
> errors, so I would recommend not consulting it further. Buy the Warmer
> and Kleppe book; it's very readable.
> It appears that the current MDT-OCL is working correctly. The only issue
> is whether the previous release temporarily supported an obsolete
> syntax. Since the current release correctly rejects #, there is little
> point raising a bugzilla that I instantly reject as INVALID.
> Regards
> Ed Willink
> John T.E. Timm wrote:
>> The older version of OCL, appears to have supported the '#' in front of
>> an enum literal name:
>>
>> http://www.csci.csusb.edu/dick/samples/ocl.html#Grammar
>>
>> I have a minimal working example using the '#' under OCL 1.2.3. I will
>> submit a bugzilla.
>>
>> Thanks,
>>
>> JT
>>
>> Ed Willink wrote:
>>
>>> John T.E. Timm wrote:
>>>> The only way I got this type of constraint to work in my application
>>>> was to use this syntax:
>>>>
>>>> self.c1 = #E::e1
>>>>
>>>> I am using OCL 1.2.3 under Eclipse Ganymede.
>>
>>> I find this very difficult to understand. Using MDT-OCL 1.3.0 on Galileo
>>> (and I don't think anything has changed here) and the RoyalAndLoyal.ocl
>>> example from org.eclipse.qvt.declarative.examples.ocl.royalandloyal.
>>> The constraint:
>>
>>> inv invariant_Customer7 :
>>> (self.gender = Gender::male) implies self.title = 'Mr.'
>>
>>> works fine, but fails if Gender::male is misspelled or #-prefixed.
>>> (The error message for the #-prefix needs improvement -
>>> raised as https://bugs.eclipse.org/bugs/show_bug.cgi?id=283509).
>>
>>> Search the sources the # character is only used as a fragment separator
>>> in comment hyper links and as a miscellaneous string character, so I
>>> cannot understand how you get something tyo work by using it.
>>
>>> Please submit a full 'working' example using # as a Bugzilla.
>>
>>> Regards
>>
>>> Ed Willink
>>
>>