Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Error detail
Error detail [message #808909] Tue, 28 February 2012 09:26 Go to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
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 09:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 12:54 Go to previous messageGo to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
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 13:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 14:16 Go to previous messageGo to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
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 14:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 14:58 Go to previous message
MinhTu TonThat is currently offline MinhTu TonThatFriend
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: Thu Apr 18 03:48:05 GMT 2024

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

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

Back to the top