Author Topic: Find in Project by ElementID or ElementGUID  (Read 11642 times)

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Find in Project by ElementID or ElementGUID
« on: November 18, 2021, 09:46:29 pm »
I have (again) a very simple question however I do not find a solution that is simple so I am afraid I miss something obvious in SparxEA.
I have scripts checking my model and they log errors and in the log I have the ElementID or ElementGUID as the name of the Element is not unique in my model (In the script I have the element object so I can log any attribute that is useful for a search).
However if I want to search in my project (simple ctrl+F) I can only search by name (which is useless as I get multiple hits and I do not know which is the correct one) and not by an ID.
Is there an easy way to do this? or should I write my own query (I am not very used to doing that but if I have to learn I'll teach myself)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13283
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find in Project by ElementID or ElementGUID
« Reply #1 on: November 18, 2021, 10:00:08 pm »
You can use my EA Navigator add-in if you want to search something based on the guid.

Writing your own query is of course also possible.
This is an example of a query searching an element based on the guid:

Code: [Select]
select c.ea_guid AS CLASSGUID,c.object_type AS CLASSTYPE,c.name AS Name, c.stereotype AS Stereotype ,package.name AS PackageName ,package_p1.name AS PackageLevel1,package_p2.name AS PackageLevel2,package_p3.name AS PackageLevel3
from ((((t_object c
inner join t_package  package on c.package_id = package.package_id)
left join t_package  package_p1 on package_p1.package_id = package.parent_id)
left join t_package  package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package  package_p3 on package_p3.package_id = package_p2.parent_id)
where
c.ea_guid like '<Search Term>'

Geert

Arnoud_B

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
    • View Profile
Re: Find in Project by ElementID or ElementGUID
« Reply #2 on: November 19, 2021, 07:44:24 am »
Thanks again Geert! That works perfectly mostly as I can right click the result and 'find in project browser' to take me to the object I am looking for.

Shegit Brahm

  • EA User
  • **
  • Posts: 98
  • Karma: +1/-0
    • View Profile
Re: Find in Project by ElementID or ElementGUID
« Reply #3 on: November 23, 2021, 08:45:35 pm »
With the help of this community I build up this mess of a query for finding a guid:
(because I wanted to know in which ea table it occured what I stumbled upon)
=> search for element ID is missing here!

Code: [Select]
select ea_guid AS CLASSGUID, Diagram_Type as CLASSTYPE, 't_diagram' as CLASSTABLE, Name, diagram_id as t_id, ea_guid as guddi, 't_diagram' as source
from t_diagram where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, Object_Type as CLASSTYPE, 't_object' as CLASSTABLE, Name, object_id as t_id, ea_guid as guddi, 't_object' as source
from t_object where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Connector' as CLASSTYPE, 't_connector' as CLASSTABLE, Name, connector_id as t_id, ea_guid as guddi, 't_connector' as source
from t_connector where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Stereotypes' as CLASSTYPE, 't_stereotypes' as CLASSTABLE,  (stereotype + '&' + appliesto) as Name , '0' as t_id, ea_guid as guddi, 't_stereotypes' as source
from t_stereotypes where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Package' as CLASSTYPE, 't_package' as CLASSTABLE,  Name , package_id as t_id, ea_guid as guddi, 't_package' as source from t_package where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Attribute' as CLASSTYPE, 't_attribute' as CLASSTABLE, Name, id as t_id, ea_guid as guddi, 't_attribute' as source from t_attribute where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Operation' as CLASSTYPE, 't_operation' as CLASSTABLE, Name, operationid as t_id, ea_guid as guddi, 't_operation' as source from t_operation where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Attributetag' as CLASSTYPE, 't_attributetag' as CLASSTABLE,  (ElementID + '&' + propertyid + '&' + property) as Name, '0' as t_id, ea_guid as guddi, 't_attributetag' as source from t_attributetag where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Objectscenarios' as CLASSTYPE, 't_objectscenarios' as CLASSTABLE,  Scenario as Name, object_id as t_id, ea_guid as guddi, 't_objectscenarios' as source from t_objectscenarios where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Operationparams' as CLASSTYPE, 't_objectparams' as CLASSTABLE,  Name , operationid as t_id, ea_guid as guddi, 't_operationparams' as source from t_operationparams where ea_guid like '#WC#<Search Term>#WC#'
union
select ea_guid AS CLASSGUID, 'Operationtag' as CLASSTYPE, 't_operationtag' as CLASSTABLE,  (ElementID + '&' + propertyid + '&' + property) as Name, '0' as t_id, ea_guid as guddi, 't_operationtag' as source from t_operationtag where ea_guid like '#WC#<Search Term>#WC#'

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Find in Project by ElementID or ElementGUID
« Reply #4 on: November 23, 2021, 09:20:54 pm »
With the help of this community I build up this mess of a query for finding a guid:
Hehe, LOL. That's (more or less) the one I came up for my customer quite some time ago :-)

Code: [Select]
SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE, "Element" AS [Type], t_object.Name AS Name
FROM t_object
WHERE t_object.ea_guid = "<Search Term>"
UNION
SELECT t_diagram.ea_guid AS CLASSGUID, t_diagram.Diagram_Type AS CLASSTYPE, "Diagram" AS [Type], t_diagram.Name AS Name
FROM t_diagram
WHERE t_diagram.ea_guid = "<Search Term>"
UNION
SELECT t_attribute.ea_guid AS CLASSGUID, t_attribute.Type AS CLASSTYPE, "Attribute" AS [Type], t_attribute.Name AS Name
FROM t_attribute
WHERE t_attribute.ea_guid = "<Search Term>"
UNION
SELECT t_operation.ea_guid AS CLASSGUID, t_operation.Type AS CLASSTYPE, "Operation" AS [Type], t_operation.Name AS Name
FROM t_operation
WHERE t_operation.ea_guid = "<Search Term>"

q,