Getting started with OCL/EMF validation [message #68624] |
Wed, 11 March 2009 11:22  |
Eclipse User |
|
|
|
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 14:30  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02872 seconds