Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Kai H. on March 25, 2011, 11:14:30 pm

Title: Create a shared or composite aggregation
Post by: Kai H. on March 25, 2011, 11:14:30 pm
This is not a question, but an answer from the EA support. I post it here to share it with you.

The folowing code creates a composite aggregation with the black diamond :

Code: [Select]
EA.Connector CompositeConnector = (EA.Connector)destElement.Connectors.AddNew("", "Aggregation");
CompositeConnector.SupplierEnd.Aggregation = 2;
CompositeConnector.ClientID = Composite.ElementID;
CompositeConnector.SupplierID = destElement.ElementID;
CompositeConnector.Update();

to have the white diamond (shared),
Code: [Select]
CompositeConnector.SupplierEnd.Aggregation = 2;has to be replaced by:
Code: [Select]
CompositeConnector.SupplierEnd.Aggregation = 1;or by zero for none.

Kai
Title: Re: Create a shared or composite aggregation
Post by: «Midnight» on April 01, 2011, 11:15:17 pm
FWIW...

Keep in mind that setting the value to zero can leave you open to a side effect. You are left with an aggregation connector that has where the type is invisible to both EA and the user. This can have consequences later if EA treats the connector as an aggregation, but a user thinks it is just a 'plain' link.

An example case is iterating through the model looking for connectors by type. A user may think the 'plain' connector is an association, but EA cannot find it by enumerating "association" type connectors. This can be frustrating for users of an automation tool.

It is possible - even easy! - to set up this situation through automation, much more difficult - perhaps impossible - through the UI. It can be difficult to debug.

David