I'm quite new to reports generation in Archi and a real newbie to StringTemplates, so please be kind !
I would like to modify the HTML reports by adding to the Elements frame an additional tab which lists all relationships (sorted per relationship type) of the element, in addition to current documentation and properties.
How should I do this? May I modify the ST template only?
Thanks for your help
I didn't write this particular code, but I have edited it to update to ArchiMate 3. I mainly hacked at the *.stg files in trial and error. Sorry I can't be of more help.
I did write this code so I might help on this ;-)
The first thing is to look at StringTemplate's documentation (https://github.com/antlr/stringtemplate4/blob/master/doc/index.md). The key point to understand is how ST maps methods calls to expressions (https://github.com/antlr/stringtemplate4/blob/master/doc/templates.md#attribute-expressions).
Then, as Phil said you'll have to "hack" .st files that are inside the plugins/com.archimatetool.reports_xxx/templates/st. The one of interrest for this purpose is "frame.st". Tabs (documentation, properties, elements...) are created arround line 80. At some point you'll see:
<div role="tabpanel" class="tab-pane" id="elements">
<table class="table table-striped table-hover table-condensed">
This block is generated only when the element being parsed contains some children (in ST (https://github.com/antlr/stringtemplate4/blob/master/doc/templates.md#attribute-expressions), "element.Children" calls the method "getChildren()" of the element), thus when we are on a diagram. You can duplicate this part to create the list of relationships.
The list itself is created through the ST function "expandChildren()" (with the list of children as parameters):
expandChildren(children) ::= <<
<tr><td> <a href="../elements/^c.ArchimateElement.Id^.html" target="element"> ^c.Name;format="xml-encode"^ </a> </td><td class="i18n-elementtype-^c.ArchimateElement.Class.SimpleName^"></td></tr>
<tr><td> <a href="../views/^c.ReferencedModel.Id^.html" target="view"> ^c.Name^ </a> </td><td class="i18n-viewpoint-^c.ReferencedModel.Viewpoint^"></td></tr>
<!-- DEBUG: Skipping element from class ^c.Class.Name^ -->
You have to duplicate it to implement the logic required to list relationships. The main issue is that relationships are not listed as children, so you have to iterate on each children to get the list of its SourceConnections and then print them. Of course, to be able to know which attribute to use, you'll have to look at Archi Model code (https://github.com/archimatetool/archi/tree/master/com.archimatetool.model/src/com/archimatetool/model/impl).
I missed the understanding on how ST mapped the .properties to java methods, which is much clearer now.
Thanks to your help, I can now easilty navigate the relationships. Yet, as I understood there is no boolean operators in ST, do you have any hint on how to filter on a given type of relationships (follow the "FlowRelationships" for instance) ?
I faced the same issue: you can only check if a property exist or not, not its value. The workaround I've used several time is to generate all elements and add them a CSS class or Id that is generated. You can then change the CSS file to add a "display: none;" on those classes or Ids.
Could you share your work, It could be easily added to a future version of Archi ;-)
I'll do when finished (at least to answer my initial needs) with pleasure.
FWIW, I'm working on a slightly enhanced version of the HTML report for Archi. It now adds a tab with the list of relationships (including those that are hidden because of nesting) and also an embedded (browser/JS based) database on which you can run SQL queries (through a "Query" tab on the model "view", ie. the view opened by default and when you click on the model name in the tree).
The branch is accessible on GitHub: https://github.com/archimatetool/archi/tree/enhanced-html-report
If you want to test, you can simply replace your local template folder (inside the report plugin folder) by this one : https://github.com/archimatetool/archi/tree/enhanced-html-report/com.archimatetool.reports/templates
Hi, I am interested in using this custom html-report plugin. When I replace the 2 template files, I can see that different html is being generated with an extra relations tab but this tab does not show up in the lower left frame (southwest) because no relationships are found (while I am pretty sure that relationships do exist for the selected element).
Alternatively, I replaced the standard report plugin with this custom plugin but after that Archi does no longer generate html output at all.
Can you help me out here?
Could you provide a screenshot of the issue and a zip of the generated report for a basic model (like Archisurance) ?
Here are the requested files
There's an issue with the generated report, the query tab should be visible only on the page associated to the model itself (the one you see when the page is loaded the first time or when you click on the model name, here 'Demo' on the model tree). This is certainly due to a screwed file in the template.
Can you please do the following:
- In the "plugins/com.archimatetool.reports_a.b.c.timestamp/templates" subfolder of Archi, remove 'html' and 'st' subfolders.
- In the same place, extract content of attached ZIP. You should now have proper 'html' and 'st' subfolders.
- Generate an HTML report again to see if issue is fixed.
Thanks for the explanation. I guess I was the one that screwed the template file in my hope that I could tweak it in such way that when you click an object in the model, the relationships of the selected object appear in the lower left frame that shows all object specific characteristics. For us there are 2 reasons to see the relationships per object in the lower left frame:
- we would also like to see relationships that are not shown on the selected view.
- we want to narrow down the number of relationships that show up after pressing the relations tab. Some of our views contain
more than a hundred relationships so a huge table that shows them all will be hard to grasp for the reader.
Would it be possible to tweak the template in such way that it would work the way I hoped it would work or will that be impossible with the current version of the plugin?
Sorry for the inconvenience.
What you describe should be possible, but I can't promise that I will implement it on this version of the report (I'm working on another version which is a full rewrite).
Great to hear that you are working on a rewrite. I am fine with waiting for your new version. Better not spend time on something that is going to be replaced anyway but if you have a small hint about how I could fix it myself with the template than that would be much appreciated.
Quote(I'm working on another version which is a full rewrite).
;D...(twiddles thumbs impatiently)...
If you've not already seen it: https://twitter.com/jbsarrodie/status/992473846727966720