checking a set of constraints on a model [message #675690] |
Wed, 01 June 2011 04:11  |
Eclipse User |
|
|
|
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 #675726 is a reply to message #675690] |
Wed, 01 June 2011 06:02  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.74464 seconds