Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Iterate over Associations
Iterate over Associations [message #56815] Tue, 27 May 2008 14:20 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hi christian and others,

In my language I interpret Associations (with all ends by the Association) as
Set instances, (and also as Types), so I can iterate over an Associations contents:

someAssociation.select( i:someAssociation | condition);

Afais OCL does not have this notion, am I right?

Thanks,
Felix
Re: Iterate over Associations [message #56842 is a reply to message #56815] Tue, 27 May 2008 14:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Felix,

Yes, the instances of associations are, essentially, tuples whose values
are the objects referenced by the member ends. In the context of an
Association, you will see that the multiplicity of a member end (from
the perspective of the association) is exactly 1 (try it in the
interactive console example; it should work).

Given an association named A, you can do an expression like this:

A.allInstances->select(a : A | <condition-on-ends>)

because Associations are classifiers and, therefore, types in the OCL
type system. This should work in MDT OCL, so long as you give your
associations names (we don't yet support the implicit names defined by
UML).

HTH,

Christian


On Tue, 2008-05-27 at 16:20 +0200, Felix Dorner wrote:
> Hi christian and others,
>
> In my language I interpret Associations (with all ends by the Association) as
> Set instances, (and also as Types), so I can iterate over an Associations contents:
>
> someAssociation.select( i:someAssociation | condition);
>
> Afais OCL does not have this notion, am I right?
>
> Thanks,
> Felix
>
>
Re: Iterate over Associations [message #56868 is a reply to message #56842] Tue, 27 May 2008 15:13 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Christian W. Damus wrote:

Hi Christian,

i forgot about the mighty allInstances operator. Thanks.

>(we don't yet support the implicit names defined by
> UML).

I didn't know that there's an implicit name, can I find about this in the OCL
spec or the UML superstructure?


Felix
Re: Iterate over Associations [message #56894 is a reply to message #56868] Wed, 28 May 2008 01:41 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-o/69hPCscRsGl6BjCjrg
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Felix,

I'm not sure. A quick look for it in the UML Superstructure didn't turn
it up, but then I didn't try very hard.

You might try asking on the UML2 newsgroup ... I know Kenn followed some
algorithm in the naming of associations in the MDT UML2 implementation.
The implicit names provided by UML2 look like A_<end1-name>_<end2-name>,
where <end1-name> and <end2-name> may, themselves, be implicit role
names based on the end classifier names.

E.g., given an association:

Apple -------- Tree

with unnamed ends, the implicit name of the association is A_apple_tree
or some such.

Cheers,

Christian


On Tue, 2008-05-27 at 17:13 +0200, Felix Dorner wrote:

> Christian W. Damus wrote:
>
> Hi Christian,
>
> i forgot about the mighty allInstances operator. Thanks.
>
> >(we don't yet support the implicit names defined by
> > UML).
>
> I didn't know that there's an implicit name, can I find about this in the OCL
> spec or the UML superstructure?
>
>
> Felix

--=-o/69hPCscRsGl6BjCjrg
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Felix,<BR>
<BR>
I'm not sure.&nbsp; A quick look for it in the UML Superstructure didn't turn it up, but then I didn't try very hard.<BR>
<BR>
You might try asking on the UML2 newsgroup ... I know Kenn followed some algorithm in the naming of associations in the MDT UML2 implementation.&nbsp; The implicit names provided by UML2 look like A_&lt;end1-name&gt;_&lt;end2-name&gt;, where &lt;end1-name&gt; and &lt;end2-name&gt; may, themselves, be implicit role names based on the end classifier names.<BR>
<BR>
E.g., given an association:<BR>
<BR>
&nbsp;&nbsp; Apple&nbsp; --------&nbsp; Tree<BR>
<BR>
with unnamed ends, the implicit name of the association is A_apple_tree or some such.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Tue, 2008-05-27 at 17:13 +0200, Felix Dorner wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Christian W. Damus wrote:</FONT>

<FONT COLOR="#000000">Hi Christian,</FONT>

<FONT COLOR="#000000">i forgot about the mighty allInstances operator. Thanks.</FONT>

<FONT COLOR="#000000"> &gt;(we don't yet support the implicit names defined by</FONT>
<FONT COLOR="#000000">&gt; UML).</FONT>

<FONT COLOR="#000000">I didn't know that there's an implicit name, can I find about this in the OCL </FONT>
<FONT COLOR="#000000">spec or the UML superstructure?</FONT>


<FONT COLOR="#000000">Felix</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-o/69hPCscRsGl6BjCjrg--
Previous Topic:Re: [OCL] AstNode - startPosition is a transient attribute
Next Topic:Re: Getting tha value of an enumeration attribute (eGet())
Goto Forum:
  


Current Time: Thu Apr 25 15:26:09 GMT 2024

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

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

Back to the top