Navigating UML associations in OCL

847 views Asked by At

I'm trying to navigate UML associations in OCL, using the eclipse OCL implementation. I know that UML Associations are treated as Attributes, and the getAttributes() function called on a Class will return a set containing the Attributes as well as a Property object for each Association. What I need however, is not the Property, but the Class on the other end of the Association.

For bidirectional Associations, the following code works, although it doesn't seem very elegant:

self.getAllAttributes().opposite.class

Not only is it not elegant, it also doesn't work on directed Associations (there is not opposite Property there). Is there a better way of navigating Associations in OCL?

2

There are 2 answers

1
Christian On BEST ANSWER

What about using property.type?

0
lowcoupling On

Why don't you try with the OCL console as explained in this post

http://lowcoupling.com/post/47845805110/ocl-and-the-eclipse-ocl-console