Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ValidationEvent, IValidator, putClientData
ValidationEvent, IValidator, putClientData [message #421263] Fri, 01 August 2008 21:24 Go to next message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi !

How to customize putClientData(str,obj)? the aim ist to achieve an
injection mechanism, that bind a complex constraint (from third party xml
file) to ISelection and respectively to EObject.
I do not need to restrict the constraints that are applied to my model
not so long ago, Christian wrote:
"The IValidator API isn't supposed to be implemented by clients"

Grateful for your effort an advice,

Sam
Re: ValidationEvent, IValidator, putClientData [message #421270 is a reply to message #421263] Sat, 02 August 2008 10:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Sam,

Maybe Christian will understand the question, but I don't. You've read
the detailed documentation Christian has provided for the validation
framework?


Sam wrote:
> Hi !
>
> How to customize putClientData(str,obj)? the aim ist to achieve an
> injection mechanism, that bind a complex constraint (from third party
> xml file) to ISelection and respectively to EObject.
> I do not need to restrict the constraints that are applied to my model
> not so long ago, Christian wrote: "The IValidator API isn't supposed
> to be implemented by clients"
>
> Grateful for your effort an advice,
>
> Sam
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ValidationEvent, IValidator, putClientData [message #421274 is a reply to message #421270] Sat, 02 August 2008 11:33 Go to previous messageGo to next message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Ed,
sorry for the bad question formulation.
I have read the documentation, as christian has recommended, it has helped
me to better understand the use of EMF Validation Framework.

the question ist: is it proper to use putClientData(arg,arg2)?

perhaps I am confused, I will check my specification.

Thanks,
Sam
Re: ValidationEvent, IValidator, putClientData [message #421281 is a reply to message #421263] Sat, 02 August 2008 16:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Sam,

If I understand correctly, you are looking to determine, at run-time,
which constraints should be evaluated on which particular objects in a
model? And the problem is, that the framework only permits the
association of constraints with EClasses, but not with finer-grained
criteria that determine which particular instances of those EClasses?

You can do this in a couple of ways:

(a) use an IConstraintFilter with your IValidator. It defines a
filtering protocol that the validator uses to determine whether a
particular EObject should be validated against a particular constraint
that was provided by the framework.

(b) if you don't want the client of the validation service to have to
determine which constraints to apply, but want to control this in the
constraint-provider, then you don't have to use the static plugin.xml
implementation of the constraint provider. You can define your own
IConstraintProvider class that uses any criteria you require to
determine which constraints to offer for any EObject that is to be
validated. Just be sure, in your <constraintProvider> declaration in
your plugin.xml, to disable caching of the constraints, because the
framework caches them by EClass, not by EObject.

HTH,

Christian


Sam wrote:
> Hi !
>
> How to customize putClientData(str,obj)? the aim ist to achieve an
> injection mechanism, that bind a complex constraint (from third party
> xml file) to ISelection and respectively to EObject.
> I do not need to restrict the constraints that are applied to my model
> not so long ago, Christian wrote: "The IValidator API isn't supposed to
> be implemented by clients"
>
> Grateful for your effort an advice,
>
> Sam
>
>
>
>
Re: ValidationEvent, IValidator, putClientData [message #421285 is a reply to message #421281] Sat, 02 August 2008 19:14 Go to previous messageGo to next message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Christian,

first, I ask you to apologize my English.
++++
If I understand correctly, you are looking to determine, at run-time,
which constraints should be evaluated on which particular objects in a
model? And the problem is, that the framework only permits the
association of constraints with EClasses, but not with finer-grained
criteria that determine which particular instances of those EClasses?
++++
YES, exactly "super" Christian! the "finer-grained" criteria is the core
of my specification. just to provide you an idea of this
complex-validation-issue:
1- for the same Parameter(EAttribute) we could have to bind different
Rules (Constraints) depending on something called the Parameter Source
Provider.
the Validation Framework give me the posibility to control the "global"
Validation form of a "DataBlock"= EClass, but each particular instance
(EAttribute=Parameter) could be checked Formally with other different
Validation Rules(nested Validation)- (image the matryoshka doll)-.
2- ItŽs also reasonable to group related constraints depending on
EDataType of the EAttribute and the owned Parameter Source Provider. e.g
letŽs assume a Network Package, that carried 3 messages. grouping Rules
and bind them to EAttribute(msg) to execute the Validation is much
practicable than writing for each Network Package a Rules-Engine e.g.
( foreach flopy include EPack(sourceProvider )
PROCESS_Tracking_Denied(flopy) =”TRUE”
forward ERROR_MSG (flopy) is not empty).
Network Package is unique but the one and the same messages could be
carried by different Network Package. those messages require different
Validation Rules to be conform with their own Parent Package.


++++++
(a) use an IConstraintFilter with your IValidator. It defines a filtering
protocol that the validator uses to determine whether a particular EObject
should be validated against a particular constraint that was provided by
the framework.
+++++++
IConstraintFilter could be helpful, so I think my solution will depend on
(a) and (b).

+++++
(b) if you don't want the client of the validation service to have to
determine which constraints to apply, but want to control this in the
constraint-provider, then you don't have to use the static plugin.xml
implementation of the constraint provider. You can define your own
IConstraintProvider class that uses any criteria you require to determine
which constraints to offer for any EObject that is to be validated. Just
be sure, in your <constraintProvider> declaration in your plugin.xml, to
disable caching of the constraints, because the framework caches them by
EClass, not by EObject.
+++++

OK, That sound pretty nice. (I tried to clown the static plugin.xml by
extrating the information that define the Constraint till now without
success).

so i will take consideration of the folowing;
a- define <constraintProvider> in the plugin.xml,
b- extends AbstractModelConstraint, c- use setInitializationData() to
initialize Constraints, d- addValidation Listener and define client Context
customize putClientData() and make my Rules-Config.xml available to the
appropriate Parameter.


Merci!
Sam
Re: ValidationEvent, IValidator, putClientData [message #421325 is a reply to message #421285] Mon, 04 August 2008 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Sam,

See some replies in-line, below.

Cheers,

Christian


Sam wrote:
> Hi Christian,
>
> first, I ask you to apologize my English.
> ++++
> If I understand correctly, you are looking to determine, at run-time,
> which constraints should be evaluated on which particular objects in a
> model? And the problem is, that the framework only permits the
> association of constraints with EClasses, but not with finer-grained
> criteria that determine which particular instances of those EClasses?
> ++++
> YES, exactly "super" Christian! the "finer-grained" criteria is the core

Please, don't call me super. I'm just a human being.

> of my specification. just to provide you an idea of this
> complex-validation-issue:
> 1- for the same Parameter(EAttribute) we could have to bind different
> Rules (Constraints) depending on something called the Parameter Source
> Provider.
> the Validation Framework give me the posibility to control the "global"
> Validation form of a "DataBlock"= EClass, but each particular instance
> (EAttribute=Parameter) could be checked Formally with other different
> Validation Rules(nested Validation)- (image the matryoshka doll)-.

Yes, with a dynamic constraint provider, you can implement the
contribution of rules as flexibly as you need. It's just that you take
on all of the complexity; the EMF framework won't help much.


> 2- ItŽs also reasonable to group related constraints depending on
> EDataType of the EAttribute and the owned Parameter Source Provider. e.g
> letŽs assume a Network Package, that carried 3 messages. grouping Rules
> and bind them to EAttribute(msg) to execute the Validation is much
> practicable than writing for each Network Package a Rules-Engine e.g.
> ( foreach flopy include EPack(sourceProvider )
> PROCESS_Tracking_Denied(flopy) =?TRUE?
> forward ERROR_MSG (flopy) is not empty). Network Package is
> unique but the one and the same messages could be carried by different
> Network Package. those messages require different Validation Rules to be
> conform with their own Parent Package.

Out of the box, the validation framework provides support for
associating invariant constraints with metaclasses (EClasses), which is
by far the most common scenario. What it doesn't address is the need to
associate constraints with EDataTypes, implying that attributes of that
type will be validated for some kind of well-formedness of the value.
This would be most useful, I suppose, for string-like data types (such
as are common in XSD). If you feel it's important, you could certainly
raise an enhancement request.

> ++++++
> (a) use an IConstraintFilter with your IValidator. It defines a
> filtering protocol that the validator uses to determine whether a
> particular EObject should be validated against a particular constraint
> that was provided by the framework.
> +++++++
> IConstraintFilter could be helpful, so I think my solution will depend
> on (a) and (b).
>
> +++++
> (b) if you don't want the client of the validation service to have to
> determine which constraints to apply, but want to control this in the
> constraint-provider, then you don't have to use the static plugin.xml
> implementation of the constraint provider. You can define your own
> IConstraintProvider class that uses any criteria you require to
> determine which constraints to offer for any EObject that is to be
> validated. Just be sure, in your <constraintProvider> declaration in
> your plugin.xml, to disable caching of the constraints, because the
> framework caches them by EClass, not by EObject.
> +++++
>
> OK, That sound pretty nice. (I tried to clown the static plugin.xml by
> extrating the information that define the Constraint till now without
> success).
>
> so i will take consideration of the folowing; a- define
> <constraintProvider> in the plugin.xml, b- extends
> AbstractModelConstraint, c- use setInitializationData() to initialize
> Constraints, d- addValidation Listener and define client Context
> customize putClientData() and make my Rules-Config.xml available to the
> appropriate Parameter.

That sounds like a reasonable plan. I *think* it should work.

Good luck!

>
>
> Merci!
> Sam
>
Re: ValidationEvent, IValidator, putClientData [message #421558 is a reply to message #421325] Sat, 09 August 2008 11:56 Go to previous messageGo to next message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Christian,
+++
Please, don't call me super. I'm just a human being.
+++
1/ Sorry, Pardon me.

++++
Out of the box, the validation framework provides support for associating
invariant constraints with metaclasses (EClasses), which is by far the
most common scenario. What it doesn't address is the need to associate
constraints with EDataTypes, implying that attributes of that type will be
validated for some kind of well-formedness of the value. This would be
most useful, I suppose, for string-like data types (such as are common in
XSD). If you feel it's important, you could certainly raise an
enhancement request.
++++++
2/ for me itŽs important, how to raise an enhancement request?


Thanks,
Sam
Re: ValidationEvent, IValidator, putClientData [message #421559 is a reply to message #421558] Sat, 09 August 2008 12:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000403020505060402090201
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Sam,

Comments below.


Sam wrote:
> Hi Christian,
> +++
> Please, don't call me super. I'm just a human being.
> +++
> 1/ Sorry, Pardon me.
He's just being humble. It's best to humor him and treat him like a
normal person. :-P
>
> ++++
> Out of the box, the validation framework provides support for
> associating invariant constraints with metaclasses (EClasses), which
> is by far the most common scenario. What it doesn't address is the
> need to associate constraints with EDataTypes, implying that
> attributes of that type will be validated for some kind of
> well-formedness of the value. This would be most useful, I suppose,
> for string-like data types (such as are common in XSD). If you feel
> it's important, you could certainly raise an enhancement request.
> ++++++
> 2/ for me it


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ValidationEvent, IValidator, putClientData [message #421575 is a reply to message #421559] Sun, 10 August 2008 11:36 Go to previous messageGo to next message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Ed,

Clarification:
my use case do not permit the use of Constraint at the Model Level bevor
the code has been generated by EMF. Do you have any idea of how create and
invoke the Invariant Constraint after the code generation process? To lean
on ChristianŽs explanation, the dynamic constraint provider schould solve
my Problem.
1- generate Code from xsd.
2- placing Rules-Config.xml outside the plugin.xml.
3- customize the Validation Framework and implement my case Rules.

What do you think?

Thanks,
Sam
Re: ValidationEvent, IValidator, putClientData [message #421576 is a reply to message #421575] Sun, 10 August 2008 12:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Sam,

Comments below.

Sam wrote:
> Hi Ed,
>
> Clarification:
> my use case do not permit the use of Constraint at the Model Level
> bevor the code has been generated by EMF. Do you have any idea of how
> create and invoke the Invariant Constraint after the code generation
> process?
I don't really get what the first sentence is saying. The only way to
do within what core EMF provides directly is exactly the same was as
it's done automatically for you. I.e., you have to write a for the
package and register it. Invoking it is also done exactly the same way.
> To lean on ChristianŽs explanation, the dynamic constraint provider
> schould solve my Problem.
> 1- generate Code from xsd.
The facets on XSD simple types generate constraints exactly as I
described. That's how all the simple type restrictions of XSD are
enforced. Adding a named constraint is just a way to augment that.
> 2- placing Rules-Config.xml outside the plugin.xml.
> 3- customize the Validation Framework and implement my case Rules.
>
> What do you think?
I think you'll have to work with Christian to extend his framework for
this or do something like his framework. It's an easy thing to walk an
entire EMF model and apply constraints to EObjects and to the values of
their EAttributes...
>
> Thanks,
> Sam
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ValidationEvent, IValidator, putClientData [message #421578 is a reply to message #421559] Sun, 10 August 2008 16:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Ed,

What I was trying to say is that the (extrinsic) validation-framework
component allows definition of constraints on EClasses, but not on
EDataTypes. The former case is quite straight-forward, evaluating the
constraint on objects that are instances of a given EClass. The latter
is not quite as straight-forward, because it requires evaluating the
constraints on objects that have an EAttribute of the given EDataType type.

Sam is looking at the extrinsic validation solution because he is not in
a position to generate code for the model.

Hope that makes it more clear,

Christian

Ed Merks wrote:
> Sam,
>
> Comments below.
>
>
> Sam wrote:
>> Hi Christian,
>> +++
>> Please, don't call me super. I'm just a human being.
>> +++
>> 1/ Sorry, Pardon me.
> He's just being humble. It's best to humor him and treat him like a
> normal person. :-P
>>
>> ++++
>> Out of the box, the validation framework provides support for
>> associating invariant constraints with metaclasses (EClasses), which
>> is by far the most common scenario. What it doesn't address is the
>> need to associate constraints with EDataTypes, implying that
>> attributes of that type will be validated for some kind of
>> well-formedness of the value. This would be most useful, I suppose,
>> for string-like data types (such as are common in XSD). If you feel
>> it's important, you could certainly raise an enhancement request.
>> ++++++
>> 2/ for me itŽs important, how to raise an enhancement request?
> Actually I'm not sure what he means in this case. Invariants work for
> EClasses because we generate code for them. The best we can do for an
> EDataType is define named constraints that will be enforced for all
> instances by code you have to write in the generated validator. I.e.,
> the same thing as is in
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html
> for EClasses works for EDataTypes. E.g., if I define a constraint like
> this:
>
> <eClassifiers xsi:type="ecore:EDataType" name="D"
> instanceClassName="int">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="constraints" value="Abc"/>
> </eAnnotations>
> </eClassifiers>
>
> the generated validator will have a method like this:
>
> /**
> * Validates the Abc constraint of '<em>D</em>'.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public boolean validateD_Abc(int d, DiagnosticChain diagnostics,
> Map<Object, Object> context) {
> // TODO implement the constraint
> // -> specify the condition that violates the constraint
> // -> verify the diagnostic details, including severity,
> code, and message
> // Ensure that you remove @generated or mark it @generated NOT
> if (false) {
> if (diagnostics != null) {
> diagnostics.add
> (createDiagnostic
> (Diagnostic.ERROR,
> DIAGNOSTIC_SOURCE,
> 0,
> "_UI_GenericConstraint_diagnostic",
> new Object[] { "Abc",
> getValueLabel(BPackage.Literals.D, d, context) },
> new Object[] { d },
> context));
> }
> return false;
> }
> return true;
> }
>
> And that constraint will be checked for the value of any feature that
> uses this data type.
>>
>>
>> Thanks, Sam
Re: ValidationEvent, IValidator, putClientData [message #421579 is a reply to message #421558] Sun, 10 August 2008 16:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Sam,

To raise an enhancement request, you fill out the form in Eclipse's
bugzilla database. This link should give you a head-start:

https://bugs.eclipse.org/bugs/enter_bug.cgi?assigned_to=emf. validation-inbox%40eclipse.org&blocked=&bug_file_loc =http%3A%2F%2F&bug_severity=enhancement&bug_status=N EW&comment=&component=Validation&contenttypeentr y=&contenttypemethod=autodetect&contenttypeselection =text%2Fplain&data=&dependson=&description=& flag_type-1=X&flag_type-2=X&flag_type-4=X&flag_t ype-6=X&flag_type-7=X&flag_type-8=X&form_name=en ter_bug&keywords=&maketemplate=Remember%20values%20a s%20bookmarkable%20template&op_sys=All&priority=P3&a mp;product=EMF&qa_contact=&rep_platform=PC&short _desc=Support%20for%20defining%20constraints%20on%20EDataTyp es&version=1.2

Note that raising a request doesn't mean that this feature will be
implemented. That depends on the time that I can devote to the
component's priorities, and what other contributors are interested in
working on. Your best chance of seeing a new feature realized is, in
general, to submit a patch for it yourself :-)

Cheers,

Christian

Sam wrote:
> Hi Christian,
> +++
> Please, don't call me super. I'm just a human being.
> +++
> 1/ Sorry, Pardon me.
>
> ++++
> Out of the box, the validation framework provides support for
> associating invariant constraints with metaclasses (EClasses), which is
> by far the most common scenario. What it doesn't address is the need to
> associate constraints with EDataTypes, implying that attributes of that
> type will be validated for some kind of well-formedness of the value.
> This would be most useful, I suppose, for string-like data types (such
> as are common in XSD). If you feel it's important, you could certainly
> raise an enhancement request.
> ++++++
> 2/ for me itŽs important, how to raise an enhancement request?
>
>
> Thanks, Sam
Re: ValidationEvent, IValidator, putClientData [message #421583 is a reply to message #421578] Sun, 10 August 2008 21:00 Go to previous message
Sam Julian is currently offline Sam JulianFriend
Messages: 29
Registered: July 2009
Junior Member
Hi, Christian, Ed,

+++
Sam is looking at the extrinsic validation solution because he is not in a
position to generate code for the model.
++++
I can generate code from the model by extending the EObjectValidator and I
do get something like this:

public boolean validateINTaNunbTYPE_RangeTypeCaseMin(abcType fancyTYPE,
DiagnosticChain diagnostics, Map<Object, Object> context) {
boolean result = fancyTYPE.compareTo
........BLAH BLAH etc..
reportMinViolation(Package.Literals.xxxx,xxxxx, xxx, true, diagnostics,
context);
return result;
}

this work well so far, but grouping all of the generated validation
depending on EDAtatype is much useful.
e.g. public boolean validateMinType and public boolean validateMaxType
following my requirement those Validation could be grouped in a "Range
Rule" validate min max mean to validate an "Interval".

I am quite sure to get a normal solution, but its could be wonderful to
have a Beautiful one.

Cheers!
Sam
Previous Topic:TreeViewer refresh
Next Topic:Re: The newbie struggle (But still made it).
Goto Forum:
  


Current Time: Fri Mar 29 04:43:50 GMT 2024

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

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

Back to the top