Skip to main content



      Home
Home » Modeling » EMF » EMF Validation
EMF Validation [message #539307] Thu, 10 June 2010 07:01 Go to next message
Eclipse UserFriend
Hi All,

I am using Diagnostics to validate my model.
Not an expert in EMF to start with.

My EObjectValidatior has this method which comes from as result of restriction in the xsd.


protected void reportDataValuePatternViolation
    (EDataType eDataType, Object value, PatternMatcher [] patterns, DiagnosticChain diagnostics, Map<Object, Object> context)
  {
    String patternLiterals = "";
    if (patterns.length > 0)
    {
      patternLiterals = getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object [] { patterns[0] });
      for (int i = 1; i < patterns.length; ++i)
      {
        patternLiterals = getEcoreResourceLocator().getString("_UI_ListTail_composition", new Object [] { patternLiterals, patterns[i] });
      }
    }

    diagnostics.add
      (createDiagnostic
        (Diagnostic.ERROR,
         DIAGNOSTIC_SOURCE,
         DATA_VALUE__MATCHES_PATTERN,
         "_UI_PatternConstraint_diagnostic",
         new Object []
         {
           getValueLabel(eDataType, value, context),
           patternLiterals
         },
         new Object [] { value, eDataType, patterns },
         context));
  }




It seems the _UI_ListHead_composition type of error is being reported with _UI_PatternConstraint_diagnostic.
So everytime my capital letter check apppears as the special character check which is corresponding to _UI_PatternConstraint_diagnostic.

Is my understanding wrong at some place?
Please help.

Thanks and Regards,
Saurav
Re: EMF Validation [message #539395 is a reply to message #539307] Thu, 10 June 2010 10:49 Go to previous messageGo to next message
Eclipse UserFriend
Saurav,

Comments below.


saurav wrote:
> Hi All,
>
> I am using Diagnostics to validate my model.
> Not an expert in EMF to start with.
>
> My EObjectValidatior has this method which comes from as result of
> restriction in the xsd.
>
>
>
> protected void reportDataValuePatternViolation
> (EDataType eDataType, Object value, PatternMatcher [] patterns,
> DiagnosticChain diagnostics, Map<Object, Object> context)
> {
> String patternLiterals = "";
> if (patterns.length > 0)
> {
> patternLiterals =
> getEcoreResourceLocator().getString("_UI_ListHead_composition ", new
> Object [] { patterns[0] });
> for (int i = 1; i < patterns.length; ++i)
> {
> patternLiterals =
> getEcoreResourceLocator().getString("_UI_ListTail_composition ", new
> Object [] { patternLiterals, patterns[i] });
> }
> }
>
> diagnostics.add
> (createDiagnostic
> (Diagnostic.ERROR,
> DIAGNOSTIC_SOURCE,
> DATA_VALUE__MATCHES_PATTERN,
> "_UI_PatternConstraint_diagnostic",
> new Object []
> {
> getValueLabel(eDataType, value, context),
> patternLiterals
> },
> new Object [] { value, eDataType, patterns },
> context));
> }
>
>
>
>
> It seems the _UI_ListHead_composition type of error is being reported
> with _UI_PatternConstraint_diagnostic.
> So everytime my capital letter check apppears as the special character
> check which is corresponding to _UI_PatternConstraint_diagnostic.
I don't know what you're saying.
>
> Is my understanding wrong at some place?
An example of what's wrong would help.
> Please help.
>
> Thanks and Regards,
> Saurav
>
Re: EMF Validation [message #539928 is a reply to message #539395] Mon, 14 June 2010 06:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Sorry as i was not much clear in my earlier post.

I meant i have a regex pattern defined in the Xsd schema as a restriction where i dont allow any element name to start with upper case.The same regex pattern also does not allow special characters.

Now the thing is in EMF EObjectValidor() we have this reportDataValuePatternViolation method which reports the error with the message with key of '_UI_PatternConstraint_diagnostic' for any pattern mismatch. So for both of the cases (Uppercase and special character check) same error would be reported.

So my problem lies with the same error reported for any kind of pattern mismatch.

Here I have two solutions in my mind

(a) To keep the error msg generic like 'Name is invalid'.But it lacks the further clarity.

(b) To introduce my own checks.In this case i do not get much help from EMF.

I hope i was able to clear it further.
Please provid your inputs here.

cheers,
Saurav
Re: EMF Validation [message #540022 is a reply to message #539928] Mon, 14 June 2010 11:34 Go to previous message
Eclipse UserFriend
Saurav,

There's not much EMF can do in terms of producing a specialized message
from a single pattern so you'd need to produce your own messages for
such cases if that's what you feel you really need; the user is shown
the pattern...


saurav wrote:
> Hi Ed,
>
> Sorry as i was not much clear in my earlier post.
>
> I meant i have a regex pattern defined in the Xsd schema as a
> restriction where i dont allow any element name to start with upper
> case.The same regex pattern also does not allow special characters.
>
> Now the thing is in EMF EObjectValidor() we have this
> reportDataValuePatternViolation method which reports the error with
> the message with key of '_UI_PatternConstraint_diagnostic' for any
> pattern mismatch. So for both of the cases (Uppercase and special
> character check) same error would be reported.
>
> So my problem lies with the same error reported for any kind of
> pattern mismatch.
>
> Here I have two solutions in my mind
>
> (a) To keep the error msg generic like 'Name is invalid'.But it lacks
> the further clarity.
>
> (b) To introduce my own checks.In this case i do not get much help
> from EMF.
>
> I hope i was able to clear it further.
> Please provid your inputs here.
>
> cheers,
> Saurav
Previous Topic:Reflective Java code generator for instances ?
Next Topic:[CDO] Exists an MWE Reader?
Goto Forum:
  


Current Time: Sun Jul 13 08:12:33 EDT 2025

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

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

Back to the top