[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: User data in validation

Christian,

Comments inline.

Christian W. Damus wrote:
Hi, Vasanth,

No, currently there is no such facility.  I think in the EValidator API, the
context map is geared towards utilities that are known to and provided by
EMF, such as SubstitutionLabelProviders.  It can be assumed that
constraints in an EValidator will know what to do with these
general-purpose context objects, but not application-specific objects.

With respect to the EValidator API, I have modified the generated XXXValidator (? EValidator). (It might be argued that I should have created a new EValidator and registered it?) Now, when I call the validator, I pass in additional context information in the context map and my new constraints make use of the additional context information.



The assumption in the ModelValidationService is that if constraints are so
tightly coupled with an application that they need to exchange such context
data, then they can provide their own communication channel separately from
the validation framework. I'm not sure that this is always practical.

As for now, I have made my generated XXXResourceImpl adaptable and it provides additional context information (Resource is not IAdaptable, but I made my generated XXXResourceImpl to be IAdaptable. This is not very elegant but it helps solve my problem for now). Since constraints have access to the EObject being validated (hence the underlying Resource), I am able to get my additional context information from this).


Certainly, we're open to proposals to enhance this part of the API.

I would think that IValidator could have some way to set additional context that becomes accessible to all constraints as part of IValidationContext itself.


Thanks,
Vasanth



Cheers,

Christian


Vasanth Velusamy wrote:

When using the EMF Validation Framework (ModelValidationService along
with constraints), how do I provide user-defined context data to the
constraints? AbstractModelConstraint.validate() provides an
IValidationContext from which I am able to retrieve the target and other
details, but how can I provide user context data to the constraint? I
understand that IValidationContext.get/putCurrentConstraintData() is for
a different purpose.

In the EValidator api, I see that Diagnostician.validate() gives the
option to add user data as a context map (Map<Object, Object> context).

Is there something similar when using the EMF Validation Framework?

Thanks,
Vasanth