Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Alexander.Golyshkin on December 25, 2023, 07:24:24 pm

Title: EA Object API for "find in all diagrams" by GUID
Post by: Alexander.Golyshkin 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?
Title: Re: EA Object API for "find in all diagrams" by GUID
Post by: Geert Bellekens 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
Title: Re: EA Object API for "find in all diagrams" by GUID
Post by: qwerty 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.
Title: Re: EA Object API for "find in all diagrams" by GUID
Post by: Alexander.Golyshkin 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?
Title: Re: EA Object API for "find in all diagrams" by GUID
Post by: Alexander.Golyshkin 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}')
Title: Re: EA Object API for "find in all diagrams" by GUID
Post by: Geert Bellekens 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