Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: martin1 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
-
In the Query Builder under "Search Model" use "Current Package".
-
In the SQL search you can use macro's such as #Branch# to limit the results to the selected package branch.
something like this:
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
-
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).
-
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.
-
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 (https://sparxsystems.com/enterprise_architect_user_guide/16.1/the_application_desktop/creating_filters.html) for more details
Geert
-
#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.
-
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
-
#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 (https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_navigation/creating_filters.html). (Compared to 15.1 (https://sparxsystems.com/enterprise_architect_user_guide/15.1/model_navigation/creating_filters.html))