Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Validation Framework
Validation Framework [message #427146] Wed, 04 February 2009 11:40 Go to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

at the moment I try to work with the validation framework. I tried the
example from the tutorial and the EMF book.

But I have some problems to understand how to go into this:

if (diagnostics != null){

when we always call the function like this:

validator.validateItem_limitExceeded(eObject, null, null);

And diagnostics is always null!


And if I try to recreate everything with a new ecore model eclipse doesn't
create the packageValidator.java
And it doesn't create the code like in the example.

Thank you for your help. I am really frustrated...

Matthias
Re: Validation Framework [message #427149 is a reply to message #427146] Wed, 04 February 2009 12:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040000090402010107030507
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Matthias,

Comments below.

Matthias wrote:
> Hi,
>
> at the moment I try to work with the validation framework. I tried the
> example from the tutorial and the EMF book.
>
> But I have some problems to understand how to go into this:
>
> if (diagnostics != null){
>
> when we always call the function like this:
>
> validator.validateItem_limitExceeded(eObject, null, null);
>
> And diagnostics is always null!
The validator returns true or false to indicate if something is valid.
*Optionally *it can also collect diagnostics describing the reason
something isn't valid. But in many cases, one isn't interested in the
reason, which typically is only useful to the human reader, so the
generated patterns are written to avoid producing diagnostics when they
aren't desired.
>
>
> And if I try to recreate everything with a new ecore model eclipse
> doesn't create the packageValidator.java And it doesn't create the
> code like in the example.
Did you put any constraints in your model? If there are no constraints,
there won't be a generated validator.
> Thank you for your help. I am really frustrated...
>
> Matthias
>
>

--------------040000090402010107030507
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Matthias,<br>
<br>
Comments below.<br>
<br>
Matthias wrote:
<blockquote
cite="mid:c7e250c114a0a82335a2129e3e1e9718$1@www.eclipse.org"
type="cite">Hi,
<br>
<br>
at the moment I try to work with the validation framework. I tried the
example from the tutorial and the EMF book.
<br>
<br>
But I have some problems to understand how to go into this:
<br>
<br>
if (diagnostics != null){
<br>
<br>
when we always call the function like this:
<br>
<br>
validator.validateItem_limitExceeded(eObject, null, null);
<br>
<br>
And diagnostics is always null!
<br>
</blockquote>
The validator returns true or false to indicate if something is valid.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation Framework [message #427150 is a reply to message #427149] Wed, 04 February 2009 12:48 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
Hi Ed,

thanks first! ;-)

> The validator returns true or false to indicate if something is valid.
> *Optionally *it can also collect diagnostics describing the reason
> something isn't valid. But in many cases, one isn't interested in the
> reason, which typically is only useful to the human reader, so the
> generated patterns are written to avoid producing diagnostics when they
> aren't desired.

But for output of the errors in the problems view I need this diagnostics,
or?
So how I can get the handle of the DiagnosticChain to add the errors like
in the example?

And about the other problem, I thought if I have a already modeled ecore
model, I just have to add Annotation with Source Ecore. And this is the
constraint. But now I am confused about this.

And I changed this to:

@model annotation="http://www.eclipse.org/emf/2002/Ecore
constraints='limitReached'"



Matthias

Ed Merks wrote:

> Matthias,

> Comments below.

> Matthias wrote:
>> Hi,
>>
>> at the moment I try to work with the validation framework. I tried the
>> example from the tutorial and the EMF book.
>>
>> But I have some problems to understand how to go into this:
>>
>> if (diagnostics != null){
>>
>> when we always call the function like this:
>>
>> validator.validateItem_limitExceeded(eObject, null, null);
>>
>> And diagnostics is always null!
> The validator returns true or false to indicate if something is valid.
> *Optionally *it can also collect diagnostics describing the reason
> something isn't valid. But in many cases, one isn't interested in the
> reason, which typically is only useful to the human reader, so the
> generated patterns are written to avoid producing diagnostics when they
> aren't desired.
>>
>>
>> And if I try to recreate everything with a new ecore model eclipse
>> doesn't create the packageValidator.java And it doesn't create the
>> code like in the example.
> Did you put any constraints in your model? If there are no constraints,
> there won't be a generated validator.
>> Thank you for your help. I am really frustrated...
>>
>> Matthias
>>
>>
Re: Validation Framework [message #427151 is a reply to message #427150] Wed, 04 February 2009 12:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Matthias,

Comments below.

Matthias wrote:
> Hi Ed,
>
> thanks first! ;-)
>
>> The validator returns true or false to indicate if something is
>> valid. *Optionally *it can also collect diagnostics describing the
>> reason something isn't valid. But in many cases, one isn't
>> interested in the reason, which typically is only useful to the human
>> reader, so the generated patterns are written to avoid producing
>> diagnostics when they aren't desired.
>
> But for output of the errors in the problems view I need this
> diagnostics, or?
Yes.
> So how I can get the handle of the DiagnosticChain to add the errors
> like in the example?
Perhaps you'd like to be more specific so I know what you're referring
to... It's up to the caller to decide to pass in something to collect
diagnostics. As the implementer of a validator, you have to handle the
case where it's null and the case where it's not.
>
> And about the other problem, I thought if I have a already modeled
> ecore model, I just have to add Annotation with Source Ecore. And this
> is the constraint. But now I am confused about this.
>
> And I changed this to:
>
> @model annotation="http://www.eclipse.org/emf/2002/Ecore
> constraints='limitReached'"
It looks right. You reloaded your model so that this actually ended up
in your *.ecore?
>
>
>
> Matthias
>
> Ed Merks wrote:
>
>> Matthias,
>
>> Comments below.
>
>> Matthias wrote:
>>> Hi,
>>>
>>> at the moment I try to work with the validation framework. I tried
>>> the example from the tutorial and the EMF book.
>>>
>>> But I have some problems to understand how to go into this:
>>>
>>> if (diagnostics != null){
>>>
>>> when we always call the function like this:
>>>
>>> validator.validateItem_limitExceeded(eObject, null, null);
>>>
>>> And diagnostics is always null!
>> The validator returns true or false to indicate if something is
>> valid. *Optionally *it can also collect diagnostics describing the
>> reason something isn't valid. But in many cases, one isn't
>> interested in the reason, which typically is only useful to the human
>> reader, so the generated patterns are written to avoid producing
>> diagnostics when they aren't desired.
>>>
>>>
>>> And if I try to recreate everything with a new ecore model eclipse
>>> doesn't create the packageValidator.java And it doesn't create the
>>> code like in the example.
>> Did you put any constraints in your model? If there are no
>> constraints, there won't be a generated validator.
>>> Thank you for your help. I am really frustrated...
>>>
>>> Matthias
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation Framework [message #427152 is a reply to message #427150] Wed, 04 February 2009 13:06 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Matthias wrote:
> But for output of the errors in the problems view I need this
> diagnostics, or?

I think this is a good example. In my case, I even use the collected
diagnostics to suggest actions that would fix the problem.

> So how I can get the handle of the DiagnosticChain to add the errors
> like in the example?

In the book, there's a section where they talk about that magic wizard
'Diagnostician' and its static validate methods? I validate my models
with it: Diagnostics d = Diagnostician.validate(myEObject). Of course,
this will validate all constraints that are defined on that eObjects eClass.

Hope this helps.
Felix
Re: Validation Framework [message #427154 is a reply to message #427151] Wed, 04 February 2009 13:42 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
Hi Ed,

> It looks right. You reloaded your model so that this actually ended up
> in your *.ecore?
This was the problem, the changes wasn't in the ecore model itself.

Now it works, thanks a lot.

Matthias

Ed Merks wrote:

> Matthias,

> Comments below.

> Matthias wrote:
>> Hi Ed,
>>
>> thanks first! ;-)
>>
>>> The validator returns true or false to indicate if something is
>>> valid. *Optionally *it can also collect diagnostics describing the
>>> reason something isn't valid. But in many cases, one isn't
>>> interested in the reason, which typically is only useful to the human
>>> reader, so the generated patterns are written to avoid producing
>>> diagnostics when they aren't desired.
>>
>> But for output of the errors in the problems view I need this
>> diagnostics, or?
> Yes.
>> So how I can get the handle of the DiagnosticChain to add the errors
>> like in the example?
> Perhaps you'd like to be more specific so I know what you're referring
> to... It's up to the caller to decide to pass in something to collect
> diagnostics. As the implementer of a validator, you have to handle the
> case where it's null and the case where it's not.
>>
>> And about the other problem, I thought if I have a already modeled
>> ecore model, I just have to add Annotation with Source Ecore. And this
>> is the constraint. But now I am confused about this.
>>
>> And I changed this to:
>>
>> @model annotation="http://www.eclipse.org/emf/2002/Ecore
>> constraints='limitReached'"
> It looks right. You reloaded your model so that this actually ended up
> in your *.ecore?
>>
>>
>>
>> Matthias
>>
>> Ed Merks wrote:
>>
>>> Matthias,
>>
>>> Comments below.
>>
>>> Matthias wrote:
>>>> Hi,
>>>>
>>>> at the moment I try to work with the validation framework. I tried
>>>> the example from the tutorial and the EMF book.
>>>>
>>>> But I have some problems to understand how to go into this:
>>>>
>>>> if (diagnostics != null){
>>>>
>>>> when we always call the function like this:
>>>>
>>>> validator.validateItem_limitExceeded(eObject, null, null);
>>>>
>>>> And diagnostics is always null!
>>> The validator returns true or false to indicate if something is
>>> valid. *Optionally *it can also collect diagnostics describing the
>>> reason something isn't valid. But in many cases, one isn't
>>> interested in the reason, which typically is only useful to the human
>>> reader, so the generated patterns are written to avoid producing
>>> diagnostics when they aren't desired.
>>>>
>>>>
>>>> And if I try to recreate everything with a new ecore model eclipse
>>>> doesn't create the packageValidator.java And it doesn't create the
>>>> code like in the example.
>>> Did you put any constraints in your model? If there are no
>>> constraints, there won't be a generated validator.
>>>> Thank you for your help. I am really frustrated...
>>>>
>>>> Matthias
>>>>
>>>>
>>
>>
Re: Validation Framework [message #427155 is a reply to message #427154] Wed, 04 February 2009 14:14 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 19
Registered: July 2009
Junior Member
The only question no is how to start the validation with a button.

I have a button as a extension and I can run my own classes with this
button, but not the validation process "validateAction".

Any ideas?

Thanks
Matthias

Matthias wrote:

> Hi Ed,

>> It looks right. You reloaded your model so that this actually ended up
>> in your *.ecore?
> This was the problem, the changes wasn't in the ecore model itself.

> Now it works, thanks a lot.

> Matthias

> Ed Merks wrote:

>> Matthias,

>> Comments below.

>> Matthias wrote:
>>> Hi Ed,
>>>
>>> thanks first! ;-)
>>>
>>>> The validator returns true or false to indicate if something is
>>>> valid. *Optionally *it can also collect diagnostics describing the
>>>> reason something isn't valid. But in many cases, one isn't
>>>> interested in the reason, which typically is only useful to the human
>>>> reader, so the generated patterns are written to avoid producing
>>>> diagnostics when they aren't desired.
>>>
>>> But for output of the errors in the problems view I need this
>>> diagnostics, or?
>> Yes.
>>> So how I can get the handle of the DiagnosticChain to add the errors
>>> like in the example?
>> Perhaps you'd like to be more specific so I know what you're referring
>> to... It's up to the caller to decide to pass in something to collect
>> diagnostics. As the implementer of a validator, you have to handle the
>> case where it's null and the case where it's not.
>>>
>>> And about the other problem, I thought if I have a already modeled
>>> ecore model, I just have to add Annotation with Source Ecore. And this
>>> is the constraint. But now I am confused about this.
>>>
>>> And I changed this to:
>>>
>>> @model annotation="http://www.eclipse.org/emf/2002/Ecore
>>> constraints='limitReached'"
>> It looks right. You reloaded your model so that this actually ended up
>> in your *.ecore?
>>>
>>>
>>>
>>> Matthias
>>>
>>> Ed Merks wrote:
>>>
>>>> Matthias,
>>>
>>>> Comments below.
>>>
>>>> Matthias wrote:
>>>>> Hi,
>>>>>
>>>>> at the moment I try to work with the validation framework. I tried
>>>>> the example from the tutorial and the EMF book.
>>>>>
>>>>> But I have some problems to understand how to go into this:
>>>>>
>>>>> if (diagnostics != null){
>>>>>
>>>>> when we always call the function like this:
>>>>>
>>>>> validator.validateItem_limitExceeded(eObject, null, null);
>>>>>
>>>>> And diagnostics is always null!
>>>> The validator returns true or false to indicate if something is
>>>> valid. *Optionally *it can also collect diagnostics describing the
>>>> reason something isn't valid. But in many cases, one isn't
>>>> interested in the reason, which typically is only useful to the human
>>>> reader, so the generated patterns are written to avoid producing
>>>> diagnostics when they aren't desired.
>>>>>
>>>>>
>>>>> And if I try to recreate everything with a new ecore model eclipse
>>>>> doesn't create the packageValidator.java And it doesn't create the
>>>>> code like in the example.
>>>> Did you put any constraints in your model? If there are no
>>>> constraints, there won't be a generated validator.
>>>>> Thank you for your help. I am really frustrated...
>>>>>
>>>>> Matthias
>>>>>
>>>>>
>>>
>>>
Re: Validation Framework [message #427156 is a reply to message #427155] Wed, 04 February 2009 14:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Matthias,

It's done by ValidateAction. (Ctrl-Shift-T is very handy if you aren't
using it yet.)


Matthias wrote:
> The only question no is how to start the validation with a button.
>
> I have a button as a extension and I can run my own classes with this
> button, but not the validation process "validateAction".
>
> Any ideas?
>
> Thanks
> Matthias
>
> Matthias wrote:
>
>> Hi Ed,
>
>>> It looks right. You reloaded your model so that this actually ended
>>> up in your *.ecore?
>> This was the problem, the changes wasn't in the ecore model itself.
>
>> Now it works, thanks a lot.
>
>> Matthias
>
>> Ed Merks wrote:
>
>>> Matthias,
>
>>> Comments below.
>
>>> Matthias wrote:
>>>> Hi Ed,
>>>>
>>>> thanks first! ;-)
>>>>
>>>>> The validator returns true or false to indicate if something is
>>>>> valid. *Optionally *it can also collect diagnostics describing
>>>>> the reason something isn't valid. But in many cases, one isn't
>>>>> interested in the reason, which typically is only useful to the
>>>>> human reader, so the generated patterns are written to avoid
>>>>> producing diagnostics when they aren't desired.
>>>>
>>>> But for output of the errors in the problems view I need this
>>>> diagnostics, or?
>>> Yes.
>>>> So how I can get the handle of the DiagnosticChain to add the
>>>> errors like in the example?
>>> Perhaps you'd like to be more specific so I know what you're
>>> referring to... It's up to the caller to decide to pass in
>>> something to collect diagnostics. As the implementer of a
>>> validator, you have to handle the case where it's null and the case
>>> where it's not.
>>>>
>>>> And about the other problem, I thought if I have a already modeled
>>>> ecore model, I just have to add Annotation with Source Ecore. And
>>>> this is the constraint. But now I am confused about this.
>>>>
>>>> And I changed this to:
>>>>
>>>> @model annotation="http://www.eclipse.org/emf/2002/Ecore
>>>> constraints='limitReached'"
>>> It looks right. You reloaded your model so that this actually ended
>>> up in your *.ecore?
>>>>
>>>>
>>>>
>>>> Matthias
>>>>
>>>> Ed Merks wrote:
>>>>
>>>>> Matthias,
>>>>
>>>>> Comments below.
>>>>
>>>>> Matthias wrote:
>>>>>> Hi,
>>>>>>
>>>>>> at the moment I try to work with the validation framework. I
>>>>>> tried the example from the tutorial and the EMF book.
>>>>>>
>>>>>> But I have some problems to understand how to go into this:
>>>>>>
>>>>>> if (diagnostics != null){
>>>>>>
>>>>>> when we always call the function like this:
>>>>>>
>>>>>> validator.validateItem_limitExceeded(eObject, null, null);
>>>>>>
>>>>>> And diagnostics is always null!
>>>>> The validator returns true or false to indicate if something is
>>>>> valid. *Optionally *it can also collect diagnostics describing
>>>>> the reason something isn't valid. But in many cases, one isn't
>>>>> interested in the reason, which typically is only useful to the
>>>>> human reader, so the generated patterns are written to avoid
>>>>> producing diagnostics when they aren't desired.
>>>>>>
>>>>>>
>>>>>> And if I try to recreate everything with a new ecore model
>>>>>> eclipse doesn't create the packageValidator.java And it doesn't
>>>>>> create the code like in the example.
>>>>> Did you put any constraints in your model? If there are no
>>>>> constraints, there won't be a generated validator.
>>>>>> Thank you for your help. I am really frustrated...
>>>>>>
>>>>>> Matthias
>>>>>>
>>>>>>
>>>>
>>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:IMarker and IResource
Next Topic:Additional properties to an EMFObject
Goto Forum:
  


Current Time: Tue Apr 23 10:23:57 GMT 2024

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

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

Back to the top