Author Topic: Custom report content issue  (Read 3190 times)

Roche Pso

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-1
    • View Profile
Custom report content issue
« on: September 17, 2024, 02:23:55 am »
Hi,

I have two packages - "external" and "internal" - they live next to each other in my model

I have an SQL query that finds objects of a particular stereotype. I have put this query as the source for a template fragment

I have created a pair of templates that use the template fragment - one (templateExt) is for objects in package: "external" and the other (templateInt) is for objects in package: "internal"

I have created a custom document. I dropped package: "external" onto the custom document and told it to use templateExt. I dropped package: "internal" onto the custom document and told it to use templateInt

The resulting document has the correct static text from each template, but the dynamic content is the same. Although the scope of the query is meant to be constrained by the package I dropped onto the document it seems that in both cases the query has searched both packages and returned all the results.

So it looks a bit like this:

External Interfaces
IDTypeName
ext01externalWater input
int01internaltemp1

Internal Interfaces
IDTypeName
ext01externalWater input
int01internaltemp1

Why is the package I drop onto the custom document not constraining the query?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom report content issue
« Reply #1 on: September 17, 2024, 04:19:17 am »
Kinda hard to know without seeing the query. My crystal ball is at the cleaners at the moment.

Geert

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Re: Custom report content issue
« Reply #2 on: September 17, 2024, 03:44:25 pm »
Why not introduce a TaggedValue like "InterfaceType" containing either "Internal" or "External"?
You could then mix elements like you want and filter them using the TV.

Roche Pso

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-1
    • View Profile
Re: Custom report content issue
« Reply #3 on: September 17, 2024, 07:40:10 pm »
Why not introduce a TaggedValue like "InterfaceType" containing either "Internal" or "External"?
You could then mix elements like you want and filter them using the TV.

I think that is what I will have to do

Doesn't seem at all intuitive though and results in multiple copies of essentially the same query to work around an issue with the document generation

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom report content issue
« Reply #4 on: September 17, 2024, 08:39:09 pm »
Why not introduce a TaggedValue like "InterfaceType" containing either "Internal" or "External"?
You could then mix elements like you want and filter them using the TV.

I think that is what I will have to do

Doesn't seem at all intuitive though and results in multiple copies of essentially the same query to work around an issue with the document generation
You don't need that. You can use the package macro in your queries to filter the content based on the package.
But again, without seeing your query there not much advice to be given..

Geert

Roche Pso

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-1
    • View Profile
Re: Custom report content issue
« Reply #5 on: September 17, 2024, 11:16:52 pm »
The query could be as simple as

Code: [Select]
select o.name as Name
from t_object as o

which when run by itself will find everything in the model, but in a custom document when you drop PackageA on the document and choose the template which contains the fragment that contains that query it also finds everything in the model. It feels like choosing the specific package was pointless because it didn't do anything to constrain the scope of the query underlying the template, I could drop any package onto the main document and then use a specific query to get only the things I want. 🤷‍♂️

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom report content issue
« Reply #6 on: September 17, 2024, 11:26:13 pm »
Look here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_publishing/create_a_custom_sql_query.html

As you can see there are several macro's you can use to limit the contents of your document.

In your example that would be something like

Code: [Select]
select o.name as Name
from t_object as o
where o.Package_ID = #PACKAGEID#

Geert

Roche Pso

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-1
    • View Profile
Re: Custom report content issue
« Reply #7 on: September 17, 2024, 11:33:25 pm »
Thanks Geert, I accept that this is necessary, but it is implied in the help that it isnt meant to work like this:

Quote
For a model element such as a Package, element or Feature, you can select the (default) option of 'Dynamic Content' in
the 'Insert as' field. This adds the object information to the document. The prompt also provides a list from which you can
select a template or template fragment to format that specific information within the document. The list of templates can
be filtered to present only those that are user-defined, or system-provided, or technology-provided, or to show all
available templates. You make your selection by clicking on the appropriate radio button under the list.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom report content issue
« Reply #8 on: September 17, 2024, 11:40:39 pm »
It is, but only for "regular" templates.

There is no automagical filtering in SQL fragments
That would be impossible. There's no way EA can know which part of the query I want to limit to the package being processed.

Geert