Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Constraints in meta-model
Constraints in meta-model [message #498183] Sun, 15 November 2009 16:55 Go to next message
Eclipse UserFriend
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() &lt;=
self.parameter-> size()&#xD;&#xA;and&#xD;&#xA;self.subscriber .parameterMapping- >size()
&lt;= 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 #498408 is a reply to message #498183] Mon, 16 November 2009 18:58 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Gilbert,

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)...

Kenn

Gilbert Mirenque wrote:
> 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() &lt;=
> self.parameter-> size()&#xD;&#xA;and&#xD;&#xA;self.subscriber .parameterMapping- >size()
> &lt;= 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 Go to previous messageGo to next message
Eclipse UserFriend
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 #498421 is a reply to message #498411] Mon, 16 November 2009 20:08 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Gilbert,

The extension point is 'org.eclipse.emf.ecore.validation_delegate'. See
details at
http://wiki.eclipse.org/EMF/New_and_Noteworthy/Helios#Regist ering_a_Validation_Delegate.

Kenn

Gilbert Mirenque wrote:
> 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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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?
Previous Topic:Renaming EMF Editor with F2
Next Topic:OPTION_ESCAPE_USING_CDATA question
Goto Forum:
  


Current Time: Fri Apr 26 07:33:05 GMT 2024

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

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

Back to the top