Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Creating OCL Expressions
Creating OCL Expressions [message #53573] Sun, 06 April 2008 16:06 Go to next message
Eclipse User
Originally posted by: sebstation.freenet.de

Hallo all!

I have a simple problem (I think). I have build an editor, using the GMF
Framework. The editor is used for building other diagrams.
He really works fine and so on... Now my problem is, i want to use
integrate OCL in the following way.

I want to define constraints via Ocl expressions. That means:

With my editor i make a diagram. Then i want to use OCL Expressions to
make constraints on that diagram.
I realize it with a field, where you can write in the Ocl Expression.

Now to the problem:

What i get from the field is a String.
1. How can i convert this string to an OCL Expression?
2. How can i validate this Expression after i convert him?

I know, it sounds not so complicated and i donŽt know, why i donŽt get it,
but iŽll hope you can help me.

Ciao,
Hank
Re: Creating OCL Expressions [message #53600 is a reply to message #53573] Mon, 07 April 2008 13:12 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Hank,

The two most important pieces of the OCL parsing puzzle are the OCL text,
itself (which it sounds like you already have) and the *context* in which
to parse that expression.

The context is one of:

- for invariant constraints, a classifier
- in the Ecore metamodel, some kind of EClassifier
- in the UML metamodel, some kind of Classifier
- for operation pre/post/body conditions, an operation
- Ecore EOperation or UML Operation
- for attribute initial-value or derivation expressions, a property
- Ecore EStructuralFeature or UML Property

Then, just use the org.eclipse.ocl.OCL/org.eclipse.ocl.helper.OCLHelper API
to parse your constraint expression in the appropriate context, using the
EnvironmentFactory implementation for your metamodel. See the Tutorial and
other documentation in the OCL SDK's on-line help for details of how to get
started with the parsing API.

I don't know whether the metamodel for your GMF editor is Ecore, UML, or
some DSL of your own. If the latter, then you will have to implement a
metamodel binding for your metamodel to teach the OCL parser how to
introspect your metamodel to find the UML/EMOF concepts that OCL
understands. The "Advanced Topics" in the SDK docs discuss this, and of
course the existing org.eclipse.ocl.{ecore,uml} plug-ins provide examples
of metamodel bindings.

HTH,

Christian

Hank Thomas wrote:

> Hallo all!
>
> I have a simple problem (I think). I have build an editor, using the GMF
> Framework. The editor is used for building other diagrams.
> He really works fine and so on... Now my problem is, i want to use
> integrate OCL in the following way.
>
> I want to define constraints via Ocl expressions. That means:
>
> With my editor i make a diagram. Then i want to use OCL Expressions to
> make constraints on that diagram.
> I realize it with a field, where you can write in the Ocl Expression.
>
> Now to the problem:
>
> What i get from the field is a String.
> 1. How can i convert this string to an OCL Expression?
> 2. How can i validate this Expression after i convert him?
>
> I know, it sounds not so complicated and i donŽt know, why i donŽt get it,
> but iŽll hope you can help me.
>
> Ciao,
> Hank
Previous Topic:[Announce] MDT OCL 1.2.0M6 is available
Next Topic:Evaluation of allInstances and self usage
Goto Forum:
  


Current Time: Wed Sep 17 13:54:17 GMT 2014

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

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