Custom OCL messages [message #1460384] |
Mon, 03 November 2014 14:10 |
Eclipse User |
|
|
|
Hi,
I am trying to use custom OCL messages, but have no success.
I have checked this thread: https://www.eclipse.org/forums/index.php/t/392067/ (as I understood this issue were resolved in releases after indigo).
My invariant:
invariant nonEmptyType('Type must be any non-empty'): self.type->notEmpty();
But my generated validator does not use my custom messages and I am getting standard message:
Constraint is violated for .... ...
I am using luna release. How I can fix this?
|
|
|
|
Re: Custom OCL messages [message #1461274 is a reply to message #1460422] |
Tue, 04 November 2014 11:45 |
Eclipse User |
|
|
|
Hi,
I followed next tutorials for OCLinEcore: first, second. But where is no any information about custom messages.
I found interesting paragraph in OCLin syntax doc:
Quote:A class invariant optionally supports a second OCL expression as a parenthesis on the invariant name. This parenthesized expression is invoked when an invariant fails in order to provide a user-defined failure message. Whether this message is an error or a warning is determined by the evaluation of the invariant:
But it is meaning is not clear for me because my custom message from first message in this thread are not working with generated java code.
|
|
|
|
Re: Custom OCL messages [message #1462090 is a reply to message #1461309] |
Wed, 05 November 2014 07:34 |
Eclipse User |
|
|
|
Thanks for response. But I still could not find way how to use custom error messages. Documentation looks weird for me.
Link
Quote:invariant SufficientCopies('There are ' + library.loans->select((book = self))->size().toString() + ' loans for the ' + copies.toString() + ' copies of \'' + name + '\''):
library.loans->select((book = self))->size() <= copies;
Unfortunately, in the Indigo release, EMF does not support this customization. This must be activated explicitly using an EValidator that is aware of the ValidationDelegateExtension extended API. This is available by using the OCLinEcoreEObjectValidator.
I have tried this syntax, but have no success. I am using Luna and I don't need any manually modifications.
But I also tried to use OCLinEcoreEObjectValidator.java class and my invariants could not be found, because it's using some annotations on eOperation:
String expression = EcoreUtil.getAnnotation(eOperation, validationDelegate, "body");
But I am using java generated code for invariants and there is no any annotations on operation.
Can I find anywhere stable example and/or tutorial?
[Updated on: Wed, 05 November 2014 07:41] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02405 seconds