Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Validation via OCL
EMF Validation via OCL [message #514792] Tue, 16 February 2010 16:25 Go to next message
Dennis sui is currently offline Dennis suiFriend
Messages: 35
Registered: February 2010
Member
Hi,

I try to add some constraints in my ecore model.
In the book "eclipse Modeling Project" there is an example at "Chapter 3.2.4"

This is what i have done:

1. changed the .genmodel:
OCL_ECORE=org.eclipse.ocl.ecore
Dynamic Templates=true
Template Directory = /emf.test/templates

2. added a annotation:
source : http://www.eclipse.org/2007/OCL
->DetailsEntry: key=derived
value=self.id<>null

I just want that the EAttribute "id" can't be null.
If i invoke the validation in my generated Editor via "right click->validate", nothing happens.
Maybe i misunderstand something.

I hope somebody can help me.
Re: EMF Validation via OCL [message #514829 is a reply to message #514792] Tue, 16 February 2010 18:27 Go to previous messageGo to next message
Assen Sharlandjiev is currently offline Assen SharlandjievFriend
Messages: 17
Registered: January 2010
Location: Sofia, Bulgaria
Junior Member

Hi,

1. You need to annotate your EClass with ecore contraints annotation to specify the invariants.
2. For each invariant you need to create OCL annotation with key the name of the invariant and value the OCL invariant expression.
3. Make sure you add the dynamic templates in the folder you specified in your genmodel.
4. Check your generated model validator. Do you see the contraints methods implemented?

You can get sample dynamic templates from Modeling project's CVS. Check the org.eclipse.amalgam project's examples - like the dsl.mindmap.

Hope that this helps Smile


Re: EMF Validation via OCL [message #514863 is a reply to message #514829] Tue, 16 February 2010 18:06 Go to previous messageGo to next message
dennis is currently offline dennisFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,

thanks for your help.
In the meantime i discovered something strange.
It seems that no Validation example works well.
I tried the EMF Validation Framework with OCL Example. No defined
Constaint works in this example, neither Batch nor Live Validation.
Only the normal ecore depencies can be found in the editor when
pressing validate.

I am using Eclipse Galileo

ps: i know, my english is terrible, sorry for that.

Assen Sharlandjiev wrote:

> Hi,
>
> 1. You need to annotate your EClass with ecore contraints annotation
to
> specify the invariants. 2. For each invariant you need to create OCL
> annotation with key the name of the invariant and value the OCL
invariant
> expression. 3. Make sure you add the dynamic templates in the folder
you
> specified in your genmodel.
> 4. Check your generated model validator. Do you see the contraints
> methods implemented?
>
> You can get sample dynamic templates from Modeling project's CVS.
Check
> the org.eclipse.amalgam project's examples - like the dsl.mindmap.
>
> Hope that this helps :)
Re: EMF Validation via OCL [message #515661 is a reply to message #514863] Fri, 19 February 2010 16:29 Go to previous message
Dennis sui is currently offline Dennis suiFriend
Messages: 35
Registered: February 2010
Member
Hi,

I solved the second Problem. I just did not realize that i have to use the "Validate Elements.." Button Wink.

The Validation Example works good but i have a few more questions.

1. The "Location" Column in the Problems View alway shows "Unknown". A double click on a Problem did nothing. How can i solve this ?

2. Is it possible to change the normal validate Button to do the work for my Validation Framework ?

mfg
Dennis

[Updated on: Tue, 23 February 2010 10:22]

Report message to a moderator

Previous Topic:Migrate from Spring+Hibernate to Spring+Teneo
Next Topic:XMLSaveImpl not saving data
Goto Forum:
  


Current Time: Sat Apr 20 03:15:19 GMT 2024

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

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

Back to the top