|Re: automatic use of OCL validations model driven code. [message #54966 is a reply to message #54939]
||Mon, 05 May 2008 22:50
Originally posted by: give.a.damus.gmail.com|
See some replies in-line, below.
On Monday 05-05-2008 (06:30), jason henriksen wrote:
> Hi All,
> I'm trying to do some research about OCL before I dive too far in to
> it. I'm using annotated XSDs via EMF to create a Java model. I am
> NOT using a eclipse UI in order to manipulate that model.
> If I put OCL annotations on some fields of my model are those
> annotations automatically 'baked in' to the java model setters? Or
> do I need to use external code in order to invoke the OCL and
> validate the model after I've set the values?
Probably implementing validation at that level would be overkill. OCL
constraints often check fairly complex structures that are built by
any number of operations in any order; an API cannot effectively check
these conditions in every setter invocation.
> The only usage example I can find for EMF/OCL on the web is here:
> http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-w
> ith-OCL/index.html But this involves changing JET templates which my
> client isn't going to be keen on doing.
But that's the beauty of EMF! It's an extensible *framework*, even in
the code-generation department.
Anyway, there is an open enhancement request in the EMF bugzilla to
provide this kind of integration out-of-the-box.
There is also the EMF Validation Framework's support for extrinsic
definition of OCL constraints (i.e., separately from the model).
> Is there any tool that can take an EObject and auto-magically
> iterate over the fields checking if they have any OCL annotations and
> checking that those OCL requirements are valid? (I'm on the verge of
> writing something like that and it seems like somebody must have done
> it already)
Yep. The EMF Validation Framework component already did this. Check
out the org.eclipse.emf.validation.examples.ocl example plug-in. It
shows a simple way to declare OCL constraints in plugin.xml and also
in *.ocl documents.
> I tried downloading the OCL example project, but had no idea what to
> do with it. It seems like all the examples assume I'm generating a
> UI, but since I'm not it gets kind of confusing. :S
The only example in MDT OCL is an interactive console, which is quite
useful as a scratchpad for developing your OCL constraints. However,
the OCL API doesn't extend into the evaluation of constraint libraries
on models; so far, that has been left to integrations such as the
custom template example (article) and the validation framework.
> Thanks for any advice or documentation,
> Jason Henriksen
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Powered by FUDForum
. Page generated in 0.01456 seconds