Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Roche Pso 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
ID | Type | Name |
ext01 | external | Water input |
int01 | internal | temp1 |
Internal Interfaces
ID | Type | Name |
ext01 | external | Water input |
int01 | internal | temp1 |
Why is the package I drop onto the custom document not constraining the query?
-
Kinda hard to know without seeing the query. My crystal ball is at the cleaners at the moment.
Geert
-
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.
-
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
-
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
-
The query could be as simple as
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. 🤷♂️
-
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
select o.name as Name
from t_object as o
where o.Package_ID = #PACKAGEID#
Geert
-
Thanks Geert, I accept that this is necessary, but it is implied in the help that it isnt meant to work like this:
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.
-
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