Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Constraint issue
EMF Constraint issue [message #1590065] Wed, 28 January 2015 20:39 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
I followed the standard practice of adding constraint, but when IValidator.validate() executes the constraint is not being executed because it's not being registered. I did some debugging and see that myContraints List in GetBatchConstraintsOperation is empty, but ClientContext has my context present. Also IClientSelector is being called. What could be the issue with failure to add my constraint?

Here is my extension points definitions
<extension
         point="org.eclipse.emf.validation.constraintProviders">
      <category
            id="myCategory"
            mandatory="false"
            name="Non Empty Reference"/>
      <constraintProvider
            cache="true"
            mode="Live">
         <package namespaceUri="http://myNamespace"/>
         <constraints categories="myCategory">
            <constraint
                  class="NonEmptyReferenceConstraint"
                  id="ReferenceNotEmpty"
                  isEnabledByDefault="true"
                  lang="Java"
                  mode="Live"
                  name="Non Empty References"
                  severity="ERROR"
                  statusCode="1">
               <description>
                  All items in an EXT library model should have some unique identifier or name.
               </description>
               <message>
                  ..been found to have no unique identifier (name or title).
               </message>
            </constraint>
         </constraints>
      </constraintProvider>
   </extension>
   <extension
         point="org.eclipse.emf.validation.constraintBindings">
      <clientContext
            default="false"
            id="referenceContext">
         <selector class="ValidationDelegateClientSelector"/>
      </clientContext>
      <binding
            context="referenceContext"
            category="myCategory"/>
   </extension>


Thanks,
Alex
Re: EMF Constraint issue [message #1590122 is a reply to message #1590065] Wed, 28 January 2015 21:23 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
The problem was that I was using IBatchValidator on a Live constraint, once I changed to Batch mode, everything worked. However, I did specify:
IBatchValidator validator = ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
validator.setIncludeLiveConstraints(true);

So shouldn't my constraint be called anyway?
Re: EMF Constraint issue [message #1590278 is a reply to message #1590122] Wed, 28 January 2015 23:23 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Alex,

Yes, I would have expected it to have been called under those
circumstances. Such a basic regression should have turned up in the
automated tests, though, so perhaps there was something else at play in
the filtering of the constraints.

Cheers,

Christian


On 2015-01-28 21:23:37 +0000, Alex Kravets said:

> The problem was that I was using IBatchValidator on a Live constraint,
> once I changed to Batch mode, everything worked. However, I did specify:
>
> IBatchValidator validator =
> ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
> validator.setIncludeLiveConstraints(true);
>
> So shouldn't my constraint be called anyway?
Previous Topic:XMI load validation
Next Topic:[EMF] Wrong URI for proxy of controlled resource
Goto Forum:
  


Current Time: Fri Apr 19 02:43:54 GMT 2024

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

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

Back to the top