View Question

add multiplicity to association


Do you have a function that adds the multiplicity to the association? I can't find it in the Astah SDK API. Can you give me an example also?

Thank you a lot.

Product: Astah Professional

Hi Ano,

You cannot add multiplicity to the association but to the Association End. So get Association End from Association, and then add multiplicity to the Association End. You can get Association End with IAssociation#getMemberEnds() method.

Hope this figure helps you to understand how API works towards the models on diagram ("JUDE" is a former name of Astah):

Image Text

Cheers, SJ

Can you give me a working example?

When I look for getMemberEnds () I cant add the multiplicity by the method setMultiplicityByStrings. How can I add multiplicity to an association end?

Hi Ano,

A working example is as follows. This example sets one end to 0..1 and the other to 0..*

ProjectAccessor prjAccessor = AstahAPI.getAstahAPI().getProjectAccessor();`
INamedElement[] elements = prjAccessor.findElements(IAssociation.class);
IAssociation association = (IAssociation) elements[0];
IAttribute[] ends = association.getMemberEnds();
String[][] ranges0 = {{"0", "1"}};
String[][] ranges1 = {{"0", "*"}};

Cheers, Nakaya

Answer Question

This content has the following tags: