Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Hurra on June 08, 2017, 11:19:02 pm

Title: List Composite Diagrams
Post by: Hurra on June 08, 2017, 11:19:02 pm
Hello!

I am interested in adding a diagram as list in another diagram for navigation purposes. The default SQL search string is
Code: [Select]
SELECT
t_object.ea_guid AS CLASSGUID,
t_object.Object_Type AS CLASSTYPE,
t_object.Name,
t_object.Status,
t_object.Author,
t_object.Diagram_ID

FROM t_object
INNER JOIN
(t_diagram INNER JOIN t_diagramobjects ON t_diagram.Diagram_ID = t_diagramobjects.Diagram_ID) ON t_object.Object_ID = t_diagramobjects.Object_ID

WHERE t_diagram.ea_guid='{myElementGUID}'

ORDER by t_object.Name

By adding
Code: [Select]
AND NType=8

in the WHERE statement I get a list of all elements in the diagram with composite, or child, diagrams. However, instead of listing the elements I would like to list the diagrams. I have a hard time figuring out the SQL query for this search.

I should find all diagrams which is composite, or child diagrams, to the elements in the current diagram. With JScript and the API I could figure this out, but not with SQL.

Could I get some pointers?

Thank you!
Title: Re: List Composite Diagrams
Post by: Uffe on June 09, 2017, 12:05:33 am
Hello,


Couple pointers.

If you're looking for diagrams you've got to select from t_diagram. There's no Object_Type there, but the "ea_guid AS CLASSGUID" construct still works to allow you to locate the results in the project browser.

You're on the right track with t_diagramobjects, that's what joins t_object and t_diagram (each row in t_diagramobjects represents one element in one diagram).

However, the GUID of a child diagram does not match its parent element, whether the diagram is composite or not. Instead, match t_diagram.Parent_ID to t_object.Object_ID.

Composite diagrams are normally child diagrams, but they can be moved out of their parent element and placed elsewhere in the project browser (which really screws things up). The composite diagram of an element (an element can have any number of child diagrams, but only one composite diagram) is stored by its GUID in one of the t_object.PDATA columns I think.

HTH,


/Uffe