| Home » Modeling » OCL » Iterate over Associations
 Goto Forum:| 
| Iterate over Associations [message #56815] | Tue, 27 May 2008 10:20  |  | 
| Eclipse User  |  |  |  |  | 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 10:53   |  | 
| Eclipse User  |  |  |  |  | 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 #56894 is a reply to message #56868] | Tue, 27 May 2008 21:41  |  | 
| Eclipse User  |  |  |  |  | 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.  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.  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.<BR>
 <BR>
 E.g., given an association:<BR>
 <BR>
    Apple  --------  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"> >(we don't yet support the implicit names defined by</FONT>
 <FONT COLOR="#000000">> 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--
 |  |  |  | 
 
 
 Current Time: Thu Oct 30 21:48:39 EDT 2025 
 Powered by FUDForum . Page generated in 0.03435 seconds |