Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Jozzi on May 22, 2024, 01:12:20 am
-
Hi,
I have a diagram with several classes with attributes and tagged values on the attributes.
I need to generate documentation where each attribute is on a separate row of the table. The first column will contain the attribute name and the other columns will contain the TV values. Currently, all attributes are being generated into a single row of the table.
Unfortunately, I'm not very skilled at creating templates and I only know basic SQL. I tried to resolve the situation in the following way.
1) Basic template
diagram >
element >
< element
< diagram
element >
attribute >
<table>
<tr>
<th>Attribute (name of attribute)</th>
<th>Type (type of attribute)</th>
<th>Format (tagged value)</th>
<th>Note (note of attribute</th>
</tr>
<tr>
<td>{Template - a3_Class_Att_Name_API}</td>
<td>template</td>
<td>template</td>
<td>template</td>
</tr>
</table>
< attribute
< element
< package
2) Template - a3_Class_Att_Name_API
Only the custom field "Name" base on this script (custom sql query):
select
a.Name as Name
from t_attribute a
left join t_object o ON a.object_ID = o.object_ID
left join t_attributetag at ON a.ID = at.ElementID
where
o.object_id =#OBJECTID#
Thank you very much for your help.
-
Hi,
I'm not sure I understand what you want to do, and I'm not sure that it's possible.
What Database are you using, or are you using a file based repository?
Try to run SQL to try to achieve what you want, and take it from there. MS-SQL does not support Common Table Expressions, which might have helped here.
I think that going the XML route would be a better choice, but then you would have to produce the documentation via Scripting ( in which I have no experience at all)
Sincerely,
Shimon
P.S. I assume you have a set number of tagged values, and you want a separate column for each one.
-
Hi,
thank you for your response.
The intention is to achieve this using a "customer template" and "inserted templates" into "the customer template":
For each class, a table should be generated containing rows. Each row should have the attribute name and its tagged values in the columns (I know how to add TV to columns). The problem is that all attributes of class are being generated into a single row of the table (I need each row to correspond to an attribute).
I am afraid that scripting is currently outside my scope :(.
Thank you
Jozzi
-
You should make an sql fragment for the whole attributes table under element>
In the past I used a query like this:
select att.[Pos] AS Pos, att.[Name]
, CASE WHEN att.Derived = 1 THEN '<b>Derived</b>' + CHAR(10) + att.Notes
ELSE att.Notes END AS [Description-Formatted],
att.LowerBound, att.UpperBound ,
CASE WHEN x.[Description] is null THEN 'no' ELSE 'yes' END AS IsID,
isnull(v.[Value], 'TBD') AS Versioned,isnull(dc.VALUE,'TBD') as DataClassification, isnull(ts.[Value], 'TBD') AS Timesliced, att.TYPE AS Format
from ((((t_attribute att
left outer join [t_attributetag] v on (v.[ElementID] = att.[ID]
and v.[Property] = 'Versioned'))
left outer join [t_attributetag] ts on (ts.[ElementID] = att.[ID]
and ts.[Property] = 'Timesliced'))
left outer join [t_attributetag] dc on (dc.[ElementID] = att.[ID]
and dc.[Property] in ('MDG::Data Classification', 'Data Classification')))
left outer join t_xref x on (x.[Client] = att.[ea_guid]
and x.Type = 'attribute property'
and x.[Description] like '%@PROP=@NAME=isID@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=1@ENDVALU;%'))
where att.Object_ID = #OBJECTID#
Geert
-
Hi Geert,
thank you very much! I understood the idea and adapted it to my needs, and everything works as it should. I am very grateful to you. It helped me a lot. Have a nice day! Jozzi