Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL constraints in Ecore problems view messages
OCL constraints in Ecore problems view messages [message #761633] Tue, 06 December 2011 19:24 Go to next message
giovi disanto is currently offline giovi disantoFriend
Messages: 58
Registered: September 2011
Member
Hi,
i've defined some ocl constraints in my ecore metamodel and validation works but i want to personalize errors message in problems view. there is a way to do this? or it's possible to have name of constraints with space character? For example a constraint named "mustHaveName" can appear in problems view as "must have name"?
Re: OCL constraints in Ecore problems view messages [message #761650 is a reply to message #761633] Tue, 06 December 2011 20:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes and Yes.

Arbitrary constraint names can be escaped as _'must have name'.

If you are using the Indigo release there is fair chance that you can
suffix a parenthesized string-valued expression to the invariant name
for evaluation on failure. See
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FIntegration.html.

Note that the custom message and severity are an Eclipse OCL extension.
I'm not entirely comfortable with the context communication between
primary constraint and secondary message. Something may well change
before it gets proposed for inclusion in OMG OCL.

Regards

Ed Willink


On 06/12/2011 19:24, giovi wrote:
> Hi,
> i've defined some ocl constraints in my ecore metamodel and validation
> works but i want to personalize errors message in problems view. there
> is a way to do this? or it's possible to have name of constraints with
> space character? For example a constraint named "mustHaveName" can
> appear in problems view as "must have name"?
Re: OCL constraints in Ecore problems view messages [message #761707 is a reply to message #761650] Tue, 06 December 2011 23:09 Go to previous messageGo to next message
giovi disanto is currently offline giovi disantoFriend
Messages: 58
Registered: September 2011
Member
Hi Ed!
Thanks for reply, it works but when i use customization message my errors became warnings, it's normal?
Re: OCL constraints in Ecore problems view messages [message #761869 is a reply to message #761707] Wed, 07 December 2011 07:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The severity is currently controlled by the return value of the invariant.

true => ok
false => warning
null => error
invalid => error and maybe stack trace

So you might want to define a helper

def: asError(status : Boolean) : Boolean = if status then status else
null endif

so that you can just do

inv Mine('mine'): asError(something)

Regards

Ed Willink


On 06/12/2011 23:09, giovi wrote:
> Hi Ed!
> Thanks for reply, it works but when i use customization message my
> errors became warnings, it's normal?
Re: OCL constraints in Ecore problems view messages [message #762583 is a reply to message #761869] Thu, 08 December 2011 10:40 Go to previous messageGo to next message
giovi disanto is currently offline giovi disantoFriend
Messages: 58
Registered: September 2011
Member
hi Edward,
Sorry for my incompetence but i can't understand where i have tu put helper you have suggested me. If i copy it in my ecore file with OClinEcore editor i receive an error...
For my validation i could only use static messages but if i use the escape character _'my message' i don't receive error but validator not use my ocl constraint and if i open Validator class i see there are a validation rule for all words in my message but without ocl expression, in this example for 'my' and 'message'
Re: OCL constraints in Ecore problems view messages [message #762590 is a reply to message #762583] Thu, 08 December 2011 10:51 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The example I gave was a def: which is a Complete OCL syntax that allows
meta-model extension.

If you're using OCLinEcore then you need to define an extra 'ordinary'
operation that is visible by inheritance or by delegation to the
invariant. (Ecore does not support static operations, so you have to
make the helper a non-static operation and provide some object as the
self of the operation.)

Regards

Ed Willink



On 08/12/2011 10:40, giovi wrote:
> hi Edward,
> Sorry for my incompetence but i can't understand where i have tu put
> helper you have suggested me. If i copy it in my ecore file with
> OClinEcore editor i receive an error...
> For my validation i could only use static messages but if i use the
> escape character _'my message' i don't receive error but validator not
> use my ocl constraint and if i open Validator class i see there are a
> validation rule for all words in my message but without ocl
> expression, in this example for 'my' and 'message'
Previous Topic:Run CompleteOCL Validation manually
Next Topic:How to access to attributes in other classes?
Goto Forum:
  


Current Time: Fri Apr 19 06:24:43 GMT 2024

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

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

Back to the top