Author Topic: EA Object API for "find in all diagrams" by GUID  (Read 4002 times)

Alexander.Golyshkin

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
EA Object API for "find in all diagrams" by GUID
« on: December 25, 2023, 07:24:24 pm »
Does exist any object API (Project/Repository/etc) for for "find in all diagrams" element by it's GUID?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13295
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA Object API for "find in all diagrams" by GUID
« Reply #1 on: December 25, 2023, 10:01:23 pm »
Not directly.

First do a Repository.SQLQuery for the diagramID's, and then get the diagrams from their ID

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: EA Object API for "find in all diagrams" by GUID
« Reply #2 on: December 26, 2023, 04:04:48 am »
I made me a SQL to find any guid inn almost anything. Actually I used it in a script to show the result directly in the browser.

q.

Alexander.Golyshkin

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: EA Object API for "find in all diagrams" by GUID
« Reply #3 on: December 26, 2023, 06:25:59 pm »
OK, I understood that there is no specific object API for that. So, could you help me to make a SQL query which will find any diagrams GUIDs in model where contain a specific GUID element?

Alexander.Golyshkin

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: EA Object API for "find in all diagrams" by GUID
« Reply #4 on: December 26, 2023, 08:12:37 pm »
I just did a couple experiments and found that EA supports a nested SQL queries, so

Code: [Select]
// Getting count usages in diagrams for object_guid = {453E455C-AD5D-49a4-8EF5-851ADA1BAD37}
SELECT COUNT(*) from t_diagramobjects where object_id= (SELECT object_id from t_object WHERE ea_guid='{453E455C-AD5D-49a4-8EF5-851ADA1BAD37}')

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13295
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA Object API for "find in all diagrams" by GUID
« Reply #5 on: December 26, 2023, 09:47:15 pm »
I just did a couple experiments and found that EA supports a nested SQL queries, so

Code: [Select]
// Getting count usages in diagrams for object_guid = {453E455C-AD5D-49a4-8EF5-851ADA1BAD37}
SELECT COUNT(*) from t_diagramobjects where object_id= (SELECT object_id from t_object WHERE ea_guid='{453E455C-AD5D-49a4-8EF5-851ADA1BAD37}')
I don't think that's the most efficient way to do that.

I would use

Code: [Select]
select d.Diagram_ID from t_diagram d
where exists
(select do.Instance_ID from t_diagramobjects do
inner join t_object o on o.Object_ID = do.Object_ID
where do.Diagram_ID = d.Diagram_ID
and o.ea_guid = '{6202126E-1F87-4f99-9A80-BABCC305BC6F}')

Geert