Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Getting started with OCL/EMF validation
Getting started with OCL/EMF validation [message #68624] Wed, 11 March 2009 15:22 Go to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi,

I'm trying to get started with OCL for EMF. I've scribbled the following
minimal metamodel in emfatic:

@namespace(uri="tree", prefix="tree")
package tree;

class Tree {
attr String label;
val Tree[*] children;
}

made it an ecore, created the genmodel and generated the model, edit and
editor code.

Then I tried to add a dummy OCL constraint by creating a new plugin and
making its plugin.xml look like this:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.emf.validation.constraintProviders">
<constraintProvider
cache="true">
<package
namespaceUri="tree">
</package>
<constraints>
<constraint
id="tree.validation.constraint1"
lang="OCL"
mode="Batch"
name="DummyConstraint"
severity="ERROR"
statusCode="101">
<target
class="Tree">
</target>
<message>
Dummy Error Message
</message>

<![CDATA[
0>1
]]>

</constraint>
</constraints>
</constraintProvider>
</extension>

</plugin>

I'd expect that when I right-click the root of a model in a .tree editor
in my runtime workbench and click "Validate", the constraint (0>1) would
fail for all instances of Tree. Instead I get a "Validation completed
successfully" message.

Any ideas what as to what I'm doing wrong?

Cheers,
Dimitris

P.S. In case it makes a difference, I'm using the Ganymede Modeling distro
Re: Getting started with OCL/EMF validation [message #68823 is a reply to message #68624] Sat, 14 March 2009 18:30 Go to previous message
Eclipse UserFriend
Originally posted by: give.a.damus.gmail.com

Hi, Dimitris,

This hasn't changed substantively from Ganymede to Galileo.

Which "Validate" action are you invoking? The "Validate" action
generated my EMF in the editor plug-in doesn't know anything about this
extended validation framework. You need to implement your own action
that uses the ModelValidationService. An example of this is
demonstrated in the org.eclipse.emf.validation.examples.general plug-in.

In any case, this isn't going to be an OCL-specific problem. You would
have seen the same result if you implemented your constraint as a Java
class.

HTH,

Christian


Dimitris Kolovos wrote:
> Hi,
>
> I'm trying to get started with OCL for EMF. I've scribbled the following
> minimal metamodel in emfatic:
>
> @namespace(uri="tree", prefix="tree")
> package tree;
>
> class Tree {
> attr String label;
> val Tree[*] children;
> }
>
> made it an ecore, created the genmodel and generated the model, edit and
> editor code.
>
> Then I tried to add a dummy OCL constraint by creating a new plugin and
> making its plugin.xml look like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.2"?>
> <plugin>
> <extension
> point="org.eclipse.emf.validation.constraintProviders">
> <constraintProvider
> cache="true">
> <package
> namespaceUri="tree">
> </package>
> <constraints>
> <constraint
> id="tree.validation.constraint1"
> lang="OCL"
> mode="Batch"
> name="DummyConstraint"
> severity="ERROR"
> statusCode="101">
> <target
> class="Tree">
> </target>
> <message>
> Dummy Error Message
> </message>
>
> <![CDATA[
> 0>1
> ]]>
>
> </constraint>
> </constraints>
> </constraintProvider>
> </extension>
>
> </plugin>
>
> I'd expect that when I right-click the root of a model in a .tree editor
> in my runtime workbench and click "Validate", the constraint (0>1) would
> fail for all instances of Tree. Instead I get a "Validation completed
> successfully" message.
>
> Any ideas what as to what I'm doing wrong?
>
> Cheers,
> Dimitris
>
> P.S. In case it makes a difference, I'm using the Ganymede Modeling distro
Previous Topic:Re: collection declarations in OCL expressions
Next Topic:OCL in Profile
Goto Forum:
  


Current Time: Thu Apr 18 07:25:00 GMT 2024

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

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

Back to the top