Author Topic: How can I get a node by GUID  (Read 3644 times)

Michael

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
How can I get a node by GUID
« on: May 13, 2013, 10:05:21 pm »
How can I get a node by GUID
I have a guid string
and I want to get the related Node
Thanx

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: How can I get a node by GUID
« Reply #1 on: May 13, 2013, 10:42:59 pm »
A deployment Node is a type of element, so you can use Repository.GetElementByGuid(<...>)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13241
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How can I get a node by GUID
« Reply #2 on: May 13, 2013, 11:47:14 pm »
Or you could use an sql search:

Code: [Select]
select instance.ea_guid as CLASSGUID,instance.Object_Type as CLASSTYPE,instance.name as Name, package.name as PackageName ,package_p1.name as PackageLevel1,package_p2.name as PackageLevel2,package_p3.name as PackageLevel3
from ((((t_object instance
inner join t_package package on instance.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 instance.ea_guid like '#WC#<Search Term>#WC#'

Geert

philchudley

  • EA User
  • **
  • Posts: 736
  • Karma: +20/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: How can I get a node by GUID
« Reply #3 on: May 14, 2013, 12:33:11 am »
Just curious

What is the difference / advantage of the SQL query posted by Geert and this SQL query

select instance.ea_guid as CLASSGUID, instance.Object_Type as CLASSTYPE, instance.Name as Name
from T_Object instance
where instance.ea_guid like '#WC#<Search_Term>#WC#'

Instead of using like another query could be simply
where instance.ea_guid = '#WC#<Search_Term>#WC#'

Cheers

Phil
follow me on Twitter

@SparxEAGuru

Michael

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How can I get a node by GUID
« Reply #4 on: May 14, 2013, 12:40:04 am »
Thanks
OK
good solution

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13241
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How can I get a node by GUID
« Reply #5 on: May 14, 2013, 04:13:27 pm »
Quote
Just curious

What is the difference / advantage of the SQL query posted by Geert and this SQL query

select instance.ea_guid as CLASSGUID, instance.Object_Type as CLASSTYPE, instance.Name as Name
from T_Object instance
where instance.ea_guid like '#WC#<Search_Term>#WC#'

Instead of using like another query could be simply
where instance.ea_guid = '#WC#<Search_Term>#WC#'

Cheers

Phil
Hi Phil,

If you change the "like" to a "=" then you should also remove the "#WC#" wildcards.
I thought about that, and for a guid that makes sense of course, but you never know someone might forget the curly braces, or by accident only copy part of the guid...
I don't think it will hurt much performance wise.

The advantage of joining all of those parent packages is that you get an idea of the context of the element returned by the search. I can see in an instant which element is the one I need, without having to select it in the project browser.

I've added those to all of my searches; its sort of a habit.


Geert
« Last Edit: May 14, 2013, 04:14:12 pm by Geert.Bellekens »

philchudley

  • EA User
  • **
  • Posts: 736
  • Karma: +20/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: How can I get a node by GUID
« Reply #6 on: May 14, 2013, 05:59:55 pm »
Thanks Geert, thanks makes sense
follow me on Twitter

@SparxEAGuru