How can I generate an HTML report with list of relationships

Started by Quentin, August 29, 2017, 14:46:19 PM

Previous topic - Next topic

Quentin

Hi all,

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

Phil Beauvoir

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.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

I did write this code so I might help on this ;-)

The first thing is to look at StringTemplate's documentation. The key point to understand is how ST maps methods calls to 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:


^if(element.Children)^
<div role="tabpanel" class="tab-pane" id="elements">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th class="i18n-name"></th>
<th class="i18n-type"></th>
</tr>
</thead>
<tbody>
^expandChildren(element.Children)^
</tbody>
</table>
</div>
^endif^


This block is generated only when the element being parsed contains some children (in ST, "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) ::= <<
^children:{c |
^if(c.ArchimateElement)^
<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>
^elseif(c.ReferencedModel)^
<tr><td> <a href="../views/^c.ReferencedModel.Id^.html" target="view"> ^c.Name^ </a> </td><td class="i18n-viewpoint-^c.ReferencedModel.Viewpoint^"></td></tr>
^else^
<!-- DEBUG: Skipping element from class ^c.Class.Name^ -->
^endif^
^if(c.Children)^
^expandChildren(c.Children)^
^endif^
}^


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.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Quentin

Thank's Jean-Baptiste.

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) ?

Jean-Baptiste Sarrodie

Hi,

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 ;-)

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Quentin

I'll do when finished (at least to answer my initial needs) with pleasure.
:D

Jean-Baptiste Sarrodie

Hi,

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

Regards,

JB

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rfamans

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?

Regards
Roy


Jean-Baptiste Sarrodie

Hi,

Could you provide a screenshot of the issue and a zip of the generated report for a basic model (like Archisurance) ?

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rfamans

Here are the requested files

Jean-Baptiste Sarrodie

Hi,

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.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rfamans

Hi,

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.

regards,
Roy


Jean-Baptiste Sarrodie

Hi,

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).

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rfamans

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.

Regards,
Roy

Alberto

Quote(I'm working on another version which is a full rewrite).

;D...(twiddles thumbs impatiently)...