Author Topic: Def Search for elements linked to another elements  (Read 3277 times)

EAUser

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Def Search for elements linked to another elements
« on: June 23, 2014, 09:20:21 pm »
Dear EA community,

Is it possible to define a search for all elements that are linked to a specific Element I specify? In my search, I would like to further specify the type of link, i.e. find all elements linked via a 'Dependency' or a 'Realization'-Link. Which properties in the search do I need to use for that?

Thank you for your help!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Def Search for elements linked to another elem
« Reply #1 on: June 24, 2014, 01:04:17 am »
Something like
Code: [Select]
SELECT d.name  FROM t_object as s, t_object as d, t_connector where s.Object_ID = t_connector.Start_Object_ID and d.Object_ID = t_connector.End_Object_ID and s.ea_guid  = "<Search Term>" You need to extend it so the type is also included. Further you should supply the
Code: [Select]
t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE to make the search result navigable.

q.
« Last Edit: June 24, 2014, 01:05:55 am by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Def Search for elements linked to another elem
« Reply #2 on: June 24, 2014, 04:09:51 pm »
Here, try this
Code: [Select]
select c.ea_guid as CLASSGUID,c.object_type as CLASSTYPE,c.name as Name, c.stereotype as Stereotype ,con.Connector_Type,
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_connector con on con.End_Object_ID = c.Object_ID)
inner join t_object so on con.Start_Object_ID = so.Object_ID)
inner join t_package as package on c.package_id = package.package_id)
left join t_package as package_p1 on package_p1.package_id = package.parent_id)
left join t_package as package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package as package_p3 on package_p3.package_id = package_p2.parent_id)
where so.Name like '<Search Term>'
and con.Connector_Type in ('Realisation','Realization', 'Dependency')

I've added both spelling variants of Realization just in case EA decides to get consistent and use Realization all over. ::)

Geert

EAUser

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Def Search for elements linked to another elem
« Reply #3 on: June 24, 2014, 04:57:43 pm »
Wow, this is great, works like a charm.

thank you, this has been a great help!

EAUser

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Def Search for elements linked to another elem
« Reply #4 on: June 24, 2014, 05:50:56 pm »
I think I have an idea about what this code is about, except for this part:
Code: [Select]
inner join t_package as package on c.package_id = package.package_id)
left join t_package as package_p1 on package_p1.package_id = package.parent_id)
left join t_package as package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package as package_p3 on package_p3.package_id = package_p2.parent_id)
could you help me out explaining what this is for?

I have tried to expand the script in order to only search for requirements linked to the search term object and at the same time linked to a category object cat.

This gives me an error which I am unable to determine, does anybody know what I would have to change?

Code: [Select]
select c.ea_guid as CLASSGUID,c.object_type as CLASSTYPE,c.name as Name, c.stereotype as Stereotype ,con.Connector_Type,con2.Connector_Type,
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_connector con on con.End_Object_ID = c.Object_ID)
inner join t_object so on con.Start_Object_ID = so.Object_ID)
inner join t_connector con2 on con2.End_Object_ID = c.Object_ID)
inner join t_object cat on con2.Start_Object_ID = cat.Object_ID)
inner join t_package as package on c.package_id = package.package_id)
left join t_package as package_p1 on package_p1.package_id = package.parent_id)
left join t_package as package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package as package_p3 on package_p3.package_id = package_p2.parent_id)
where so.Name like '<Search Term>'
and con.Connector_Type in ('Dependency')
and con2.Connector_Type in ('Realization','Realisation')
and cat.Name like 'Category YY'

Furthermore, how can I specify to restrict the search only on requirements, at best only requirements of the type 'functional' ?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Def Search for elements linked to another elem
« Reply #5 on: June 24, 2014, 07:01:22 pm »
Well, in case Geert wont answer: this is not a SQL forum. You're probably on your own when it comes to correcting complex SQL :-/

q.
« Last Edit: June 24, 2014, 07:01:51 pm by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Def Search for elements linked to another elem
« Reply #6 on: June 25, 2014, 03:54:39 pm »
Quote
I think I have an idea about what this code is about, except for this part:
Code: [Select]
inner join t_package as package on c.package_id = package.package_id)
left join t_package as package_p1 on package_p1.package_id = package.parent_id)
left join t_package as package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package as package_p3 on package_p3.package_id = package_p2.parent_id)
could you help me out explaining what this is for?
That returns the package hierarchy up to four levels upwards. It usually helps to determine the context of the search result.

Quote
I have tried to expand the script in order to only search for requirements linked to the search term object and at the same time linked to a category object cat.

This gives me an error which I am unable to determine, does anybody know what I would have to change?
I just tried that one and it ran without error.
Anyway, in any circumstance, if you are seeking help with regards to an error you should always include the actual error message.
"an error" rarely yields usable results when googling.

Quote
Furthermore, how can I specify to restrict the search only on requirements, at best only requirements of the type 'functional' ?
"Requirement" is the object_type, "functional" is the stereotype.
You are probably OK using the stereotype field, except when using multiple stereotypes. In that case you'll have to query t_xref as well.

Geert
« Last Edit: June 25, 2014, 03:55:48 pm by Geert.Bellekens »

EAUser

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Def Search for elements linked to another elem
« Reply #7 on: June 25, 2014, 08:46:55 pm »
Thank you Geert, that helps!

Concerning the code, turns out it was just some brackets that were missing around the 'and' statements...