[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.mdt.uml2.ocl] Re: Using OCL to specify derived References (NOT attributes)

Christian,


Christian W. Damus wrote:

> OCL, as UML, does not distinguish between "attributes" and "references" as
> Ecore does; these are all just Properties.  Thus, "der:" constraints
> specified in OCL can derive read-only values for either of these kinds of
> properties.
> 
> You can use OCL in the EMF code generation process to specify derived
> properties as described in this article:
> 
> http://www.eclipse.org/articles/Article-EMF-Codegen-with-OCL/article.html

I have already stumbled across this article and I am working through it
at the moment (in parallel to a few other things, so progress is slow).
I used an EAnnotation in the Ecore model to specify a method body (but
since I am new to the OCL syntax I yet have to define something useful).
I got the code created as shown in the above tutorial. I also tried to
define a constraint like "myAttribute>0", by using the "inv:" constraint
on the attribute, but apparently, the OCL SDK did not generate code that
checks this invariant upon setting the attribute.
How can this be done?
Is there a way to make constraint checks "deferred" (i.e. allow
inconsistent attributes during a series object modifications and check
for validity after the modifications).

Can you tell me the relationship between the two EMFT projects "OCL" and
"Validation"? Apparently, OCL aims at creating code from OCL constraints
attached as annotations... but what is the scope of Validation? To me it
seems that their goals are at least partially overlapping (Validation
mentions supporting OCL). Validation describes something like the
"deferred constraints".

> 
> There are also plans for the UML2 UML and OCL components to implement
> support for specifying OCL constraints such as property derivations in UML
> models:
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=163808
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=105199

Thanks for this hint, but I hope I can stick with basic Ecore models for
now.

Regards

JÃrgen