Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Carl on April 15, 2014, 12:00:14 am

Title: OCL Validation Warning
Post by: Carl on April 15, 2014, 12:00:14 am
Hi,

I have an OCL constraint defined as follows on a class.  When I save the constraint, I get the message "OCL Validation Successful".

inv: rating >= 0

Where rating is an int attribute of the class BlogEntry.

However, when I validate a diagram containing the class and run Model > Validate Selected, I get the following warning.

MVR040001 - warning (BlogEntry (Class)): OCL violation: inv: rating >= 0      

Does anyone know if this is a bug?  I've also experimented with "self" (which isn't required) and gotten the same results.

Thanks
Title: Re: OCL Validation Warning
Post by: Frank Crow on April 15, 2014, 09:31:33 am
What a coincidence!   I just finished reading the book on OCL and was trying to implement some constraints.   I get the same exact thing.   When I save the constraint, if it is legitimate OCL syntax it does say "OCL validation successful" and if I violate the syntax, I get an error message.   But then when I do Project->Validate Selected... I get the same as thing you are getting.   A *warning* that says "OCL violation" (MVR040001) which the EA help says "The element violates the OCL constraint specified."   I am using a very simple constraint, I'm not even sure how EA thinks that the expression is true/false either way.  It is not like I'm giving it any values for the attributes!

Very confusing!   Any help is highly appreciated!

Thanks,
Frank
Title: Re: OCL Validation Warning
Post by: Aaron B on April 15, 2014, 10:34:09 am
Try restarting EA and then run the OCL validation again.  Does the same error still get reported?
Title: Re: OCL Validation Warning
Post by: Frank Crow on April 15, 2014, 11:14:57 am
Restarted EA and still get the same thing.

thanks,
Frank
Title: Re: OCL Validation Warning
Post by: qwerty on April 15, 2014, 07:04:49 pm
From what I remember EA never executed any OCL but only validated the OCL syntax. That might have changed over the last versions, though.

q.
Title: Re: OCL Validation Warning
Post by: Carl on April 15, 2014, 11:19:16 pm
The OCL syntax looks fine to me.  I have an "inv:" leading off the expression.  I've tried "rating >= 0" and "self.rating >= 0".  Moreover, I get the "successful" message when I save the expression in the Properties Dialog.

It's the Model Validation function that I'm asking about.
Title: Re: OCL Validation Warning
Post by: Frank Crow on April 16, 2014, 12:25:21 pm
Same here!

Thanks,
Frank
Title: Re: OCL Validation Warning
Post by: qwerty on April 16, 2014, 07:05:18 pm
So you should probably send a bug report (bottom right of the page).

q.