Author Topic: Limiting "Model Search" to package?  (Read 1954 times)

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Limiting "Model Search" to package?
« on: August 01, 2024, 07:03:57 pm »
Is there an easy possibility to limit the model search to one package? i.e. I want to get all elements of a certain stereotype within one package and its subpackages

Thanks

PeterHeintz

  • EA User
  • **
  • Posts: 965
  • Karma: +58/-18
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #1 on: August 01, 2024, 07:10:18 pm »
In the Query Builder under "Search Model" use "Current Package".
Best regards,

Peter Heintz

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13212
  • Karma: +549/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Limiting "Model Search" to package?
« Reply #2 on: August 01, 2024, 07:37:10 pm »
In the SQL search you can use macro's such as #Branch# to limit the results to the selected package branch.

something like this:

Code: [Select]
SELECT o.ea_guid AS CLASSGUID, o.object_type AS CLASSTYPE,o.Stereotype AS RequirementType, o.Name AS Name, title.Value AS Title, oldreqid.Value AS OldReqID,
package.name AS PackageName, package_p1.name AS Package_level1, package_p2.name AS Package_level2, package_p3.name AS Package_level3
from (((((t_object o
inner join t_package package on o.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)
left join t_objectproperties title on (title.Object_ID = o.Object_ID
         and title.Property in ('Title','Title NL')))
LEFT JOIN t_objectproperties oldreqid ON (oldreqid.Object_ID = o.Object_ID
         AND oldreqid.Property = 'OldRequirementID')
where o.Object_Type = 'Requirement'
and o.Stereotype in ('Application Requirement', 'Solution Requirement')
and package.Name not like '%archive%'
and package.Name not like '%delete%'
and o.Package_ID IN (#Branch#)
order by o.Name

Geert

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #3 on: August 01, 2024, 08:58:48 pm »
The drawback of those solutions is that it is difficult to execute them in scope of a relationship matrix, as I always have to select the required package first.

I'd prefer a solution where I first query a specific package, and then get all elements of that package (and subpackages).

PeterHeintz

  • EA User
  • **
  • Posts: 965
  • Karma: +58/-18
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #4 on: August 01, 2024, 09:03:10 pm »
With SQL queries you can do so as long as you are using a SQL DB supporting the "With" statement. I will look for the SQL statement I use do do that and I will post it.
Best regards,

Peter Heintz

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13212
  • Karma: +549/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Limiting "Model Search" to package?
« Reply #5 on: August 01, 2024, 09:57:32 pm »
The drawback of those solutions is that it is difficult to execute them in scope of a relationship matrix, as I always have to select the required package first.

I'd prefer a solution where I first query a specific package, and then get all elements of that package (and subpackages).

If you already know which package you want, you can use the #Branch=<GUID>#  macro.
See https://sparxsystems.com/enterprise_architect_user_guide/16.1/the_application_desktop/creating_filters.html for more details

Geert

martin1

  • EA User
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #6 on: August 01, 2024, 11:58:52 pm »
#Branch=<GUID># sounds interesting. Unfortunately it yields a syntax error and I suspect that Branch with this GUID parameter is not available in EA14, only #Branch# seems to work.

PeterHeintz

  • EA User
  • **
  • Posts: 965
  • Karma: +58/-18
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #7 on: August 02, 2024, 12:00:12 am »
Or find here a MSSQL query I use as a MSSQL view on my server which generates for each t_object a "ID Path" an "Name Path" and a GUID Path" which can be used to filter path related elements.



WITH PathBuilder(Parent_ID, Package_ID, Package_Name, GUIDPath, NamePath, IDPath) AS (SELECT        Parent_ID, Package_ID, Name, CAST(ea_guid AS VARCHAR(1000)) AS GUIDPath, CAST(Name AS VARCHAR(1000)) AS NamePath,
                                                                                                                                                                                                                                    CAST(Package_ID AS VARCHAR(1000)) AS IDPath
                                                                                                                                                                                                          FROM            dbo.t_package AS pkg
                                                                                                                                                                                                          WHERE        (Parent_ID = 0)
                                                                                                                                                                                                          UNION ALL
                                                                                                                                                                                                          SELECT        pkg.Parent_ID, pkg.Package_ID, pkg.Name, CAST(pb.GUIDPath + '.' + pkg.ea_guid AS VARCHAR(1000)) AS GUIDPath,
                                                                                                                                                                                                                                   CAST(pb.NamePath + '.' + pkg.Name AS VARCHAR(1000)) AS NamePath,
                                                                                                                                                                                                                                   CAST(pb.IDPath + '.' + CAST(pkg.Package_ID AS VARCHAR(1000)) AS VARCHAR(1000)) AS IDPath
                                                                                                                                                                                                          FROM            dbo.t_package AS pkg INNER JOIN
                                                                                                                                                                                                                                   PathBuilder AS pb ON pkg.Parent_ID = pb.Package_ID)
    SELECT DISTINCT Parent_ID, Package_ID, Package_Name, GUIDPath, NamePath, IDPath
     FROM            PathBuilder AS pb
Best regards,

Peter Heintz

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8045
  • Karma: +118/-20
    • View Profile
Re: Limiting "Model Search" to package?
« Reply #8 on: August 02, 2024, 01:28:46 pm »
#Branch=<GUID># sounds interesting. Unfortunately it yields a syntax error and I suspect that Branch with this GUID parameter is not available in EA14, only #Branch# seems to work.
Looks like it was added in 15.2. (Compared to 15.1)