Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Validation: Diagnostician vs. ModelValidationService  () 1 Vote
EMF Validation: Diagnostician vs. ModelValidationService [message #761917] Wed, 07 December 2011 09:36 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

in an Eclipse Application (yes, running Eclipse Platform), I want to
call EMF Validation programmatically.
What is the right way to do it? I found

org.eclipse.emf.validation.service.ModelValidationService
ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH).validate(eobject);
vs.
org.eclipse.emf.ecore.util.Diagnostician
Diagnostician.INSTANCE.validate(eobject);

The first results always an empty Status with
"Status OK: org.eclipse.emf.validation code=10 No constraints were
evaluated. null"
The second results a Diagnostic with proper error messages. So my
Validator (CompleteOCL) is registered correctly.

In both cases I register my validator with an earlyStartup:
@Override
public void earlyStartup() {
URI oclURI = URI.createPlatformResourceURI("myPath",false);
EValidator validator =
new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
}

What's the difference between the two approaches. Why is the
ModelValidationService not seeing my constraints while the Diagnostician
does? Is it the right way to use the Diagnostician? Why are there
multiple approaches anyways?

Cheers,
Hauke
Re: EMF Validation: Diagnostician vs. ModelValidationService [message #762015 is a reply to message #761917] Wed, 07 December 2011 12:38 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Kauke,

I'm not all the familiar with how the extended validation framework
works. Do you have additional registered constraints in your
plugin.xml? I'm not sure it's intended to invoke the intrinsic
constraints of the core framework...


On 07/12/2011 1:36 AM, Hauke Fuhrmann wrote:
> Hi there,
>
> in an Eclipse Application (yes, running Eclipse Platform), I want to
> call EMF Validation programmatically.
> What is the right way to do it? I found
>
> org.eclipse.emf.validation.service.ModelValidationService
> ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH).validate(eobject);
>
> vs.
> org.eclipse.emf.ecore.util.Diagnostician
> Diagnostician.INSTANCE.validate(eobject);
>
> The first results always an empty Status with
> "Status OK: org.eclipse.emf.validation code=10 No constraints were
> evaluated. null"
> The second results a Diagnostic with proper error messages. So my
> Validator (CompleteOCL) is registered correctly.
>
> In both cases I register my validator with an earlyStartup:
> @Override
> public void earlyStartup() {
> URI oclURI = URI.createPlatformResourceURI("myPath",false);
> EValidator validator =
> new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
> EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
> }
>
> What's the difference between the two approaches. Why is the
> ModelValidationService not seeing my constraints while the
> Diagnostician does? Is it the right way to use the Diagnostician? Why
> are there multiple approaches anyways?
>
> Cheers,
> Hauke


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Jet template packaging
Next Topic:Programmatically generate model code
Goto Forum:
  


Current Time: Thu Apr 25 17:20:42 GMT 2024

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

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

Back to the top