One of the main reasons I created my own script library for Sparx EA was to have an efficient way to quickly retrieve and update information for all the child Objects that occur under a given set of parent Objects. From what I can tell, there are 8 main types of Objects: Packages, Elements, Diagrams, DiagramLinks, DiagramObjects, Attributes, Methods and Connectors.
The allowed hierarchy for these objects is:
- Package
- Package (child)
- Element
- Element (child)
- Diagram
- DiagramLink
- Connector (represented by the DiagramLink)
- DiagramObject
- Element (represented by the Diagram Object)
- DiagramLink
- Attribute
- Element (classifier)
- Method
- Element (Parameter Type)
- Element (Return Type)
- Connector
- Element (source)
- Element (target)
- Diagram
- DiagramLink
- Connector
- DiagramObject
- Element
- DiagramLink
As you can see there is a matrix relationship between these objects where the decedent of one path may end up being it’s own parent, e.g. Element 1 -> Diagram 1 -> Diagram Object 1 -> Element 1.
The getHierarchy function in my script library allows me to specify one or more starting Objects (of the same object type), and specify what child objects I’d like returned (by providing an array of object type IDs).