OCLinEcore: Custom validation messages not working [message #1700726] |
Mon, 06 July 2015 16:48 |
Matthias Freund Messages: 8 Registered: May 2014 |
Junior Member |
|
|
Hi all,
I am currently trying to realize custom OCL validation messages by means of the 'OCLinEcoreTutorial' but so far have not been successful. I have performed the following steps:
- Set the following OCL preferences
- Executor targeted by the default OCL delegate: ".../Pivot"
- Realisation of OCL embedded within Ecore models: "Generate Java Code in *Impl classes"
- Create the OCLinEcoreTutorial example
- Open the 'Tutorial.ecore' with the OCLinEcore editor
- Change the 'SufficientCopies' invariant of the 'Books' class as described here
- Generate the model code by means of the genmodel
- Make the generated 'TutorialValidator' extend the 'OCLinEcoreEObjectValidator'
- Run the generated model code
- Create a new model and validate it (with the 'Sample Reflective Ecore Model Editor')
When I validate the model, I always get the default error message (The 'SufficientCopies' constraint is violated ...) instead of the custom error message.
Did I miss anything or does this seem to be a bug? I tried to debug this myself and found that the correct error message seems to be assembled inside the 'SufficientCopies(...)' method of class 'BookImpl'. It is stored in a variable called 'TupleValue'. However, this does not seem to be passed to 'CGStringLogDiagnosticOperation.INSTANCE.evaluate(...)':
...
final /*@NonNull*/ /*@Thrown*/ TupleValue symbol_0 = ValueUtil.createTupleOfEach(TutorialTables.TUPLid_, sum_4, le_0);
final /*@NonInvalid*/ boolean status = (Boolean)symbol_0.getValue(1/*status*/);
final /*@NonInvalid*/ boolean logDiagnostic = ClassUtil.nonNullState(CGStringLogDiagnosticOperation.INSTANCE.evaluate(evaluator, TypeId.BOOLEAN, TutorialTables.STR_Book_c_c_SufficientCopies, this, diagnostics, context, severity_0, status, TutorialTables.INT_0).booleanValue());
Thanks in advance for any help!
Kind regards
Matthias
|
|
|
Re: OCLinEcore: Custom validation messages not working [message #1700730 is a reply to message #1700726] |
Mon, 06 July 2015 17:06 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
HI
Oops.
CGStringLogDiagnosticOperation was a late addition to support
configurable severities for safe navigation. I can easily understand how
it breaks the code as you have described. However I'm surprised that no
JUnit test detected the breakage. I'm also puzzled that I missed the
regression while reviewing all the tutorials for Mars.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=471948 raised.
Regards
Ed Willink
On 06/07/2015 17:48, Matthias Freund wrote:
> Hi all,
>
> I am currently trying to realize custom OCL validation messages by
> means of the 'OCLinEcoreTutorial' but so far have not been successful.
> I have performed the following steps:
>
>
> Set the following OCL preferences
>
> Executor targeted by the default OCL delegate: ".../Pivot"
> Realisation of OCL embedded within Ecore models: "Generate Java Code
> in *Impl classes" Create the OCLinEcoreTutorial example
> Open the 'Tutorial.ecore' with the OCLinEcore editor
> Change the 'SufficientCopies' invariant of the 'Books' class as
> described
> http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FIntegration.html
> Generate the model code by means of the genmodel
> Make the generated 'TutorialValidator' extend the
> 'OCLinEcoreEObjectValidator'
> Run the generated model code
> Create a new model and validate it (with the 'Sample Reflective Ecore
> Model Editor')
>
> When I validate the model, I always get the default error message (The
> 'SufficientCopies' constraint is violated ...) instead of the custom
> error message.
>
> Did I miss anything or does this seem to be a bug? I tried to debug
> this myself and found that the correct error message seems to be
> assembled inside the 'SufficientCopies(...)' method of class
> 'BookImpl'. It is stored in a variable called 'TupleValue'. However,
> this does not seem to be passed to
> 'CGStringLogDiagnosticOperation.INSTANCE.evaluate(...)':
>
>
> ..
> final /*@NonNull*/ /*@Thrown*/ TupleValue symbol_0 =
> ValueUtil.createTupleOfEach(TutorialTables.TUPLid_, sum_4, le_0);
> final /*@NonInvalid*/ boolean status =
> (Boolean)symbol_0.getValue(1/*status*/);
> final /*@NonInvalid*/ boolean logDiagnostic =
> ClassUtil.nonNullState(CGStringLogDiagnosticOperation.INSTANCE.evaluate(evaluator,
> TypeId.BOOLEAN, TutorialTables.STR_Book_c_c_SufficientCopies, this,
> diagnostics, context, severity_0, status,
> TutorialTables.INT_0).booleanValue());
>
>
> Thanks in advance for any help!
>
> Kind regards
> Matthias
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02084 seconds