Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » n-ary association
n-ary association [message #760360] Fri, 02 December 2011 07:07 Go to next message
Eclipse UserFriend
Hello,

how can i programmatically create n-ary association? or is that impossible?

normally, i create associations using createAssociation method of
org.eclipse.uml2.uml.Class

class1.createAssociation(..., class2, ...);

it would be nice, if i could create empty association, for example

assoc = model.createAssociation(name);

and then add several association ends to it

assoc.addMemberEnd(assocEnd);

thanks in advance
Re: n-ary association [message #760390 is a reply to message #760360] Fri, 02 December 2011 09:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Emil,

Have you used the debugger to see what's happening under the covers. In
the end, the factory methods on UML2Factory are used to create empty new
things and then they're populated. Methods like createAssociation are
just convenience methods...

On 02/12/2011 8:07 AM, Emil Huseynli wrote:
> Hello,
>
> how can i programmatically create n-ary association? or is that
> impossible?
>
> normally, i create associations using createAssociation method of
> org.eclipse.uml2.uml.Class
>
> class1.createAssociation(..., class2, ...);
>
> it would be nice, if i could create empty association, for example
>
> assoc = model.createAssociation(name);
>
> and then add several association ends to it
>
> assoc.addMemberEnd(assocEnd);
>
> thanks in advance


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: n-ary association [message #760401 is a reply to message #760390] Fri, 02 December 2011 09:56 Go to previous messageGo to next message
Eclipse UserFriend
i'll take a look at sources then, thanks!

On 02.12.2011 10:16, Ed Merks wrote:
> Emil,
>
> Have you used the debugger to see what's happening under the covers. In
> the end, the factory methods on UML2Factory are used to create empty new
> things and then they're populated. Methods like createAssociation are
> just convenience methods...
>
> On 02/12/2011 8:07 AM, Emil Huseynli wrote:
>> Hello,
>>
>> how can i programmatically create n-ary association? or is that
>> impossible?
>>
>> normally, i create associations using createAssociation method of
>> org.eclipse.uml2.uml.Class
>>
>> class1.createAssociation(..., class2, ...);
>>
>> it would be nice, if i could create empty association, for example
>>
>> assoc = model.createAssociation(name);
>>
>> and then add several association ends to it
>>
>> assoc.addMemberEnd(assocEnd);
>>
>> thanks in advance
Re: n-ary association [message #760410 is a reply to message #760390] Fri, 02 December 2011 10:11 Go to previous messageGo to next message
Eclipse UserFriend
i.e. it's theoretically possible to create n-ary associations?

On 02.12.2011 10:16, Ed Merks wrote:
> Emil,
>
> Have you used the debugger to see what's happening under the covers. In
> the end, the factory methods on UML2Factory are used to create empty new
> things and then they're populated. Methods like createAssociation are
> just convenience methods...
>
> On 02/12/2011 8:07 AM, Emil Huseynli wrote:
>> Hello,
>>
>> how can i programmatically create n-ary association? or is that
>> impossible?
>>
>> normally, i create associations using createAssociation method of
>> org.eclipse.uml2.uml.Class
>>
>> class1.createAssociation(..., class2, ...);
>>
>> it would be nice, if i could create empty association, for example
>>
>> assoc = model.createAssociation(name);
>>
>> and then add several association ends to it
>>
>> assoc.addMemberEnd(assocEnd);
>>
>> thanks in advance
Re: n-ary association [message #760412 is a reply to message #760410] Fri, 02 December 2011 10:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Emil,

I'm really not sure. Did you look at what's happening under the covers
for the bidirectional case? Does the Association API appear to allow
more than two ends? Have you consulted the UML specification or some
other source of information for the answer?



On 02/12/2011 11:11 AM, Emil Huseynli wrote:
> i.e. it's theoretically possible to create n-ary associations?
>
> On 02.12.2011 10:16, Ed Merks wrote:
>> Emil,
>>
>> Have you used the debugger to see what's happening under the covers. In
>> the end, the factory methods on UML2Factory are used to create empty new
>> things and then they're populated. Methods like createAssociation are
>> just convenience methods...
>>
>> On 02/12/2011 8:07 AM, Emil Huseynli wrote:
>>> Hello,
>>>
>>> how can i programmatically create n-ary association? or is that
>>> impossible?
>>>
>>> normally, i create associations using createAssociation method of
>>> org.eclipse.uml2.uml.Class
>>>
>>> class1.createAssociation(..., class2, ...);
>>>
>>> it would be nice, if i could create empty association, for example
>>>
>>> assoc = model.createAssociation(name);
>>>
>>> and then add several association ends to it
>>>
>>> assoc.addMemberEnd(assocEnd);
>>>
>>> thanks in advance
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: n-ary association [message #760416 is a reply to message #760412] Fri, 02 December 2011 10:18 Go to previous messageGo to next message
Eclipse UserFriend
ok, have to investigate a little bit

On 02.12.2011 11:14, Ed Merks wrote:
> Emil,
>
> I'm really not sure. Did you look at what's happening under the covers
> for the bidirectional case? Does the Association API appear to allow
> more than two ends? Have you consulted the UML specification or some
> other source of information for the answer?
>
>
>
> On 02/12/2011 11:11 AM, Emil Huseynli wrote:
>> i.e. it's theoretically possible to create n-ary associations?
>>
>> On 02.12.2011 10:16, Ed Merks wrote:
>>> Emil,
>>>
>>> Have you used the debugger to see what's happening under the covers. In
>>> the end, the factory methods on UML2Factory are used to create empty new
>>> things and then they're populated. Methods like createAssociation are
>>> just convenience methods...
>>>
>>> On 02/12/2011 8:07 AM, Emil Huseynli wrote:
>>>> Hello,
>>>>
>>>> how can i programmatically create n-ary association? or is that
>>>> impossible?
>>>>
>>>> normally, i create associations using createAssociation method of
>>>> org.eclipse.uml2.uml.Class
>>>>
>>>> class1.createAssociation(..., class2, ...);
>>>>
>>>> it would be nice, if i could create empty association, for example
>>>>
>>>> assoc = model.createAssociation(name);
>>>>
>>>> and then add several association ends to it
>>>>
>>>> assoc.addMemberEnd(assocEnd);
>>>>
>>>> thanks in advance
>>
Re: n-ary association [message #760472 is a reply to message #760410] Fri, 02 December 2011 13:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

About a year ago, I succeeded in creating N-ary associations in Papyrus,
although at that time the ergonomics was klunky so I raised a Bugzilla.

I think you need an AssociationClass to orchestrate the multiple 1:1
'sub-associations'.

That would rather confirm that UML2's implementation of the UML model is
accurate. The new UML 2.4.1 version of MDT/UML2 should be even more
accurate since the UML meta-model is directly generated from the OMG
specification meta-model.

Regards

Ed Willink

On 02/12/2011 10:11, Emil Huseynli wrote:
> i.e. it's theoretically possible to create n-ary associations?
>
> On 02.12.2011 10:16, Ed Merks wrote:
>> Emil,
>>
>> Have you used the debugger to see what's happening under the covers. In
>> the end, the factory methods on UML2Factory are used to create empty new
>> things and then they're populated. Methods like createAssociation are
>> just convenience methods...
>>
>> On 02/12/2011 8:07 AM, Emil Huseynli wrote:
>>> Hello,
>>>
>>> how can i programmatically create n-ary association? or is that
>>> impossible?
>>>
>>> normally, i create associations using createAssociation method of
>>> org.eclipse.uml2.uml.Class
>>>
>>> class1.createAssociation(..., class2, ...);
>>>
>>> it would be nice, if i could create empty association, for example
>>>
>>> assoc = model.createAssociation(name);
>>>
>>> and then add several association ends to it
>>>
>>> assoc.addMemberEnd(assocEnd);
>>>
>>> thanks in advance
>
Re: n-ary association [message #760532 is a reply to message #760472] Fri, 02 December 2011 17:45 Go to previous messageGo to next message
Carsten Reckord is currently offline Carsten ReckordFriend
Messages: 139
Registered: July 2009
Senior Member
Hi Ed, Emil,

For an example of how to create an n-ary Association, see my reply to Emil's
other question below.

On 02.12.2011 14:53, Ed Willink wrote:
> I think you need an AssociationClass to orchestrate the multiple 1:1
> 'sub-associations'.

This is a common misconception about n-ary associations in the UML. There
really are no "multiple 1:1 sub-associations" in an n-ary association.

This is due to the tuple semantics of associations in the UML. An "instance"
of an association (which usually doesn't explicitly exist in most
implementations of binary associations) is a tuple of all its ends (i.e. a
3-tuple for a ternary assoc etc...). And in terms of navigability, you can't
just navigate from one end of a ternary association to one other end (in
fact a single end's multiplicity isn't even well-defined with respect to
just a single other end). Instead, for an n-ary assoc, you always need (n-1)
ends in order to navigate to the remaining end (i.e. a 2-tuple of end values
to navigate to the remaining end for a ternary assoc).


Best regards,
Carsten
Re: n-ary association [message #760578 is a reply to message #760532] Sat, 03 December 2011 05:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Carsten

You seem very well-informed. In what context, with what tools, have you
been using/considering n-ary associations.

My interest arose from trying to make sense of the OCL syntax for binary
and see whether an alignment with UML was possible for n-ary associations.

As you say, an n-ary association instance requires a tuple, which a
practical OCL run-time could realise via an implicit AssociationClass,
so that navigation can proceed in three stages

a) from a first source to all tuples
b) filtering of all tuples to one/some by selection with respect to
second/third/fourth sources
c) navigation from tuple(s) to target(s)

This made me think that UML::Association and UML::AssociationClass are
merged when deriving an OCL::Association, which at least solves the
modelling, leaving only the concrete syntax to align.

Regards

Ed Willink


On 02/12/2011 17:45, Carsten Reckord wrote:
> Hi Ed, Emil,
>
> For an example of how to create an n-ary Association, see my reply to Emil's
> other question below.
>
> On 02.12.2011 14:53, Ed Willink wrote:
>> I think you need an AssociationClass to orchestrate the multiple 1:1
>> 'sub-associations'.
> This is a common misconception about n-ary associations in the UML. There
> really are no "multiple 1:1 sub-associations" in an n-ary association.
>
> This is due to the tuple semantics of associations in the UML. An "instance"
> of an association (which usually doesn't explicitly exist in most
> implementations of binary associations) is a tuple of all its ends (i.e. a
> 3-tuple for a ternary assoc etc...). And in terms of navigability, you can't
> just navigate from one end of a ternary association to one other end (in
> fact a single end's multiplicity isn't even well-defined with respect to
> just a single other end). Instead, for an n-ary assoc, you always need (n-1)
> ends in order to navigate to the remaining end (i.e. a 2-tuple of end values
> to navigate to the remaining end for a ternary assoc).
>
>
> Best regards,
> Carsten
Previous Topic:Set and Bag types
Next Topic:org.eclipse.uml2.uml.Type::createAssociation
Goto Forum:
  


Current Time: Fri Mar 29 07:24:08 GMT 2024

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

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

Back to the top