Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Custom Validation Message & Severity(UML constraint)
Custom Validation Message & Severity [message #1090652] Tue, 20 August 2013 12:59 Go to next message
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi there,

I tried to add custom validation message and custom severity for constraints in UML2.

After reading this topic and the tutorial, I'm confused. If I well understood, it is not possible to customize validation message and severity for a UML constraint. Am I right ? Here is I have done:


  1. I desgigned a UML metamodel using the documentation available here.
  2. I added somes OCL contraints thanks to the UML element Constraint and OpaqueExpression
  3. I generated genmodel and ecore model from this point.
  4. I generated the model, edit, editor and test code. Constraints are well validated without customization.


Then, I tried several things :


  1. In my ecore generated file, I add for each Detail Entry of "OCL" EAnnotation whose key is "body" a second Detail Entry whose key is "body$message" and the provided message. Didn't do anything when the code is generated.
  2. I try to suffix the invariant name with the message between brackets, when opening the ecore model with OCLinEcore Editor. When I saved, close and re-open the OCLinEcore Editor, the suffix is disappeared.
  3. I tried to use the DSML Validation Profile from Papyrus. Didn't do anything.


If I well undestood, I can customize validation message from either OCLinEcore or CompleteOCL only for native Ecore model, but not for generated Ecore model from UML Metamodel. Is that true ?

Does anybody have a hook to use this ?


Thanks in advance,

yours,

--
Nicolas
Re: Custom Validation Message & Severity [message #1090674 is a reply to message #1090652] Tue, 20 August 2013 13:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Unfortunately the Bugzilla patch to enable EMF to support custom
validation messages remains uncommitted so you must use an
OCLinEcoreEObjectValidator as described in the documentation.

If you are losing Ecore content please submit a Bugzilla with a repro.

The OCLinEcore approach is inflexible and not extensible so I proposed
an approach based on a Tuple return, however that won't be in OCL 2.4
since it is an extension rather than a clarification. We will probably
pursue it for Eclipse OCL so that it works for UML too.

Regards

Ed Willink


On 20/08/2013 13:59, nicolas h wrote:
> Hi there,
>
> I tried to add custom validation message and custom severity for
> constraints in UML2.
>
> After reading
> http://www.eclipse.org/forums/index.php/m/30076/?srch=custom+validation+message#msg_30076
> and the
> http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FIntegration.html&cp=42_1_7_1&anchor=Integration-Messages.,
> I'm confused. If I well understood, it is not possible to customize
> validation message and severity for a UML constraint. Am I right ?
> Here is I have done:
>
>
> I desgigned a UML metamodel using the documentation available
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413.
> I added somes OCL contraints thanks to the UML element Constraint and
> OpaqueExpression
> I generated genmodel and ecore model from this point.
> I generated the model, edit, editor and test code. Constraints are
> well validated without customization.
>
>
> Then, I tried several things :
>
>
> In my ecore generated file, I add for each Detail Entry of "OCL"
> EAnnotation whose key is "body" a second Detail Entry whose key is
> "body$message" and the provided message. Didn't do anything when the
> code is generated.
> I try to suffix the invariant name with the message between brackets,
> when opening the ecore model with OCLinEcore Editor. When I saved,
> close and re-open the OCLinEcore Editor, the suffix is disappeared.
> I tried to use the DSML Validation Profile from Papyrus. Didn't do
> anything.
>
>
> If I well undestood, I can customize validation message from either
> OCLinEcore or CompleteOCL only for native Ecore model, but not for
> generated Ecore model from UML Metamodel. Is that true ?
>
> Does anybody have a hook to use this ?
>
>
> Thanks in advance,
>
> yours,
>
Re: Custom Validation Message & Severity [message #1090703 is a reply to message #1090674] Tue, 20 August 2013 14:21 Go to previous messageGo to next message
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi ed,

Thanks for your fast reply,

Ed Willink wrote on Tue, 20 August 2013 09:37
Hi

Unfortunately the Bugzilla patch to enable EMF to support custom
validation messages remains uncommitted so you must use an
OCLinEcoreEObjectValidator as described in the documentation.


I did not notice this part of the documentation. I'll try to understand how it's work.

Ed Willink wrote on Tue, 20 August 2013 09:37
If you are losing Ecore content please submit a Bugzilla with a repro.


Why do you mean about "losing Ecore content" ? Did you refer to the non-persistence of the invariant name when I open my Ecore model with OCLInEcore Editor ?

Ed Willink wrote on Tue, 20 August 2013 09:37
The OCLinEcore approach is inflexible and not extensible so I proposed
an approach based on a Tuple return, however that won't be in OCL 2.4
since it is an extension rather than a clarification. We will probably
pursue it for Eclipse OCL so that it works for UML too.


Yeah, I found your post (I no longer manage to lay hands on this post) about it but I did not understand how to implement this. I naively thought that I could replace inside my UML metamodel my opaque expression body, containing the OCL constraint, by the tuple, and get during the validation the different part of the constraint, but it seems not so easy Smile

--
Nicolas
Re: Custom Validation Message & Severity [message #1090708 is a reply to message #1090703] Tue, 20 August 2013 14:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi
On 20/08/2013 15:21, nicolas h wrote:
>> If you are losing Ecore content please submit a Bugzilla with a repro.
>
> Why do you mean about "losing Ecore content" ? Did you refer to the
> non-persistence of the invariant name when I open my Ecore model with
> OCLInEcore Editor ?
If you had something in your model and an editor discarded it without
your permission then we need to fix a bug.
> Ed Willink wrote on Tue, 20 August 2013 09:37
>> The OCLinEcore approach is inflexible and not extensible so I
>> proposed an approach based on a Tuple return, however that won't be
>> in OCL 2.4 since it is an extension rather than a clarification. We
>> will probably pursue it for Eclipse OCL so that it works for UML too.
> Yeah, I found your post (I no longer manage to lay hands on this post)
> about it but I did not understand how to implement this. I naively
> thought that I could replace inside my UML metamodel my opaque
> expression body, containing the OCL constraint, by the tuple, and get
> during the validation the different part of the constraint, but it
> seems not so easy :)
There is no point you using it until the underlying implementation is
there, which will probably happen in the next month in time for M2 and
an Eclipse OCL 4.2.0 release.

Regards

Ed Willink
Re: Custom Validation Message & Severity [message #1091394 is a reply to message #1090708] Wed, 21 August 2013 12:48 Go to previous message
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi,

Thanks for your fast reply,

Ed Willink wrote on Tue, 20 August 2013 10:29
>> If you are losing Ecore content please submit a Bugzilla with a repro.
>
> Why do you mean about "losing Ecore content" ? Did you refer to the
> non-persistence of the invariant name when I open my Ecore model with
> OCLInEcore Editor ?
If you had something in your model and an editor discarded it without
your permission then we need to fix a bug.

Done. I raised a bug in the Bugzilla here.

Ed Willink wrote on Tue, 20 August 2013 10:29
>> The OCLinEcore approach is inflexible and not extensible so I
>> proposed an approach based on a Tuple return, however that won't be
>> in OCL 2.4 since it is an extension rather than a clarification. We
>> will probably pursue it for Eclipse OCL so that it works for UML too.
> Yeah, I found your post (I no longer manage to lay hands on this post)
> about it but I did not understand how to implement this. I naively
> thought that I could replace inside my UML metamodel my opaque
> expression body, containing the OCL constraint, by the tuple, and get
> during the validation the different part of the constraint, but it
> seems not so easy Smile
There is no point you using it until the underlying implementation is
there, which will probably happen in the next month in time for M2 and
an Eclipse OCL 4.2.0 release.


Thanks for your answer. I'll wait for the OCL 4.2.0 release Wink

Regards,

--
Nicolas
Previous Topic:[Announce] Eclipse OCL 4.1.1 RC1 and OCL 4.2.0 M1 are available.
Next Topic:Eclipse OCL
Goto Forum:
  


Current Time: Tue Apr 23 07:23:05 GMT 2024

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

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

Back to the top