Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » checking a set of constraints on a model
checking a set of constraints on a model [message #675690] Wed, 01 June 2011 08:11 Go to next message
Joel Greenyer is currently offline Joel GreenyerFriend
Messages: 170
Registered: July 2009
Senior Member
Hi,
instead of checking the integrity of an instance model via annotations in the model ecore file (as for example explained here: http://www.eclipse.org/articles/article.php?file=Article-EMF-Codegen-with-OCL/index.html), I'd like to formulate constraints in a separate OCL file and then check an instance model against the constraints formulated there. This seems to be a common use case, but I can't find any description on how to do that anywhere.

What I've tried so far is parsing an OCL file with a bunch of invariant constraints defined for the different classes in the model.

package myModel
context MyClass
inv smthtrue: true
...
endpackage


After parsing, I have a list of constraints. But what do I do with those? Should I iterate over all objects in the instance model and check the constraints? Since it seems to be a common use case to check invariants in a model, I thought that there was an easier way to do that...

Thanks for helping

Joel
Re: checking a set of constraints on a model [message #675703 is a reply to message #675690] Wed, 01 June 2011 08:55 Go to previous messageGo to next message
Axel Uhl is currently offline Axel UhlFriend
Messages: 40
Registered: July 2009
Member
Hi Joel,

with constraints stored separate there is as far as I know no integration with the EMF Validation framework anymore. Another issue regarding scalability is of course that looping over *all* your elements to validate *all* constraints after *each* change doesn't work so well as soon as your model size grows beyond "trivial."

Ed may have more on the EMF Validation integration issue. What I can recommend is to have a look at the org.eclipse.ocl.examples.impactanalyzer.ImpactAnalyzer set of APIs shipping with the OCL Editors and Examples feature for Indigo. It allows you to register the OCL expressions of your constraints so you receive notifications when the values of those expressions may have changed, also telling you on which elements they may have changed. This limits re-evaluation effort significantly.

For Juno we hope to be able to provide a better and more holistic integration between OCL, EMF Validation and the OCL Impact Analyzer so that incremental re-validation of EMF models based on OCL becomes easier to handle and hence more feasible.

HTH,
-- Axel
Re: checking a set of constraints on a model [message #675726 is a reply to message #675690] Wed, 01 June 2011 10:02 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4153
Registered: July 2009
Senior Member
Hi Joel

You need to use a

org.eclipse.ocl.examples.xtext.completeocl.validation.CompleteOCLEObjectValidator
to make the validation process aware of your extended meta-model. See
the use of Complete OCL for validation in Xtext example from my
EclipseCon tutorial:
http://www.slideshare.net/EdWillink/enrich-your-models-with-ocl.

You cannot do this interactively at present.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347897 raised.

Regards

Ed Willink

On 01/06/2011 09:11, Joel Greenyer wrote:
> Hi,
> instead of checking the integrity of an instance model via annotations
> in the model ecore file (as for example explained here:
> http://www.eclipse.org/articles/article.php?file=Article-EMF-Codegen-with-OCL/index.html),
> I'd like to formulate constraints in a separate OCL file and then
> check an instance model against the constraints formulated there. This
> seems to be a common use case, but I can't find any description on how
> to do that anywhere.
>
> What I've tried so far is parsing an OCL file with a bunch of
> invariant constraints defined for the different classes in the model.
>
> package myModel
> context MyClass
> inv smthtrue: true
> ...
> endpackage
>
>
> After parsing, I have a list of constraints. But what do I do with
> those? Should I iterate over all objects in the instance model and
> check the constraints? Since it seems to be a common use case to check
> invariants in a model, I thought that there was an easier way to do
> that...
>
> Thanks for helping
>
> Joel
Previous Topic:[Announce] Eclipse OCL 3.1.0 RC3 is now available
Next Topic:[Announce] Eclipse OCL 3.1.0 RC4 is now available
Goto Forum:
  


Current Time: Wed Nov 26 10:13:13 GMT 2014

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

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