Constraints in meta-model [message #498183] |
Sun, 15 November 2009 16:55 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
With the fix of bug 255786 [1] I was confident of getting evaluated my
ocl constraints, annotated in my meta-model, in the generated EMF
editor. So I downloaded Helios and the EMF milestone 2.6.0M3 and tried
it out. I created a model with the generated editor and put a violation
of a constraint into it. But with right-clicking --> Validate I got the
message that the model is valid :( Now I'm asking myself what I did
wrong. Maybe you can help me? I added to all classes which have to be
cosntrained an EAnnotation with
source="http://www.eclipse.org/2007/OCL". As key I took a meaningful
name and as value I specified the constraint. Here is an example from
the ecore file of my meta-model:
<eAnnotations source="http://www.eclipse.org/2007/OCL">
<details key="equal_mappings_count"
value="self.publisher.parameterMapping->size() <=
self.parameter-> size()
and
self.subscriber .parameterMapping- >size()
<= self.parameter->size()"/>
</eAnnotations>
Is my procedure correct and how do I get the constraints evaluated in
the editor?
best regards,
Gilbert
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=255786
|
|
|
|
Re: Constraints in meta-model [message #498411 is a reply to message #498408] |
Mon, 16 November 2009 19:19 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
Thanks for your answer Kenn.
> The necessary changes have yet to be committed to provide an OCL
> validation delegate implementation - see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=191689. So, unless you've
> implemented a delegate for OCL and registered it, you shouldn't expect
> constraints to be automatically validated (yet)...
Just for curiosity - at which extension point one has to register such
an implementation?
|
|
|
|
Re: Constraints in meta-model [message #498496 is a reply to message #498421] |
Tue, 17 November 2009 09:18 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
Thanks Kenn for the link. It is very helpful and I tried it out. After
adding the needed annotations to the package and to the meta-classes I
re-generated the model code. But the generated EObjectValidator contains
errors in that way that the protected variables for the expressions are
multiple times declared and have syntax errors. For example the
following code was generated:
protected static final String
UI_COMPONENT__XOR_URL_CATEGORY__EEXPRESSION = "not self.url.oclIsUndefined()
protected static final String
UI_COMPONENT__XOR_URL_CATEGORY__EEXPRESSION = "implies
self.classificationCategory.oclIsUndefined()
protected static final String
UI_COMPONENT__XOR_URL_CATEGORY__EEXPRESSION = "and
protected static final String
UI_COMPONENT__XOR_URL_CATEGORY__EEXPRESSION = "self.url.oclIsUndefined()
protected static final String
UI_COMPONENT__XOR_URL_CATEGORY__EEXPRESSION = "implies not
self.classificationCategory.oclIsUndefined()";
I found out that the reason are the line feeds which a have used in my
expressions because of better appearance and structuring. If I remove
them the variables will be generated correctly. It would be nice if it
was possible to add the line feeds because long expressions are better
readable.
|
|
|
Re: Constraints in meta-model [message #498519 is a reply to message #498421] |
Tue, 17 November 2009 10:24 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
Kenn, my constraints will now be checked but what can I do to popup a
message if a constraint is violated? While debugging I see that my
ValidationDelegate will be invoked with the expressions I specified but
the message " is valid" will be displayed always.
|
|
|
Re: Constraints in meta-model [message #498533 is a reply to message #498519] |
Tue, 17 November 2009 11:23 |
Eclipse User |
|
|
|
Originally posted by: formatzeh.gmx.de
> the message " is valid" will be displayed always.
Ok this message was always be displayed because of an error in my
expression. But more meaningful messages than "constraint xyz is
violated..." would be nice. Is it possible anyhow?
|
|
|
Powered by
FUDForum. Page generated in 0.03788 seconds