Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » help with tools to use OCL from the beginning
help with tools to use OCL from the beginning [message #660206] Thu, 17 March 2011 11:15 Go to next message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hello,

I've been reading several resources about OCL (the book of Kleppe et al, and tutorials). I think it's "time to action" and I would like to make my OCL constraints in my models and metamodels.

I have to recognize that I'm quite newbie with Eclipse and their tools also. But I'm not lucky, I got stuck from the very beginning.

I have installed the MDT/OCL 3.0.2 in Eclipse Modeling Tools (Helios release)

I've read something about the OCLinEcore editor, and the OCL console integrated in Eclipse. I've seen an example (RoyalAndLoyal) that comes with the update zip. But I don't find information about how to work with them. I don't know how I can validate the file **.ocl defined on a **.ecore metamodel, and what I have to do to validate a model against the OCL constraints. Just in a word, how I can use the OCL console, and the editor. I would need a tutorial, or just a couple of clues to use the tools.

I would appreciate any help. Thanks in advance.

A.
Re: help with tools to use OCL from the beginning [message #660209 is a reply to message #660206] Thu, 17 March 2011 11:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you got to Help Contents, then follow through OCL to Tutorials you
should find what you want.

Regards

Ed Willink

On 17/03/2011 11:15, irasgo@hotmail.com wrote:
> Hello,
>
> I've been reading several resources about OCL (the book of Kleppe et
> al, and tutorials). I think it's "time to action" and I would like to
> make my OCL constraints in my models and metamodels.
> I have to recognize that I'm quite newbie with Eclipse and their tools
> also. But I'm not lucky, I got stuck from the very beginning.
> I have installed the MDT/OCL 3.0.2 in Eclipse Modeling Tools (Helios
> release)
>
> I've read something about the OCLinEcore editor, and the OCL console
> integrated in Eclipse. I've seen an example (RoyalAndLoyal) that comes
> with the update zip. But I don't find information about how to work
> with them. I don't know how I can validate the file **.ocl defined on
> a **.ecore metamodel, and what I have to do to validate a model
> against the OCL constraints. Just in a word, how I can use the OCL
> console, and the editor. I would need a tutorial, or just a couple of
> clues to use the tools.
>
> I would appreciate any help. Thanks in advance.
>
> A.
Re: help with tools to use OCL from the beginning [message #660982 is a reply to message #660209] Tue, 22 March 2011 14:52 Go to previous messageGo to next message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hello,

Thanks a lot. I checked the Help Contents with more patience and I found the information. Now I think I can use the interactive OCL console more or less, and I can put OCL constraints inside an ecore metamodel and validate its models.

But now I have another doubt:

With the OCL plug-in, in the OCL Examples and Editors, there is an example (RoyalAndLoyal). I see that there are two files RoyalAndLoyal.ecore and RoyalAndLoyal.ocl. The latter is a list of some OCL constraints, applied to the RoyalAndLoyal.ecore metamodel (it has an "import RoyalAndLoyal.ecore" line). What I don't see is what I can do with this RoyalAndLoyal.ocl file. I understand that it's a way to have all the metamodel constraints together, but I don't know how to validate a model of the RoyalAndLoyal metamodel against that RoyalAndLoyal.ocl.

Thanks in advance.

Best regards,
Re: help with tools to use OCL from the beginning [message #660987 is a reply to message #660982] Tue, 22 March 2011 15:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes. Loading Complete OCL is/was a problem.

In the 3.1.0M6 Examples, The Interactive Xtext OCL Console has a Load
Resource... capability that allows you to load the additional Complete
OCL document so that it contributes to the evaluation. This is a very
fresh facility that has not been much tested.

Regards

Ed Willink


On 22/03/2011 07:52, irasgo@hotmail.com wrote:
> Hello,
>
> Thanks a lot. I checked the Help Contents with more patience and I
> found the information. Now I think I can use the interactive OCL
> console more or less, and I can put OCL constraints inside an ecore
> metamodel and validate its models.
>
> But now I have another doubt:
>
> With the OCL plug-in, in the OCL Examples and Editors, there is an
> example (RoyalAndLoyal). I see that there are two files
> RoyalAndLoyal.ecore and RoyalAndLoyal.ocl. The latter is a list of
> some OCL constraints, applied to the RoyalAndLoyal.ecore metamodel (it
> has an "import RoyalAndLoyal.ecore" line). What I don't see is what I
> can do with this RoyalAndLoyal.ocl file. I understand that it's a way
> to have all the metamodel constraints together, but I don't know how
> to validate a model of the RoyalAndLoyal metamodel against that
> RoyalAndLoyal.ocl.
>
> Thanks in advance.
>
> Best regards,
Re: help with tools to use OCL from the beginning [message #661266 is a reply to message #660987] Wed, 23 March 2011 18:22 Go to previous messageGo to next message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hello,

I follow trying to learn more about OCL and how to use it in Eclipse, and I'm quite sad, wondering about its usefulness. I'll try to express myself:

(1) With the interactive OCL console, I only can make queries on a model. So, as I sees, it's only a way to test expressions before writing an invariant.

Moreover, one of my model elements has an attribute (called dateBirth) with EDate as data-type, so with the query self.dateBirth I get the birth-date. But if I want to get only the year of the date, something as self.dateBirth.getYear(), the query doesn't work and I don't have means to look for information about the methods I can use with Date.

Another example, the query self.name.toUpper() gets the name in uppercase. I found it in the Warmer&Kleppe's book and it works, but the OCL Specification mentions the toUpperCase() method !! (and it doesn't work in the interactive OCL console)

(2) I've seen that in the Ecore model it is possible to include OCL constraints. I've tried it, but I can only define invariants (I get errors with 'body', 'def', derivations, and the like, although the OCL Overview in the Help Contents says that these features are supported). Moreover I have to write 'invariant' instead of 'inv' (as the specification says).

It's quite frustrating to read a lot about syntax and usefulness of a language, and then not to have means to put in practice all you've learnt. I don't know if that's only my problem (maybe because I'm in the wrong way) or perhaps it's quite general. In that case, I wonder if people doing metamodeling use OCL


I write all theses reflections just in case I'm in the wrong way and one of you could give us a reference to clarify these doubts or a recommendation to use another tool or plugin.

Thanks in advance. Best regards,
Re: help with tools to use OCL from the beginning [message #661278 is a reply to message #661266] Wed, 23 March 2011 20:20 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

On 23/03/2011 11:22, irasgo@hotmail.com wrote:
> Hello,
>
> I follow trying to learn more about OCL and how to use it in Eclipse,
> and I'm quite sad, wondering about its usefulness. I'll try to express
> myself:
>
> (1) With the interactive OCL console, I only can make queries on a
> model. So, as I sees, it's only a way to test expressions before
> writing an invariant.
Yes, the Interactive OCL Console is interactive; good for peeking or
practicising. You can save and reload expressions. NB you can also Pg
Up/Dn to re-use recent expressions.
>
> Moreover, one of my model elements has an attribute (called dateBirth)
> with EDate as data-type, so with the query self.dateBirth I get the
> birth-date. But if I want to get only the year of the date, something
> as self.dateBirth.getYear(), the query doesn't work and I don't have
> means to look for information about the methods I can use with Date.
You are using OCL that works with properties; not Java, so try using
self.dateBirth.year.
> Another example, the query self.name.toUpper() gets the name in
> uppercase. I found it in the Warmer&Kleppe's book and it works, but
> the OCL Specification mentions the toUpperCase() method !! (and it
> doesn't work in the interactive OCL console)
Unfortunately the spelling evolved.

MDT/OCL implemented toUpper/toLower, then OMG specified
toUpperCase/toLowerCase.

The preliminary OCLinEcore editor in Helios uses a modelled library
which expects toUpperCase(), although the Java level parser still
implements toUpper().

The full functionality OCLinEcore editor in Indigo supports both
spellings to avoid this irritation.
>
> (2) I've seen that in the Ecore model it is possible to include OCL
> constraints. I've tried it, but I can only define invariants (I get
> errors with 'body', 'def', derivations, and the like, although the OCL
> Overview in the Help Contents says that these features are supported).
> Moreover I have to write 'invariant' instead of 'inv' (as the
> specification says).
You can define invariants for EClassifiers, bodies for EOperations and
derivations for EStructuralFeatures. See the OCLinEcore tutorial
accessible via Help->Contents.

OCL by itself, strictly Essential OCL, is unuseable on models. You have
to embed OCL in a surrounding context to provide models to query.

The OCL Console embeds in an EObject selection.

The OCLinEcore editor embeds in an Ecore model. It uses keywords such as
"invariant" with a language that supports Ecore meta-models.

The Complete OCL editor supports the Complete OCL language defined in
Clause 12 of the OCL specification and described in Warmer&Kleppe's
book. This uses keywords such as "inv" in a language that defines an
isolated OCL document that complements a meta-model.

> It's quite frustrating to read a lot about syntax and usefulness of a
> language, and then not to have means to put in practice all you've
> learnt. I don't know if that's only my problem (maybe because I'm in
> the wrong way) or perhaps it's quite general. In that case, I wonder
> if people doing metamodeling use OCL
OCL is not as widely used as it could/should be, since the provision of
GUI functionality is relatively new.

> I write all theses reflections just in case I'm in the wrong way and
> one of you could give us a reference to clarify these doubts or a
> recommendation to use another tool or plugin.

While there are many things that you can do with Eclipse OCL, I cannot
argue with the observation that there are many gaps that make life hard,
particularly for new users. I'm working hard to close these for Indigo.

There are other Open Source EMF-based OCLs. Some are better in specific
areas. I suspect that Eclipse OCL is closest to the specification.

Regards

Ed Willink
Previous Topic:Re: OCL and Xtext combination
Next Topic:Derived attributes differ randomly
Goto Forum:
  


Current Time: Sat Apr 20 00:41:06 GMT 2024

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

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

Back to the top