Home » Modeling » EMF » EMF Validation
EMF Validation [message #539307] |
Thu, 10 June 2010 11:01 |
saurav sarkar Messages: 428 Registered: July 2009 |
Senior Member |
|
|
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
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
|
|
|
Re: EMF Validation [message #539395 is a reply to message #539307] |
Thu, 10 June 2010 14:49 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
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
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: EMF Validation [message #540022 is a reply to message #539928] |
Mon, 14 June 2010 15:34 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
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
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Apr 23 07:24:07 GMT 2024
Powered by FUDForum. Page generated in 0.02578 seconds
|