Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » handling setters.
handling setters. [message #35061] Thu, 02 August 2007 09:06 Go to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

Hello,

I want to use OCL to create/modify model elements. I know that it is /bad/
because OCL is free side effect and has been designed as a query language, but I
have to do it for my own use (really local use).

I slightly modified OCLSyntaxHelper/ValidationVisitor to accept all operations
(not only the query operation). It "works". I can create class, parameter and so
on.

But I can't get access to the setters. For example, if the context is a UML
Class I would expect to retrieve the operation setName(String name). When I
debug it, I can see the operations defined by Class but I can't find any
"setter". So I looked through the hierarchy up to the NamedElement, but it
doesn't also have any setter.

So my question is where are declared theses operations and how could I include
them.

thanks a lot.

--
F. Lagarde
Re: handling setters. [message #35108 is a reply to message #35061] Thu, 02 August 2007 19:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, François,

The problem is, that these setters are not declared anywhere. They are mere
a Java-language pattern for defining mutable attributes (think JavaBeans).
Metamodels such as Ecore and UML only describe attributes as being either
read-only (in which case a Java API only has a getter) or read/write.

In order to support modification of attributes (which, in a Java binding,
would use setters) OCL would have had to provide an assignment syntax,
which is doesn't for the reasons that you indicated.

You would probably have to invent mutators as "additional operations" in
your custom environment. Possibly you could do that automatically for all
properties ... Or, your application could use OCL as a means to specify
values to assign to properties, and find some other means to specify the
assigments, themselves.

Languages such as QVT extend OCL by providing assignment semantics, so you
might even have a look at what the M2M and GMT projects can offer in that
department.

Cheers,

Christian


François Lagarde wrote:

> Hello,
>
> I want to use OCL to create/modify model elements. I know that it is
> /bad/ because OCL is free side effect and has been designed as a query
> language, but I have to do it for my own use (really local use).
>
> I slightly modified OCLSyntaxHelper/ValidationVisitor to accept all
> operations (not only the query operation). It "works". I can create class,
> parameter and so on.
>
> But I can't get access to the setters. For example, if the context is a
> UML Class I would expect to retrieve the operation setName(String name).
> When I debug it, I can see the operations defined by Class but I can't
> find any "setter". So I looked through the hierarchy up to the
> NamedElement, but it doesn't also have any setter.
>
> So my question is where are declared theses operations and how could I
> include them.
>
> thanks a lot.
>
Re: handling setters. [message #35133 is a reply to message #35108] Fri, 03 August 2007 06:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 08/02 about 09h, "Christian" (Christian W Damus) wrote:

Christian> You would probably have to invent mutators as "additional
Christian> operations" in your custom environment. Possibly you could do
Christian> that automatically for all properties ...

It's what I did at first. I created some setter operations in the Environment,
then I use reflexives mechanisms to bind it to the Java operation. But it is not
really nice.

Christian> Languages such as QVT extend OCL by providing assignment
Christian> semantics, so you might even have a look at what the M2M and
Christian> GMT projects can offer in that department.

I also thought about the QVT project. But from what I have read (ATL) it seems
not possible to embed a "script" to modify locally an element (I want a
endogeneous transformation). Maybe MofScript[1] could also be a good candidate,
but it seems that there are no way to execute "local fragment".

For example I would like to execute a small modifications in the context of a
existing object element. For example, if the context is a class:

,----
| Property myProperty = new Property('myNewProperty')
| self.name = 'MyName'
| self.ownedAttribute->add(myProperty)
`----


Reference(s):
[1] http://www.eclipse.org/gmt/mofscript/about.php

--
F. Lagarde
Re: handling setters. [message #35161 is a reply to message #35133] Fri, 03 August 2007 15:13 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi François,

I'd just like to inform you that EOL from the Epsilon GMT component
supports in-place model transformations. You can watch a demo showing
this at www.eclipse.org/gmt/epsilon/cinema/ (Populating an OO model
using EOL (Part 2)).

Cheers,
Dimitrios

François Lagarde wrote:
> In the last post, on 08/02 about 09h, "Christian" (Christian W Damus) wrote:
>
> Christian> You would probably have to invent mutators as "additional
> Christian> operations" in your custom environment. Possibly you could do
> Christian> that automatically for all properties ...
>
> It's what I did at first. I created some setter operations in the Environment,
> then I use reflexives mechanisms to bind it to the Java operation. But it is not
> really nice.
>
> Christian> Languages such as QVT extend OCL by providing assignment
> Christian> semantics, so you might even have a look at what the M2M and
> Christian> GMT projects can offer in that department.
>
> I also thought about the QVT project. But from what I have read (ATL) it seems
> not possible to embed a "script" to modify locally an element (I want a
> endogeneous transformation). Maybe MofScript[1] could also be a good candidate,
> but it seems that there are no way to execute "local fragment".
>
> For example I would like to execute a small modifications in the context of a
> existing object element. For example, if the context is a class:
>
> ,----
> | Property myProperty = new Property('myNewProperty')
> | self.name = 'MyName'
> | self.ownedAttribute->add(myProperty)
> `----
>
>
> Reference(s):
> [1] http://www.eclipse.org/gmt/mofscript/about.php
>
Re: handling setters. [message #35186 is a reply to message #35161] Fri, 03 August 2007 22:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 08/03 about 05h, "Dimitrios" (Dimitrios Kolovos) wrote:

Dimitrios> Hi François, I'd just like to inform you that EOL from the
Dimitrios> Epsilon GMT component supports in-place model
Dimitrios> transformations.

thanks for your pointer. It seems to meinteresting. However, I looked at the
documentation to figure out how I may use it in "embedded fashion" with Java but
didn't find any information.

Even if my question is borderline to this topic, could you indicate me how may I
deal with it. Does epsilon provides java API to do something:

epsilonexpression myQuery= epsilon.query("my epsilon query");
epsilon.evaluate(myContextualObject, myQuery);

--
F. Lagarde
Re: handling setters. [message #35305 is a reply to message #35186] Mon, 06 August 2007 09:31 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi François,

I've uploaded an example of running EOL from Java at
http://www.eclipse.org/gmt/epsilon/doc/examples.php (Running EOL from Java).

Cheers,
Dimitrios

François Lagarde wrote:
> In the last post, on 08/03 about 05h, "Dimitrios" (Dimitrios Kolovos) wrote:
>
> Dimitrios> Hi François, I'd just like to inform you that EOL from the
> Dimitrios> Epsilon GMT component supports in-place model
> Dimitrios> transformations.
>
> thanks for your pointer. It seems to meinteresting. However, I looked at the
> documentation to figure out how I may use it in "embedded fashion" with Java but
> didn't find any information.
>
> Even if my question is borderline to this topic, could you indicate me how may I
> deal with it. Does epsilon provides java API to do something:
>
> epsilonexpression myQuery= epsilon.query("my epsilon query");
> epsilon.evaluate(myContextualObject, myQuery);
>
Previous Topic:NPE in OCLSyntaxHelper getPropertyChoices
Next Topic:define a operation for a given type.
Goto Forum:
  


Current Time: Fri Apr 19 21:14:04 GMT 2024

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

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

Back to the top