Screwtape
Screwtape

Reputation: 1367

How do you create a virtual document for a class within a package in Enterprise Architect?

With EA virtual documents, the ability to drop packages into a ModelDocument class is great, but in many cases, I want to document individual programs (represented by classes) which logically belong in a package, and link other things to them.

I could create a ModelDocument instance for each with a query, but it's not very easy, since I would need to generate a SQL query to select the individual item, and thus I would need a ModelDocument instance for all the sections I want in the document, since I can't combine them.

There doesn't seem to be any way of showing the GUID or Element ID of an element from the Project Browser, so I'd need to firstly query the model, find the GUID and then save the search to refer to in a ModelDocument element. All of which seems rather cumbersome.

Given that EA does not allow the creation of packages under elements (which is sensible) yet only allows packages to be linked into a ModelDocument, this seems like a severe limitation on the virtual document functionality.

Does anyone have a better way of doing this?

(I may submit a feature request if not.)

Upvotes: 1

Views: 142

Answers (1)

Geert Bellekens
Geert Bellekens

Reputation: 13784

I wrote a very simple search called ZDG_ElementsByGUID where the Z is there because it then shows up at the bottom of my searches, and DG stands for DocumentGeneration
Here's the SQL code for the search:

select c.ea_guid AS CLASSGUID,c.object_type AS CLASSTYPE,c.name AS Name, c.stereotype AS Stereotype ,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_package  package on c.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 
c.ea_guid like '<Search Term>'

I use that search in (the tagged values of) my model document, using the GUID of the element as the parameter.

You can get the GUID of an element by

  • Opening the properties view and copying it from the Project section

  • Right click on the element and choose Copy / Paste | Copy node GUID to clipboard

  • Using the copy GUID button from the EA Navigator add-in

You can find a fully working example on my website: Tutorial: Generate complex documents from Enterprise Architect with a two-step semi-automated approach

Upvotes: 1

Related Questions