Home » Modeling » OCL » OCL on properties
OCL on properties [message #28227] |
Mon, 18 June 2007 17:27  |
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 09:31   |
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 #28935 is a reply to message #28493] |
Wed, 20 June 2007 16:06   |
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 #29004 is a reply to message #28966] |
Wed, 20 June 2007 16:59   |
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
|
|
| |
Goto Forum:
Current Time: Wed Jul 23 15:11:28 EDT 2025
Powered by FUDForum. Page generated in 0.05731 seconds
|