Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » validate enumartion litrerals ocl
validate enumartion litrerals ocl [message #71825] Tue, 14 July 2009 14:51 Go to next message
Szymon is currently offline SzymonFriend
Messages: 6
Registered: July 2009
Junior Member
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
Re: validate enumartion litrerals ocl [message #71844 is a reply to message #71825] Tue, 14 July 2009 17:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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
>
Re: validate enumartion litrerals ocl [message #71919 is a reply to message #71844] Wed, 15 July 2009 07:37 Go to previous messageGo to next message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
Registered: July 2009
Senior Member
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
>>
Re: validate enumartion litrerals ocl [message #71938 is a reply to message #71919] Wed, 15 July 2009 09:21 Go to previous messageGo to next message
Szymon is currently offline SzymonFriend
Messages: 6
Registered: July 2009
Junior Member
thank yo for help. It works fine.
Szymon
Re: validate enumartion litrerals ocl [message #71956 is a reply to message #71919] Wed, 15 July 2009 09:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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
Re: validate enumartion litrerals ocl [message #72014 is a reply to message #71956] Wed, 15 July 2009 17:00 Go to previous messageGo to next message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
Registered: July 2009
Senior Member
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
Re: validate enumartion litrerals ocl [message #72032 is a reply to message #72014] Wed, 15 July 2009 17:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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
>
>
Re: validate enumartion litrerals ocl [message #72050 is a reply to message #72032] Wed, 15 July 2009 17:51 Go to previous message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
Registered: July 2009
Senior Member
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
>>
>>
Previous Topic:exclusion among attributes of different types
Next Topic:Generating code with OCL constraints etc.. in it
Goto Forum:
  


Current Time: Thu Apr 25 20:39:49 GMT 2024

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

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

Back to the top