Book a Demo

Author Topic: Help: Generating indented package hierarchy report  (Read 3296 times)

brazem

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Help: Generating indented package hierarchy report
« on: January 24, 2006, 08:54:30 am »
We're trying to generate a report that would look something like a screenshot of the project hierarchy.  None of the templates don't really work because our package hierarchy is sometimes more than 10 levels deep, and I've tried to create my own, but capturing the indenting does not seem to be possible, with a deep hierarchy.

We're not sure how to do this... any help / suggestions appreciated.

thomaskilian

  • Guest
Re: Help: Generating indented package hierarchy re
« Reply #1 on: January 25, 2006, 12:12:05 am »
Have you ever read a book with chapter names like 7.4.23.1.5.8.14.4.30.1? That's what such a chapter would look like. Not really helpfull. Only LDAP is making use of such "chapters". Maybe you should rethink on what you are actually trying to show?

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Help: Generating indented package hierarchy re
« Reply #2 on: January 26, 2006, 06:35:01 pm »
Quote
Have you ever read a book with chapter names like 7.4.23.1.5.8.14.4.30.1?



OMG's UML3.0 Superstructure ?  ;)

b
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

SeungwooYu

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • Thanks
    • View Profile
Re: Help: Generating indented package hierarchy re
« Reply #3 on: July 29, 2006, 07:35:43 am »
Hierarchy showed information is very rich data for complete traceability about like Requirement / UseCase / Issue / Specific Business Object.

I was so many tried that how to export and generation XXX_trace.rtf hierarchy information depends on specific target elements. But so far I could not make trick for this.

At the most of Large Project and Software Factory companies, this requirement is so many asking to model asset team.

« Last Edit: July 29, 2006, 07:36:54 am by SeungwooYu »

Dave_Bullet

  • EA User
  • **
  • Posts: 295
  • Karma: +0/-0
    • View Profile
Re: Help: Generating indented package hierarchy re
« Reply #4 on: August 01, 2006, 04:57:26 pm »
I had a similar requirement.

I don't know how to do it in EA, but here is some SQL trickery to do the same thing.

In this example - the "MY top package" is the top level package you want to retrieve the details for.

This script should handle any number of levels.  I've tested with 4 fine.

The BIG limitation - is it assumes the package IDs are numbered in depth first order, ie:

100 Package 1
101     Child 1.1
102     Child 1.2
103        Child 1.2.1
104 Package 2
105 Package 3
106      Child 3.1
etc....

with some order by clauses - you might be able to get it the way you want

(The reason mine where in correct numerical order is I did a bulk CSV import then created the missing t_package rows in one operation)

=-=-=-=-=

/* This creates a table to return the MY hierarchy in a nested view, with levels and descriptions */

drop table MY_hierarchy

create table dbo.MY_hierarchy
(
object_id int primary key clustered,
parent_object_id int null,
depth int null,
hierarchy varchar(255) null
)

/* Seed the table with the top level MY parent */

insert into MY_hierarchy (object_id, parent_object_id, depth, hierarchy)
select object_id, null, 0, '/' from t_object where object_type = 'Package' and name = 'MY top package'

/* Populate the MY_hierarchy table with the child and parent object_id of each MY before populating the depth
and level information.  The object_type = 'Package' stops picking up hyperlinks in diagrams which have a pdata1
value of the package (diagram) they link to, which causes a duplicate PK on insert of the child */

insert into MY_hierarchy (object_id, parent_object_id)
select c.object_id, p.object_id
from t_object as c, t_object as p
where c.object_type = 'Package' and c.stereotype = 'MY'
and ltrim(str(c.package_id)) = p.pdata1
and p.object_type = 'Package'

/* for each MY - create its depth and hierarchy of parent IDs */

WHILE EXISTS (SELECT * FROM MY_hierarchy WHERE Depth Is Null)
UPDATE T SET T.depth = P.Depth + 1,
T.hierarchy = P.hierarchy + Ltrim(Str(T.parent_object_id,6,0)) + '/'
FROM MY_hierarchy AS T, MY_hierarchy as P
WHERE T.parent_object_id = P.object_id
AND P.Depth>=0
AND P.hierarchy Is Not Null
AND T.Depth Is Null

/* Then return the nested MY tree */

SELECT Space(a.Depth*16) + b.Name AS MY, a.depth as "Level", b.note as "Description"
FROM MY_hierarchy as a, t_object as b
where b.object_id=a.object_id
ORDER BY a.hierarchy + Ltrim(Str(a.object_id,6,0))
=-=-=-=-=

Then finally, you can create a view to display the hierarchy which users can dump into MS Access, excel

/* Note: Run the Create table to retrieve MY hierarchy.sql script first
to create and populate the required table */

create view dbo.MY_Hierarchy_View
as
SELECT top 500 case depth when 1 then b.name else '' end as "MY_level_1",
case depth when 2 then b.name else '' end as "MY_level_2",
case depth when 3 then b.name else '' end as "MY_level_3",
case depth when 4 then b.name else '' end as "MY_level_4",
a.depth as "Level", b.note as "Description", b.author as "Architect_Responsible"
FROM MY_hierarchy as a with (NOLOCK), t_object as b with (NOLOCK)
where b.object_id=a.object_id
and depth >= 1
ORDER BY a.hierarchy + Ltrim(Str(a.object_id,6,0))

(credit - the above is courtesy of www.sqlteam.com)

Cheers,
David.
« Last Edit: August 01, 2006, 04:58:13 pm by Dave_Bullet »
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"