Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL and redefinition
OCL and redefinition [message #66402] Mon, 02 February 2009 17:23 Go to next message
Adam Neal is currently offline Adam NealFriend
Messages: 40
Registered: July 2009
Member
Hi,

Is there a way to specify that two elements should be equal, but they are
allowed to exist in different redefinition contexts?

For example, we have redefinable elements e1 and e2, where e2 redefines e1.

I believe that stating: e1 = e2 in OCL will fail since they different
elements.

How do we detail that they must be equal irrespective of their redefinition
context? As far as I can see there is no way, and I am thinking we need to
add some methods into the RedefinableElement section of the UML spec to
allow for this. The simplest way to test for equality in this way would be
to compare the roots of both elements. Thus RedefinableElement would just
need to define the following method;
/* Find the root fragment */

RedefinableElement getRoot() {

if (self.redefinedElement <> null) return self.redefinedElement->getRoot();

return self;

}

Thus the OCL to test equality in a redefintion aware context would look
like: e1->getRoot() = e2->getRoot()



Please let me know if anyone thinks there is already a way to express this,
or if you agree with my proposal...

Regards,

Adam
Re: OCL and redefinition [message #66423 is a reply to message #66402] Mon, 02 February 2009 17:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Adam,

See some comments in-line, below.

HTH,

Christian


Adam wrote:
> Hi,
>
> Is there a way to specify that two elements should be equal, but they are
> allowed to exist in different redefinition contexts?
>
> For example, we have redefinable elements e1 and e2, where e2 redefines e1.
>
> I believe that stating: e1 = e2 in OCL will fail since they different
> elements.

Of course. These are distinct elements in the model, each with their
own identity. It would never make sense for them to be considered as
the same element. The redefinition relationship between them is a
property of the system being modeled, not of these model elements.


> How do we detail that they must be equal irrespective of their redefinition
> context? As far as I can see there is no way, and I am thinking we need to
> add some methods into the RedefinableElement section of the UML spec to
> allow for this. The simplest way to test for equality in this way would be
> to compare the roots of both elements. Thus RedefinableElement would just
> need to define the following method;
> /* Find the root fragment */
>
> RedefinableElement getRoot() {
>
> if (self.redefinedElement <> null) return self.redefinedElement->getRoot();

RedefinableElement::redefinedElement is a collection. This means that
it will never be null (at best empty), and that getRoot() would have to
return the *single* "highest" redefined element.

Of course, there might actually be multiple roots of the redefinition,
anyway (redefinition can be used to merge features defined in separate
hierarchies).


> return self;
>
> }
>
> Thus the OCL to test equality in a redefintion aware context would look
> like: e1->getRoot() = e2->getRoot()

The semantics of eqality of model elements (which is based on identity)
is a core concept in MOF; it cannot be changed. Technically, I suppose,
OclAny::= and OclAny::<> could be redefined for uml::Element, but it
just wouldn't make sense. All kinds of constraints would break. How
would then formulate a constraint that actually needs to check whether
elements are different, regardless of redefinition? What would, for
example, Property.allInstances() return? Only the leaves of
redefinition? That would be the case, because the Set(Property) of all
instances cannot contain duplicates ... You would effectively be erasing
the identity of model elements.


> Please let me know if anyone thinks there is already a way to express this,
> or if you agree with my proposal...

I guess I don't agree.


> Regards,
>
> Adam
>
>
Re: OCL and redefinition [message #66464 is a reply to message #66423] Mon, 02 February 2009 21:55 Go to previous messageGo to next message
Adam Neal is currently offline Adam NealFriend
Messages: 40
Registered: July 2009
Member
Hi Christian, thanks for the comments.

To be clear, I'm not wanting/suggesting to change the OCL "=" or "<>" to be
redef aware. I just want to know how to express it.
Good point with the redefinedElements feature being a list, that was an
oversight on my part as our tooling simplifies it to a single element...

Perhaps the way to express it then would be that they are the same if the
intersection of their redefinition hierarchy is not empty. i.e. at least
one of the elements in the chain to their roots are equal. Although again
it would require adding a method to the RedefinableElement. If you disagree
that adding a method is the way to go, then what do you suggest?

Adam
Re: OCL and redefinition [message #66484 is a reply to message #66464] Tue, 03 February 2009 14:26 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Adam,

I guess I'm not understanding what it is that you are trying to achieve.
Are you looking to extend/redefine the UML semantics to consider
redefining elements as "the same" as the redefined elements? Or, are
you just looking for a query that can be used on occasion (by your tool)
to recognize situations in which an element is occluded by redefinition?

AFAIK, the UML metamodel should already handle this: in the redefining
context classifier, an element that is redefined is not inherited, so
you will find that the "member" property of the classifier includes the
redefining element but not any that it has redefined. Have a look at
how the derivation of Classifier::member uses the Classifier::inherit()
operation to achieve this.

Otherwise, if that isn't quite working, then MDT OCL's custom "closure"
iterator could be quite handy:

context RedefinableElement

-- do I redefine (transitively) another element?
def: hides(other : RedefinableElement) : Boolean =
self->closure(redefinedElement)->includes(other)

-- do I redefine (transitively) the same element as another?
def: isEquivalentTo(other : RedefinableElement) : Boolean =
self->closure(redefinedElement)->intersection(
other->closure(redefinedElement))->notEmpty()

HTH,

Christian


Adam wrote:
> Hi Christian, thanks for the comments.
>
> To be clear, I'm not wanting/suggesting to change the OCL "=" or "<>" to be
> redef aware. I just want to know how to express it.
> Good point with the redefinedElements feature being a list, that was an
> oversight on my part as our tooling simplifies it to a single element...
>
> Perhaps the way to express it then would be that they are the same if the
> intersection of their redefinition hierarchy is not empty. i.e. at least
> one of the elements in the chain to their roots are equal. Although again
> it would require adding a method to the RedefinableElement. If you disagree
> that adding a method is the way to go, then what do you suggest?
>
> Adam
>
>
Previous Topic:Ocl Completion and stereotypes
Next Topic:Compliance of MDT OCL and its usage by other projects
Goto Forum:
  


Current Time: Sat Apr 20 01:05:25 GMT 2024

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

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

Back to the top