Book a Demo

Author Topic: How to find composite diagrams via SQL?  (Read 5365 times)

Svend Erik Nygaard

  • EA User
  • **
  • Posts: 131
  • Karma: +2/-2
  • Business Information Architect
    • View Profile
How to find composite diagrams via SQL?
« on: October 07, 2015, 02:21:41 am »
I add a composite diagram to an object:
On a diagram: on an object: context menu -> ”New Child Diagram” -> ”Composite Structure Diagram” (or ”Select Composite Diagram).

If done from an activity in a BPMN process diagram, I can find this diagram by:
t_diagramobjects.Object_ID  -->  t_objects.DATA1  -->  t_diagrams

BUT: If done from a class in a class diagram, I can NOT find it.  How do I find the composite diagram in that case?
« Last Edit: October 07, 2015, 02:23:27 am by svenderiknygaard »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to find composite diagrams via SQL?
« Reply #1 on: October 07, 2015, 03:45:27 am »
Here's what I use to set the composite diagram in VBScript
Code: [Select]
'set the given diagram as composite diagram for this element
function setCompositeDiagram (element, diagram)
      if not diagram is nothing then
            'Tell EA this element is composite
            dim objectQuery
            objectQuery = "update t_object set NType = 8 where Object_ID = " & element.ElementID
            Repository.Execute objectQuery
            if element.Type = "Object" then
                  'Tell EA which diagram is the composite diagram
                  dim xrefQuery
                  [highlight]xrefquery = "insert into t_xref (XrefID, Name, Type, Visibility, Partition, Client, Supplier) values ('"&CreateGuid&"', 'DefaultDiagram', 'element property', 'Public', '0', '"& element.ElementGUID & "', '"& diagram.DiagramGUID &"')"[/highlight]
                  Repository.Execute xrefquery
            elseif element.Type = "Activity" then
                  'for activities we need to update PDATA1 with the diagramID
                  dim updatequery
                  updatequery = "update t_object set PDATA1 = "& diagram.DiagramID & " where Object_ID = " & element.ElementID
                  Repository.Execute updatequery
            end if
      end if
end function

Geert

Svend Erik Nygaard

  • EA User
  • **
  • Posts: 131
  • Karma: +2/-2
  • Business Information Architect
    • View Profile
Re: How to find composite diagrams via SQL?
« Reply #2 on: October 13, 2015, 02:29:34 am »
Quote
xrefquery = "insert into t_xref (XrefID, Name, Type, Visibility, Partition, Client, Supplier) values ('"&CreateGuid&"', 'DefaultDiagram', 'element property', 'Public', '0', '"& element.ElementGUID & "', '"& diagram.DiagramGUID &"')"
Geert

Great, Geert, I hope to try with xref soon.
I had already noticed the NType=8, but not found the xref rows.
Thanks a lot :-)