Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCLinEcore: Custom validation messages not working
OCLinEcore: Custom validation messages not working [message #1700726] Mon, 06 July 2015 16:48 Go to next message
Matthias Freund is currently offline Matthias FreundFriend
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:


  1. 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"
  2. Create the OCLinEcoreTutorial example
  3. Open the 'Tutorial.ecore' with the OCLinEcore editor
  4. Change the 'SufficientCopies' invariant of the 'Books' class as described here
  5. Generate the model code by means of the genmodel
  6. Make the generated 'TutorialValidator' extend the 'OCLinEcoreEObjectValidator'
  7. Run the generated model code
  8. 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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5885
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
Re: OCLinEcore: Custom validation messages not working [message #1700750 is a reply to message #1700730] Mon, 06 July 2015 19:10 Go to previous messageGo to next message
Matthias Freund is currently offline Matthias FreundFriend
Messages: 8
Registered: May 2014
Junior Member
Hi,

thanks for the quick response!

Kind regards
Matthias
Re: OCLinEcore: Custom validation messages not working [message #1700869 is a reply to message #1700750] Tue, 07 July 2015 18:21 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5885
Registered: July 2009
Senior Member
Hi

I hope that you find

http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.0.1/N201507071256/mdt-ocl-Update-N201507071256.zip

fixes the problem.

Regards

Ed Willink


On 06/07/2015 20:10, Matthias Freund wrote:
> Hi,
>
> thanks for the quick response!
>
> Kind regards
> Matthias
Re: OCLinEcore: Custom validation messages not working [message #1700930 is a reply to message #1700869] Wed, 08 July 2015 09:16 Go to previous message
Matthias Freund is currently offline Matthias FreundFriend
Messages: 8
Registered: May 2014
Junior Member
Hi,

thanks! Now it works... Smile

Kind regards
Matthias
Previous Topic:how to parse a text on a transition with OCL? is it possible ?
Next Topic:uml:Signal context for OCL constraint
Goto Forum:
  


Current Time: Tue May 22 06:31:29 GMT 2018

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

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

Back to the top