Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL on properties
OCL on properties [message #28227] Mon, 18 June 2007 21:27 Go to next message
Eclipse User
Originally posted by: anquiroe101.hotmail.com

Hi all :D

I have created a Java class called Property which has the next attributes:
code, name and description. Each property algo has a OCL restriction to
check on it. For example, I have the next property:

Code: P1.1.1.1
Name: Unique AssociationEnd names within the Association
Description: The AssociationEnds must have a unique name within the
Asocciation
OCL: self.allConnections->forAll(r1,r2|r1.name = r2.name implies r1 = r2)

I'm trying to validate this property with this OCL restriction but I don't
know how to do it.
Someone can help me?

Thanks :D
Bye

Anne (OCL noob ;d)
Re: OCL on properties [message #28267 is a reply to message #28227] Tue, 19 June 2007 13:31 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Anne,

You will need more than just Java code, but also an Ecore model or UML model
describing it.

Then, the answer depends on how you intend to store your OCL constraints,
whether in your model (Ecore or UML) or in a separate text document. Have
you had a look at the Tutorial and Programmer's Guide in the SDK, and the
examples? These should give you a good starting point.

Cheers,

Christian


Anne wrote:

> Hi all :D
>
> I have created a Java class called Property which has the next attributes:
> code, name and description. Each property algo has a OCL restriction to
> check on it. For example, I have the next property:
>
> Code: P1.1.1.1
> Name: Unique AssociationEnd names within the Association
> Description: The AssociationEnds must have a unique name within the
> Asocciation
> OCL: self.allConnections->forAll(r1,r2|r1.name = r2.name implies r1 = r2)
>
> I'm trying to validate this property with this OCL restriction but I don't
> know how to do it.
> Someone can help me?
>
> Thanks :D
> Bye
>
> Anne (OCL noob ;d)
Re: OCL on properties [message #28305 is a reply to message #28267] Tue, 19 June 2007 15:05 Go to previous messageGo to next message
Eclipse User
Originally posted by: anquiroe101.hotmail.com

Hi, Christian
Where can I see that Guide and examples??

Thanks for your help :D
Re: OCL on properties [message #28343 is a reply to message #28305] Tue, 19 June 2007 15:22 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Anne,

When you install the OCL SDK (version 1.1 M7/RC0 or later), you should see
the OCL help book in the help window. Do "Help -> Help Contents" on the
main manu bar and you should see:

OCL Developer Guide
Programmer's Guide
... lots of topics ...
Tutorials
OCL Interpreter Tutorial
Examples Guide
OCL Interpreter Example
Reference
OCL API Reference
Extension Points Reference
OCL Compatibility API Reference

To install the example, do "File -> New -> Example..." from the main menu
bar and select the "OCL Plug-ins / OCL Interpreter" item to install the
example project. You can play with it in a run-time workbench to see how
the API works. The tutorial is a step-by-step walk through the
construction of a simpler variant of this example.

Cheers,

Christian

Anne wrote:

> Hi, Christian
> Where can I see that Guide and examples??
>
> Thanks for your help :D
Re: OCL on properties [message #28493 is a reply to message #28343] Wed, 20 June 2007 19:35 Go to previous messageGo to next message
Eclipse User
Originally posted by: anquiroe101.hotmail.com

Hi, Christian
I'm reading what you say me. I think I have to use OCL with Ecore
Metamodel and I haven't to use OCL in EMF (Sorry for my ignorance but I
don't get understand at all OCL in Eclipse).
I have read "Registered OCL Environments" in which I can see how to add
"org.eclipse.ocl.environments" extension point. I think I have to use it
but I don't know how to create the class associated to this extension
point.
I have create a new class which implements EnvironmentFactory but it needs
a lot of methods and I don't know which I have to implement and how to...
:Ž(

Cheers,
Anne
Re: OCL on properties [message #28935 is a reply to message #28493] Wed, 20 June 2007 20:06 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Anne,

Are you certain that you need to create a custom Environment implementation?
You only need to do this if you want to change the way that the OCL parser
parses or evaluates your OCL constraints. If you just need to define and
evaluate OCL constraints, then you can use the existing
EcoreEnvironmentFactory to create Ecore environments. This would be just
like the tutorial illustrates.

You shouldn't be at all concerned with the org.eclipse.ocl.environments
extension point. This is only used by implementations of a metamodel
binding, i.e., if you are adding support for targeting OCL on some
metamodel not already supported (e.g., MOF, SQL, etc.). Currently
supported metamodels (out-of-the-box) are Ecore and UML.

What do you mean by "haven't to use OCL in EMF"? Do you want to use OCL
with POJOs? (plain old Java objects, not modeled using EMF) If that is
the case, then MDT OCL isn't for you: it works only with EMF-based
metamodels, and with models and instances derived from them.

Cheers,

Christian


Anne wrote:

> Hi, Christian
> I'm reading what you say me. I think I have to use OCL with Ecore
> Metamodel and I haven't to use OCL in EMF (Sorry for my ignorance but I
> don't get understand at all OCL in Eclipse).
> I have read "Registered OCL Environments" in which I can see how to add
> "org.eclipse.ocl.environments" extension point. I think I have to use it
> but I don't know how to create the class associated to this extension
> point.
> I have create a new class which implements EnvironmentFactory but it needs
> a lot of methods and I don't know which I have to implement and how to...
> :Ž(
>
> Cheers,
> Anne
Re: OCL on properties [message #28966 is a reply to message #28935] Wed, 20 June 2007 20:31 Go to previous messageGo to next message
Eclipse User
Originally posted by: anquiroe101.hotmail.com

Hi, Christian
I think I have to use OCL with Ecore metamodels.
I'm going to tell you what I need to do :D
I'm creating a plugin Eclipse. I have a properties list implemented like a
LinkedList of Property Class which has a code, a name, a description and a
restriction OCL. When a user selects a property, he can validate his
associated restriction OCL.
An example of property is:
Code: P1.1.2.1
Name: Roots and Generalizations
Description: A root cannot have any Generalizations
OCL: self.isRoot implies self.generalization->isEmpty
User will have loaded a EMF model before checking OCL. For that, I cannot
use OCL like OCL example (library, books,...) because I cannot know what
model will load my user (for that I think I have to use OCL with Ecore
metamodels).

My problem is what I don't understand well how to use OCL here (and with
these properties).

Cheers,
Anne
Re: OCL on properties [message #29004 is a reply to message #28966] Wed, 20 June 2007 20:59 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Anne,

If your user is defining the models, then he/she is also defining the
constraints, right?

If you're using the OCLHelper API, as the tutorial does, then you only need
to know the OCL expression (which your Property has) and the EClass to
which it applies. The author of the OCL must have known what this EClass
is at the time of writing it. So, either your Property will have to know
the EClass (perhaps via an HREF: http://ns/uri/of/the/model#//className) or
the UI by which your user will evaluate the OCL constraints has to be able
to connect EClasses to their corresponding Property objects in order to
parse and evaluate the constraints.

Ultimately, to parse an OCL constraint, you will have to know what the
context EClass is to which it applies. Otherwise, the parser will have no
way of knowing what the names in the text mean. Wherever the tutorial uses
hard-coded EClasses from the EXTLibrary package, your code would use an
EClass that it found at run-time, in the user's model.

Does that make sense? I think I understand, now, what you are doing.

Have a look at the Interactive Console example, especially the
org.eclipse.emf.ocl.examples.interpreter.console.OCLConsoleP age's
evaluate(String) method, to see how it finds an EClass at run-time in which
context to parse and evaluate an OCL expression entered into the console.
It's a little but complicated by the fact that it handles Ecore as well as
UML, and meta-model (M2) versus model (M1) modeling levels, so there's
extra indirection in the code.

The Examples Guide has instructions how to install the example code in your
workspace.

HTH,

Christian


Anne wrote:

> Hi, Christian
> I think I have to use OCL with Ecore metamodels.
> I'm going to tell you what I need to do :D
> I'm creating a plugin Eclipse. I have a properties list implemented like a
> LinkedList of Property Class which has a code, a name, a description and a
> restriction OCL. When a user selects a property, he can validate his
> associated restriction OCL.
> An example of property is:
> Code: P1.1.2.1
> Name: Roots and Generalizations
> Description: A root cannot have any Generalizations
> OCL: self.isRoot implies self.generalization->isEmpty
> User will have loaded a EMF model before checking OCL. For that, I cannot
> use OCL like OCL example (library, books,...) because I cannot know what
> model will load my user (for that I think I have to use OCL with Ecore
> metamodels).
>
> My problem is what I don't understand well how to use OCL here (and with
> these properties).
>
> Cheers,
> Anne
Re: OCL on properties [message #29075 is a reply to message #29004] Wed, 20 June 2007 22:46 Go to previous message
Eclipse User
Originally posted by: anquiroe101.hotmail.com

wow, It seems too difficult... Well, I'm going to try do it :D

Thanks
Cheers,
Anne
Previous Topic:[Announce] MDT OCL 1.1.0 1.1RC4 is available
Next Topic:stereotype's property
Goto Forum:
  


Current Time: Fri Sep 19 02:05:37 GMT 2014

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

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