Author Topic: Find out where a diagram is used (linked)  (Read 826 times)

Alberto Favetta

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Find out where a diagram is used (linked)
« on: July 22, 2013, 06:37:30 pm »
Hi,

sometimes we are used to insert, in a diagram, links to other diagrams.
Is there a way to know where a diagram is linked?
It is possible with elements and even packages (find in all diagrams command) but for the diagrams the command is not available.

thanks!

Alberto

qwerty

  • EA Guru
  • *****
  • Posts: 9373
  • Karma: +146/-137
  • I'm no guru at all
    • View Profile
Re: Find out where a diagram is used (linked)
« Reply #1 on: July 22, 2013, 08:22:35 pm »
Not that easy. You can try this SQL:
Code: [Select]
select o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE, o.name as LName, d.name as DName from t_object as o, t_diagram as d where pdata1 = format(d.Diagram_ID, "#") and Object_Type like "UMLDiagram"  and d.ea_guid = "<Search Term>"Create a SQL search from that. From the context menu of the diagram in question issue Copy Reference/Node GUID and paste the result in the search field.

A dedicated add-in could do better...

q.

Helmut Ortmann

  • EA User
  • **
  • Posts: 915
  • Karma: +39/-1
    • View Profile
Re: Find out where a diagram is used (linked)
« Reply #2 on: August 22, 2013, 07:03:13 pm »
Hi Alberto,

the SQL:
Code: [Select]
Select o.ea_guid AS CLASSGUID, o.object_type As CLASSTYPE,
          o.name, o.Object_Type AS Type,  o.stereotype,'Reference to diagram' As Usage, dia.name As Diagram_Name, dia.diagram_type
#DB=DUMMY#    /*  Reference to Diagram    */ #DB=DUMMY#
from
#DB=JET#        t_object o INNER JOIN t_diagram dia on ( o.pdata1 = Format(dia.diagram_id ))   #DB=JET#
#DB=SQLSVR#        t_object o INNER JOIN t_diagram dia on ( o.pdata1 = dia.diagram_id )   #DB=SQLSVR#
#DB=ORACLE# t_object o INNER JOIN t_diagram dia on ( o.pdata1 = Cast(dia.diagram_id as Varchar2(39))             )   #DB=ORACLE#

where dia.ea_guid = '<Search Term>' AND o.object_type in ('InteractionOccurrence', 'Text', 'UMLDiagram')

UNION
Select o.ea_guid , o.object_type ,
  o.name, o.Object_Type ,  o.stereotype,
  'Composite of diagram' , ' ', ' '
from
t_xref x INNER JOIN t_object o on (x.client = o.ea_guid)

where x.supplier = '<Search Term>'

order by 3,4,5

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Helmut Ortmann

  • EA User
  • **
  • Posts: 915
  • Karma: +39/-1
    • View Profile
Re: Find out where a diagram is used (linked)
« Reply #3 on: August 22, 2013, 07:07:18 pm »
Hi Alberto,

the Browser script to find diagram usage by right click, script, ..

Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
'--------------------------------------------------------------------------------------------------
'- Find Usage of Diagram
'--------------------------------------------------------------------------------------------------
'- Diagram:   Find Usage of selected Diagram'
'
' History:
' 07. December 2011: Created
'
'
'
'
sub main()
      ' check diagram
      'Session.Output "test"
      'Session.Prompt "This script does support diagram items. ", promptOK
      dim guid
      dim id
      dim el
    dim s
      dim selected
      set selected       = Repository.GetContextObject()
      
      dim selectedDiagram as EA.Diagram ' to use intelli sense for Diagram
      Set selectedDiagram = selected  

      '-------------------------------------------------------------------------------------
      'on Diagram
      if not selected is nothing AND selectedDiagram.ObjectType = otDiagram then
                  Repository.RunModelSearch "Diagram usage", selectedDiagram.DiagramGUID, "", ""
                  exit sub
                  'Session.Output CStr(selectedConnector)
                  ' Session.Prompt "This script does not support diagram items of this type.", promptOK
      else
            '-------------------------------------------------------------------------------------
          'in Browser
            ' Get the type of element selected in the Project Browser
            dim treeSelectedType
            treeSelectedType = Repository.GetTreeSelectedItemType()
            
            ' Handling Code: Uncomment any types you wish this script to support
            ' NOTE: You can toggle comments on multiple lines that are currently
            ' selected with [CTRL]+[SHIFT]+[C].
            select case treeSelectedType
      
      case otDiagram
                        dim theDiagram as EA.Diagram
                        set theDiagram = Repository.GetTreeSelectedObject()
                        Repository.RunModelSearch "Find CompositeElement of Diagram", theDiagram.DiagramGUID, "", ""
      '                  
                        
      '      
      ' Code for when a method is selected      
      '            case otMethod
                        case else
                        ' Error message
                              Session.Prompt "This script does not support items of this type.", promptOK
                        
            end select
      end if
      
end sub

main()


Create a script Group Browser Scripts, New VB Script, overwrite it
Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)