Archi Forum

Archi => Archi Development => Topic started by: Joel01 on November 12, 2020, 12:01:46 PM

Title: Jasper report - printing view's relations
Post by: Joel01 on November 12, 2020, 12:01:46 PM
Hello,
I'm trying to customize the jasper report template, and I would like to print all the relations used in a view. Is there an easy way to get those relations?
Joël
Title: Re: Jasper report - printing view's relations
Post by: Phil Beauvoir on November 12, 2020, 12:55:46 PM
I think it might be:

getChildElementsDataSourceForTypes("relations")

I replaced some lines in the view.jrxml file like this:

<dataSourceExpression><![CDATA[((com.archimatetool.jasperreports.data.ViewModelDataSource)$P{REPORT_DATA_SOURCE}).getChildElementsDataSourceForTypes("relations")]]></dataSourceExpression>

and that seemed to work.

General comment regarding the Jasper code - if you need to see how it works, you could take a look at it here:

https://github.com/archimatetool/archi/tree/master/com.archimatetool.jasperreports/src/com/archimatetool/jasperreports/data
Title: Re: Jasper report - printing view's relations
Post by: johmut on February 14, 2024, 16:57:48 PM
Hi Phil,

I can't get this to work. I don't have a getChildElementsDataSourceForTypes in my dataSourceExpressions within view.jrxml ? Can you share a modded view.jrxml to report on relations on a view ?

TIA,
Johan
Title: Re: Jasper report - printing view's relations
Post by: Phil Beauvoir on February 15, 2024, 11:49:23 AM
Hi Johan,

my original response was really a proof of concept, to show how to get the relations. I edited the "view.jrxml" file in a text editor and replaced line 191. The original code is this:

<dataSourceExpression><![CDATA[((com.archimatetool.jasperreports.data.ViewModelDataSource)$P{REPORT_DATA_SOURCE}).getChildElementsDataSource()]]></dataSourceExpression>
Replaced with:

<dataSourceExpression><![CDATA[((com.archimatetool.jasperreports.data.ViewModelDataSource)$P{REPORT_DATA_SOURCE}).getChildElementsDataSourceForTypes("relations")]]></dataSourceExpression>
Phil