Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Run CompleteOCL Validation manually
Run CompleteOCL Validation manually [message #761331] Tue, 06 December 2011 09:51 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

I try to execute CompleteOLC validation of some of my EObjects
programmatically from some Eclipse code.

First, I have some Eclipse earlyStartup to register the OCL file

@Override
public void earlyStartup() {
URI oclURI = URI.createPlatformResourceURI("myPath",false);
EValidator validator =
new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
}

This works fine for validation in the standard EMF tree editor. The OCL
constraints are working fine.
Now I do this from my own code:

MyEObject o = MyFactory.eINSTANCE.createMyEObject();
IValidator<EObject> validator =
ModelValidationService.getInstance()
.newValidator(EvaluationMode.BATCH);
IStatus status = validator.validate(infra);

Afterwards the status says:
"Status OK: org.eclipse.emf.validation code=10 No constraints were
evaluated. null"

Why are no constraints evaluated? Do I have to call validation differently?

Cheers,
Hauke
Re: Run CompleteOCL Validation manually [message #761354 is a reply to message #761331] Tue, 06 December 2011 10:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Hauke

It's not clear to me that you have emulated the automated Eclipse plugin
registrations in your standalone code.

I have often found validations not occurring too. I find the best
approach is to run two debuggers; one on working code and the other on
non-working code, and see where they diverge.

Regards

Ed Willink

On 06/12/2011 09:51, Hauke Fuhrmann wrote:
> Hi there,
>
> I try to execute CompleteOLC validation of some of my EObjects
> programmatically from some Eclipse code.
>
> First, I have some Eclipse earlyStartup to register the OCL file
>
> @Override
> public void earlyStartup() {
> URI oclURI = URI.createPlatformResourceURI("myPath",false);
> EValidator validator =
> new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
> EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
> }
>
> This works fine for validation in the standard EMF tree editor. The
> OCL constraints are working fine.
> Now I do this from my own code:
>
> MyEObject o = MyFactory.eINSTANCE.createMyEObject();
> IValidator<EObject> validator =
> ModelValidationService.getInstance()
> .newValidator(EvaluationMode.BATCH);
> IStatus status = validator.validate(infra);
>
> Afterwards the status says:
> "Status OK: org.eclipse.emf.validation code=10 No constraints were
> evaluated. null"
>
> Why are no constraints evaluated? Do I have to call validation
> differently?
>
> Cheers,
> Hauke
Re: Run CompleteOCL Validation manually [message #761591 is a reply to message #761354] Tue, 06 December 2011 17:40 Go to previous messageGo to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi Ed,

note that I'm not using a standalone application. It is a usual Eclipse
Application.

I use the same earlyStartup code below for the standard EMF Tree Editor
as for my custom code (which is simply executed by pressing a Button).

I was inspired bythe Eclipse help
http://help.eclipse.org/indigo/topic/org.eclipse.ocl.doc/help/Integration.html?path=44_1_7_2#Integration-CompleteOCL
So I would think that registering the validators is correct.

So I guess I execute the validation wrong. Is there another way to call
the built-in validation for EMF?

Cheers,
Hauke

Am 06.12.2011 11:37, schrieb Ed Willink:
> Hi Hauke
>
> It's not clear to me that you have emulated the automated Eclipse plugin
> registrations in your standalone code.
>
> I have often found validations not occurring too. I find the best
> approach is to run two debuggers; one on working code and the other on
> non-working code, and see where they diverge.
>
> Regards
>
> Ed Willink
>
> On 06/12/2011 09:51, Hauke Fuhrmann wrote:
>> Hi there,
>>
>> I try to execute CompleteOLC validation of some of my EObjects
>> programmatically from some Eclipse code.
>>
>> First, I have some Eclipse earlyStartup to register the OCL file
>>
>> @Override
>> public void earlyStartup() {
>> URI oclURI = URI.createPlatformResourceURI("myPath",false);
>> EValidator validator =
>> new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
>> EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
>> }
>>
>> This works fine for validation in the standard EMF tree editor. The
>> OCL constraints are working fine.
>> Now I do this from my own code:
>>
>> MyEObject o = MyFactory.eINSTANCE.createMyEObject();
>> IValidator<EObject> validator =
>> ModelValidationService.getInstance()
>> .newValidator(EvaluationMode.BATCH);
>> IStatus status = validator.validate(infra);
>>
>> Afterwards the status says:
>> "Status OK: org.eclipse.emf.validation code=10 No constraints were
>> evaluated. null"
>>
>> Why are no constraints evaluated? Do I have to call validation
>> differently?
>>
>> Cheers,
>> Hauke
>
Re: Run CompleteOCL Validation manually [message #761598 is a reply to message #761591] Tue, 06 December 2011 17:59 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI Hauke

It's perhaps five years since I looked at EMFv. It never seemed to do
anything useful for me and as I now realize, it's OCL support was one of
many false starts that ultimately led to EMF delegates in Helios.

I always invoke validation using Diagnostician.validate.

Perhaps EMF validation has some bit rot. If you get
Diagnostician.validate to work you might care to report back on why
ModelValidationService is different.

Regards

Ed Willink

On 06/12/2011 17:40, Hauke Fuhrmann wrote:
> Hi Ed,
>
> note that I'm not using a standalone application. It is a usual
> Eclipse Application.
>
> I use the same earlyStartup code below for the standard EMF Tree
> Editor as for my custom code (which is simply executed by pressing a
> Button).
>
> I was inspired bythe Eclipse help
> http://help.eclipse.org/indigo/topic/org.eclipse.ocl.doc/help/Integration.html?path=44_1_7_2#Integration-CompleteOCL
>
> So I would think that registering the validators is correct.
>
> So I guess I execute the validation wrong. Is there another way to
> call the built-in validation for EMF?
>
> Cheers,
> Hauke
>
> Am 06.12.2011 11:37, schrieb Ed Willink:
>> Hi Hauke
>>
>> It's not clear to me that you have emulated the automated Eclipse plugin
>> registrations in your standalone code.
>>
>> I have often found validations not occurring too. I find the best
>> approach is to run two debuggers; one on working code and the other on
>> non-working code, and see where they diverge.
>>
>> Regards
>>
>> Ed Willink
>>
>> On 06/12/2011 09:51, Hauke Fuhrmann wrote:
>>> Hi there,
>>>
>>> I try to execute CompleteOLC validation of some of my EObjects
>>> programmatically from some Eclipse code.
>>>
>>> First, I have some Eclipse earlyStartup to register the OCL file
>>>
>>> @Override
>>> public void earlyStartup() {
>>> URI oclURI = URI.createPlatformResourceURI("myPath",false);
>>> EValidator validator =
>>> new CompleteOCLEObjectValidator(MyPackage.eINSTANCE, oclURI);
>>> EValidator.Registry.INSTANCE.put(MyPackage.eINSTANCE,validator);
>>> }
>>>
>>> This works fine for validation in the standard EMF tree editor. The
>>> OCL constraints are working fine.
>>> Now I do this from my own code:
>>>
>>> MyEObject o = MyFactory.eINSTANCE.createMyEObject();
>>> IValidator<EObject> validator =
>>> ModelValidationService.getInstance()
>>> .newValidator(EvaluationMode.BATCH);
>>> IStatus status = validator.validate(infra);
>>>
>>> Afterwards the status says:
>>> "Status OK: org.eclipse.emf.validation code=10 No constraints were
>>> evaluated. null"
>>>
>>> Why are no constraints evaluated? Do I have to call validation
>>> differently?
>>>
>>> Cheers,
>>> Hauke
>>
>
Previous Topic:CompleteOCL validation step by step
Next Topic:OCL constraints in Ecore problems view messages
Goto Forum:
  


Current Time: Fri Apr 19 10:38:19 GMT 2024

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

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

Back to the top