Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Error detail
Error detail [message #808909] Tue, 28 February 2012 04:26 Go to next message
Capi Tali is currently offline Capi Tali
Messages: 38
Registered: February 2012
Member
Hi all,
I use
Diagnostic dia = Diagnostician.INSTANCE.validate(eObject);
to get the validation result of an object. However, using the getMessage method of Diagnostic class only gives me a fixed error message (like "constraint violcation occured at the element //@elem.0). Now that my question is how to get the full information of the element at which the violation occured, for example, the name or properties of that element?
Sorry if I repost a raised question but I tried to find the answer without any result.
Best regards.
Re: Error detail [message #808926 is a reply to message #808909] Tue, 28 February 2012 04:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

See
http://help.eclipse.org/indigo/topic/org.eclipse.ocl.doc/help/Integration.html?path=44_1_7_1#Integration-Messages

Regards

Ed Willink

On 28/02/2012 09:26, Capi Tali wrote:
> Hi all,
> I use Diagnostic dia = Diagnostician.INSTANCE.validate(eObject); to
> get the validation result of an object. However, using the getMessage
> method of Diagnostic class only gives me a fixed error message (like
> "constraint violcation occured at the element //@elem.0). Now that my
> question is how to get the full information of the element at which
> the violation occured, for example, the name or properties of that
> element? Sorry if I repost a raised question but I tried to find the
> answer without any result. Best regards.
Re: Error detail [message #809066 is a reply to message #808926] Tue, 28 February 2012 07:54 Go to previous messageGo to next message
Capi Tali is currently offline Capi Tali
Messages: 38
Registered: February 2012
Member
Hi Ed,
Firstly, thank you for your answer. In the tutorial I see "This must be activated explicitly using an EValidator that is aware of the ValidationDelegateExtension extended API". I understand this as we have to activate the customization support within the EMF generated code. My problem is that in my application, the metamodel and its models are generated which means that I only have an ECORE meta-model without the EMF generated code for it. I wonder how we can deal with this situation? I try to register the Validator in a triggered event before the metamodel is generated but nothing happened.
Best regards.
Re: Error detail [message #809081 is a reply to message #809066] Tue, 28 February 2012 08:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

EMF model generation uses JMerge to preserve user customisations so you
can just do:

/**
* <!-- begin-user-doc -->
* The <b>Validator</b> for the model.
* @extends
org.eclipse.ocl.examples.xtext.oclinecore.validation.OCLinEcoreEObjectValidator
* <!-- end-user-doc -->
* @see company.CompanyPackage
*/
public class CompanyValidator extends OCLinEcoreEObjectValidator {

The Help Documentation is wrong; update in progress. There is no need
for @generate NOT; just an @extends within the user-doc section.

Regards

Ed Willink



On 28/02/2012 12:54, Capi Tali wrote:
> Hi Ed,
> Firstly, thank you for your answer. In the tutorial I see "This must
> be activated explicitly using an EValidator that is aware of the
> ValidationDelegateExtension extended API". I understand this as we
> have to activate the customization support within the EMF generated
> code. My problem is that in my application, the metamodel and its
> models are generated which means that I only have an ECORE meta-model
> without the EMF generated code for it. I wonder how we can deal with
> this situation? I try to register the Validator in a triggered event
> before the metamodel is generated but nothing happened. Best regards.
Re: Error detail [message #809137 is a reply to message #809081] Tue, 28 February 2012 09:16 Go to previous messageGo to next message
Capi Tali is currently offline Capi Tali
Messages: 38
Registered: February 2012
Member
Hi Ed,
Maybe you didn't understand my poor explanation. I have an ECORE metamodel embedded with OCL rule without EMF generated code. Is there anyway to register the OCLinEcoreEObjectValidator in order to modify the validation message?
Re: Error detail [message #809156 is a reply to message #809137] Tue, 28 February 2012 09:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

The documentation says:

Unfortunately, in the Indigo release, EMF does not support this
customization and so must be activated by explicitly using an EValidator
that is aware of the ValidationDelegateExtension extended API. This is
available by using the OCLinEcoreEObjectValidator, which you may install
globally by:

|EValidator.Registry.INSTANCE.put(null, new OCLinEcoreEObjectValidator());
|

Doesn't this work? Once you start validating debug where your EValidator
came from.

Regards

Ed Willink

On 28/02/2012 14:16, Capi Tali wrote:
> Hi Ed,
> Maybe you didn't understand my poor explanation. I have an ECORE
> metamodel embedded with OCL rule without EMF generated code. Is there
> anyway to register the OCLinEcoreEObjectValidator in order to modify
> the validation message?
Re: Error detail [message #809166 is a reply to message #809156] Tue, 28 February 2012 09:58 Go to previous message
Capi Tali is currently offline Capi Tali
Messages: 38
Registered: February 2012
Member
Hi Ed,
It works perfectly when I put the registration code before the validation method. Many thanks for your help. Have a nice day.
Previous Topic:OCL for Extended ECORE model
Next Topic:Creating variable in OCL
Goto Forum:
  


Current Time: Tue Jul 22 03:38:18 EDT 2014

Powered by FUDForum. Page generated in 0.05009 seconds