Guide for Simple Jasper Reports
Level: Expert
Keywords: report, JasperReports
The result: integration of simple Jasper reports to your project
Jasper report templates can be used in both ways (using LIDS, using SAMO BS). For individual use-cases, one of the ways is usually better.
How to create simple Jasper report using BS​
Here, in six steps, it is shown how to add a simple Jasper report using BS to the project.
1. Report template creation​
First of all you need to create .jrxml report file (using JasperSoft Studio) according to your needs. All reports are stored in the project package (..\metadata-packages\package_name\lids-business-service\resources\report).
Fonts may be missing at the server from which the application is launched (mostly on LINUX servers) and report generating can crash. If that occurs, you need to add given xxx.ttf file in the font's folder in the main project package (..\metadata-packages\package_name\lids-business-service\templates\fonts). Name of the file must be in a specific format (e.g. Arial_bold.ttf or TimesNewRoman.ttf)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.6.final using JasperReports Library version 6.20.6-5c96b6aa8a39ac1dc6b6bea4b81168e16dd39231 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="generatePondReport2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fc97a963-c0b6-4c19-a348-7e2773e092a3">
<property name="template.engine" value="tabular_template"/>
<property name="com.jaspersoft.studio.data.sql.tables" value="Y3RfYm9wb25kICwxNSwxNSwwZTczNDM4YS1hNzk5LTQ2ZTQtYjhlNS0wYjFjMDgzODQ1Njc7"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter"/>
<style name="Table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="1.0" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#EFEFEF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableDataset" uuid="269a8358-dae6-4a97-bbbe-24dcf18b15f1">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter"/>
<queryString language="SQL">
<![CDATA[SELECT description,
code,
cl_bopondtype
FROM ct_bopond]]>
</queryString>
<field name="description" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="description"/>
<property name="com.jaspersoft.studio.field.label" value="description"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ct_bopond"/>
</field>
<field name="code" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="code"/>
<property name="com.jaspersoft.studio.field.label" value="code"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ct_bopond"/>
</field>
<field name="cl_bopondtype" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.name" value="cl_bopondtype"/>
<property name="com.jaspersoft.studio.field.label" value="cl_bopondtype"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ct_bopond"/>
</field>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="80" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="555" height="80" uuid="9298cf73-47d0-493e-883e-455ee3c6a965"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="26" isBold="true"/>
</textElement>
<text><![CDATA["Selected Ponds"]]></text>
</staticText>
</band>
</title>
<pageFooter>
<band height="38" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="200" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<componentElement>
<reportElement x="0" y="0" width="555" height="200" uuid="677d3057-fcee-4f00-b86c-12d5d375bfe9">
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="tableDataset" uuid="69adccf8-323d-41d8-a26d-802b22b46e23">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="90" uuid="187426de-d251-4794-8176-d9248516f824">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="8fef4781-a111-409f-b94b-d6777edfd971"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12" isBold="true"/>
</textElement>
<text><![CDATA[description]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="5923d112-8712-41fc-b384-a2bd6ecb1aa1"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="f07e2804-f702-4f9f-b9c7-398190d95e47">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="90f8add8-5e37-4efe-ae27-7a59dfc73065"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12" isBold="true"/>
</textElement>
<text><![CDATA[code]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="cd819cc5-eec8-463f-b316-a2a7d8cca57e"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="4bc2ac62-b426-488f-a50d-3d53d0986fc8">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="e6e1ebaa-8751-44ec-a241-87ec4b747482"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12" isBold="true"/>
</textElement>
<text><![CDATA[cl_bopondtype]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="b67381a9-e116-41ad-a768-d37be47bc6ec"/>
<box leftPadding="2"/>
<textElement>
<font fontName="SansSerif" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{cl_bopondtype}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</summary>
</jasperReport>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.6.final using JasperReports Library version 6.20.6-5c96b6aa8a39ac1dc6b6bea4b81168e16dd39231 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="defectsReportSimpleByType" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="0" uuid="cd3df208-1f01-461e-9efe-3ee6c21a9dcb">
<property name="template.engine" value="tabular_template"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DMO MASTER data adapter"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<style name="Title" fontName="Arial" fontSize="26" isBold="true"/>
<style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#FFFFFF" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<style name="Table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="1.0" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="Table_TH" mode="Transparent" backcolor="#FFFFFF">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#CCCCCC"/>
<leftPen lineWidth="0.0" lineColor="#CCCCCC"/>
<bottomPen lineWidth="0.5" lineColor="#CCCCCC"/>
<rightPen lineWidth="0.0" lineColor="#CCCCCC"/>
</box>
</style>
<style name="Table_CH" mode="Transparent" forecolor="#B89F7D" backcolor="#70A9C6">
<box>
<pen lineWidth="0.5" lineColor="#CCCCCC"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Transparent" backcolor="#FFFFFF">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#CCCCCC"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#CCCCCC"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH_Label" style="SubTitle" mode="Opaque" forecolor="#FFFFFF" backcolor="#666666" fontSize="16" isBold="true">
<box leftPadding="2"/>
</style>
<subDataset name="tableDataset" uuid="2b78b05a-a931-41cf-8b73-93469aa17868">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DMO MASTER data adapter"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="479"/>
<property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="521"/>
<parameter name="defect_types" class="java.lang.String"/>
<queryString language="SQL">
<![CDATA[SELECT d.*,
p.DESCRIPTION AS priority_description,
s.DESCRIPTION AS state_description,
c.DESCRIPTION AS city_description,
st.DESCRIPTION AS street_description,
CASE
WHEN d.CODE LIKE '%ELE%' THEN 'ELE'
WHEN d.CODE LIKE '%LIG%' THEN 'LIG'
WHEN d.CODE LIKE '%WTR%' THEN 'WTR'
ELSE 'OTHER' -- pro hodnoty, které neodpovÃdajÃ
END AS type
FROM DEF_DEFECT d
LEFT JOIN CL_PRIORITY p ON d.C_PRIORITY = p.ID
LEFT JOIN CL_STATE s ON d.C_STATE = s.ID
LEFT JOIN TAI_CITY c ON d.C_CITY = c.ID
LEFT JOIN TAI_STREET st ON d.C_STREET = st.ID
WHERE REGEXP_LIKE(d.CODE, $P{defect_types})
ORDER BY type ASC]]>
</queryString>
<field name="CODE" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="CODE"/>
<property name="com.jaspersoft.studio.field.label" value="CODE"/>
</field>
<field name="STATE_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="STATE_DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="STATE_DESCRIPTION"/>
</field>
<field name="NAME" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="NAME"/>
<property name="com.jaspersoft.studio.field.label" value="NAME"/>
</field>
<field name="DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="DESCRIPTION"/>
</field>
<field name="DETECTION_DATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.name" value="DETECTION_DATE"/>
<property name="com.jaspersoft.studio.field.label" value="DETECTION_DATE"/>
</field>
<field name="FIX_DATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.name" value="FIX_DATE"/>
<property name="com.jaspersoft.studio.field.label" value="FIX_DATE"/>
</field>
<field name="FIX_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="FIX_DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="FIX_DESCRIPTION"/>
</field>
<field name="CITY_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="CITY_DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="CITY_DESCRIPTION"/>
</field>
<field name="STREET_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="STREET_DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="STREET_DESCRIPTION"/>
</field>
<field name="PRIORITY_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="PRIORITY_DESCRIPTION"/>
<property name="com.jaspersoft.studio.field.label" value="PRIORITY_DESCRIPTION"/>
</field>
</subDataset>
<parameter name="DEFECT_TYPES" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band height="575" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="-20" y="475" width="105" height="100" forecolor="#FFFFFF" backcolor="#006699" uuid="c43bcaab-2004-4343-bc81-ffa62c8e2de6"/>
<box>
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textField>
<reportElement style="Column header" x="0" y="0" width="104" height="73" forecolor="#FFFFFF" uuid="b948184c-22ec-4010-a2cf-425ae5d3fe2e"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="58" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement style="Column header" x="0" y="77" width="104" height="20" forecolor="#FFFFFF" uuid="57746837-8a21-417e-a9ab-2c99e0e58a46"/>
<box leftPadding="4" rightPadding="4"/>
<textElement textAlignment="Center">
<font size="16" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<line>
<reportElement mode="Transparent" x="42" y="73" width="20" height="1" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="8bf81540-6c20-445e-bc8d-cd0e33eaeb9b"/>
</line>
</frame>
</band>
</background>
<title>
<band height="104" splitType="Stretch">
<staticText>
<reportElement style="Title" x="0" y="0" width="802" height="67" uuid="77e5f357-287f-46bb-a2ca-428ae6225aa5"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="54" isBold="false"/>
</textElement>
<text><![CDATA[Defects Report]]></text>
</staticText>
</band>
</title>
<pageFooter>
<band height="39" splitType="Stretch">
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="671" y="0" width="131" height="20" forecolor="#000000" uuid="cc434357-2dc8-4be7-ba91-1828360d1ee6"/>
<textElement textAlignment="Right">
<font size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="200" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<componentElement>
<reportElement x="96" y="0" width="703" height="200" uuid="28f47f6d-9fcb-40f7-920a-82405cd665f2">
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="tableDataset" uuid="f3047354-a10a-434a-83fe-3961d0d065de">
<datasetParameter name="defect_types">
<datasetParameterExpression><![CDATA[$P{DEFECT_TYPES}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="70" uuid="72340def-7b72-49d4-a74d-e7a4a7f97506">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="d1932144-41fc-49cb-83d3-a5beacc40555"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Code]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="cd425ce4-caca-447a-a72c-93182f321c33"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{CODE}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="0a79867b-4f2d-4ec8-b8e1-9baf78c6085d">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="5fb0681c-88b4-4cb5-a6fc-2750a055e736"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[State]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="ee962ed8-51da-4705-96b5-79b46ea8803c"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{STATE_DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="c80b4e8e-81c5-4582-9286-ded747239d58">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="fe1b8fa8-03f6-4511-9449-70534b3165cf"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="a3245fb4-1cc1-44df-9659-78ca94ab3f34"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="7222c84b-70e4-4da6-ae02-90ac4e70c398">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="ccd76647-9477-4fae-bebc-7b1eaebd8f76"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Description]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="175d4fd4-0175-4626-8887-6c474f0437fa"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="2dd80b48-b20b-41e8-91b2-e71d10a4031b">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="7ef19ed7-ea34-4cdc-a352-819e9a5aea22"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Det Date]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="9b4e1fa7-cfed-4edb-820d-e2041a4b8389"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat("dd.MM.yyyy").format($F{DETECTION_DATE})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="c6d356a2-1eb3-43af-9aa7-4e052c78711b">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="2bce7105-a56f-428a-bf1a-a0df2b282df6"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Fix Date]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="1d011f7d-4dfc-48ee-8427-86e9eef7bb6d"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat("dd.MM.yyyy").format($F{DETECTION_DATE})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="4814a1c1-09e3-4a07-816e-56c80043b11d">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="38df7b26-1f3c-4d19-9559-a97b2ab0459f"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Fix]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="02b2d92c-4fbf-4f98-bac4-fbe2840e9179"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{FIX_DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="6172dc1c-13e9-45e0-86e6-d5f06a796633">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="c4f9aaa3-ec00-4a8e-b102-5893f541d01d"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[City]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="8f7889e7-9392-4b15-bb53-bd0784491ea8"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{CITY_DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="da4eff08-53ac-4bf1-8431-40152d0fae4a">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="a89484e5-ec75-426b-ae48-3018cf13a3db"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Street]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="42d63bf3-fb0a-4d00-b4a2-bd40040403fa"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{STREET_DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="db42c40f-a217-4998-be0c-6a6032fc07b9">
<jr:tableFooter style="Table_TH" height="30"/>
<jr:columnHeader style="Table_CH" height="25">
<staticText>
<reportElement key="" style="Table_CH_Label" x="0" y="0" width="70" height="25" backcolor="#006699" uuid="0512b3b5-47cd-476f-ae2e-91e1d5eccc88"/>
<box leftPadding="2">
<pen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#666666"/>
</box>
<textElement>
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Priority]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="25">
<textField>
<reportElement style="Detail" x="0" y="0" width="70" height="25" uuid="c41a3ad1-18ae-48be-9f00-58d42013a28a"/>
<box leftPadding="2"/>
<textElement>
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{PRIORITY_DESCRIPTION}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</summary>
</jasperReport>
2. Report template registration in presentation.xml​
Now register the report you just created in presentation.xml as dynamic Jasper report.
Id must correspond to the id called in the script (later in step 6). Use <ber:dynamicJasperReport> element for dynamic Jasper reports. Define output formats (there you can choose also default one) and specify input parameters in case there are any.
<ber:jasperReport id="generatePondReport" name="All ponds" orientation="landscape">
<ber:outputFormatArray>
<ber:outputFormat default="true">pdf</ber:outputFormat>
<ber:outputFormat>xls</ber:outputFormat>
</ber:outputFormatArray>
<ber:templateName>generatePondReport.jrxml</ber:templateName>
</ber:jasperReport>
<ber:dynamicJasperReport id="defectsReportSimple" name="Defects" orientation="landscape">
<ber:description>Dynamic report for defects with an unknown number of records.</ber:description>
<ber:outputFormatArray>
<ber:outputFormat default="true">pdf</ber:outputFormat>
<ber:outputFormat>xls</ber:outputFormat>
</ber:outputFormatArray>
<ber:templateName>defectsReportSimple.jrxml</ber:templateName>
</ber:dynamicJasperReport>
<ber:dynamicJasperReport id="defectsReportSimpleByType" name="Defects filtered and ordered by their type" orientation="landscape">
<ber:description>Dynamic report for defects with an unknown number of records. Defects filtered and ordered by their type.</ber:description>
<ber:outputFormatArray>
<ber:outputFormat default="true">pdf</ber:outputFormat>
<ber:outputFormat>xls</ber:outputFormat>
</ber:outputFormatArray>
<ber:inputParameterArray>
<ber:inputParameter id="DEFECT_TYPES" name="Defect Types">
<ber:description>Defect Types</ber:description>
<ber:dataType>
<ber:string maxLength="50"/>
</ber:dataType>
</ber:inputParameter>
</ber:inputParameterArray>
<ber:templateName>defectsReportSimpleByType.jrxml</ber:templateName>
</ber:dynamicJasperReport>
3. Intent button configuration​
Third step is to create an icon or button from which request will be invoked. Add intent configuration to ..\gateway\applications\applicationName\metadata\dynamic-client\samo-entities\intents folder.
The intent must be of the business-action type. The actionId is used as the name of the action in the action form configuration or business action configuration.
{
"title": "Generate Ponds Report",
"icon": "samo-demo-icons-eam:workorder",
"type": "business-action",
"entitiesGroup": "pond-group",
"display": [
"list-all"
],
"actionType": "static",
"actionId": "generatePondReport",
"fullIdsProperty": "selectedEntities",
"idsProperty": "ponds",
"openFilesProperty": "files",
"noResultDetail": true,
"allowContinuousAction": false,
"security": {
"loggedIn": true
}
}
4. Business action configuration​
Define action for report creating in desired entity business metadata configuration. Define entity business metadata configuration that just calls the script.
As name of the action use actionId of the defined business-action intent.
"generatePondReport": {
"title": "Print ponds",
"access": [
"static",
"internal",
"external",
"instance"
],
"includeStates": [
"*"
],
"steps": [
{
"type": "script",
"source": "scripts/ap_pondRegister/generatePondReport.js"
}
]
}
5. Action form configuration​
Intent button invokes an action form, where the user can select file format (or provide some additional information as other parameters).
Define the action in the entity metadata, where the action name is the value of the actionId attribute of the intent. For example, use the key-value-form component, and as an element, include a radio button type for selecting the desired report file format, allowing a default option to be chosen.
"generatePondReport": {
"title": "Choose report format",
"sections": [
{
"module": {
"type": "component:dynamic-app/modules/forms/key-value-form",
"scope": "mainScope",
"elements": [
{
"type": "radio",
"label": "Required format:",
"property": "hlp_print_format",
"allowEmptySelection": false,
"dynamic": true,
"defaultValue": "PDF",
"validation": {
"required": true
},
"options": [
{
"label": "XLS",
"value": "XLS"
},
{
"label": "PDF",
"value": "PDF"
}
]
}
]
}
}
]
}
6. Business action configuration – script​
You need to configure bussines action in JS which invokes request for a report. Jasper report obtains data based on a suitably defined SQL query directly from the database (except for input parameters), so there is no need to obtain entities data at the business action script level, you just need to create a suitable SQL query in .jrxml template.
There is a simple example of business action which invokes report and prepares temporary file for download.
function action(context) {
var jsonRequestReader = api.request()
.prepareCreateJSONRequestReader(context)
.create()
var requestContent = jsonRequestReader.getRequestBodyAsObject();
api.logging().prepareLog(context)
.message(scriptFileName)
.addVariable("REQUESTBODYPRINT:", requestContent)
.logDebug();
var outputFormat = requestContent.mainScope.hlp_print_format.toLowerCase();
var fileName = "Pond Report." + outputFormat;
var tempFile = api.temporaryFiles()
.prepareCreateReportFile(context)
.outputFormat(outputFormat)
.reportId("generatePondReport")
.fileName(fileName)
.create();
var response = api.response()
.prepareCreateClientResponse(context)
.prepareAddTemporaryFile()
.fileId(tempFile.getId())
.add()
.create();
return api.result()
.prepareCreateActionResult(context)
.result(response)
.create();
}
When dealing with input parameters, it is necessary to fill them with appropriate data. In the script, the data must be mapped to the parameters of the .jrxml report template when generating the report or preparing the temporary file. There are various options for preparing data for the template's input parameters, such as using a dynamic action form, client-provided data, etc.
There is a simple example of business action which serves data to the business server, invokes report and fills the input parameters with data, and prepares temporary file for download.
function action(context) {
var jsonRequestReader = api.request()
.prepareCreateJSONRequestReader(context)
.create()
var requestContent = jsonRequestReader.getRequestBodyAsObject();
api.logging().prepareLog(context)
.message(scriptFileName)
.addVariable("REQUESTBODYPRINT:", requestContent)
.logDebug();
var types = requestContent.requestBody.searchQuery.types;
api.logging().prepareLog(context)
.message(scriptFileName)
.addVariable("TYPESVARPRINT:", types)
.logDebug();
//var types = ["ft_defDefectElectro", "ft_defDefectWater", "ft_defDefectLighting"];
var result = '';
for (var i = 0; i < types.length; i++) {
if (types[i].indexOf('Electro') !== -1) {
result += 'ELE';
} else if (types[i].indexOf('Water') !== -1) {
result += 'WTR';
} else if (types[i].indexOf('Lighting') !== -1) {
result += 'LIG';
}
if (i < types.length - 1) {
result += '|';
}
}
api.logging().prepareLog(context)
.message(scriptFileName)
.addVariable("DEFECTTYPESPRINT:", result)
.logDebug();
var defectTypes = result;
var outputFormat = requestContent.mainScope.hlp_print_format.toLowerCase();
var fileName = "Defects Report." + outputFormat;
var tempFile = api.temporaryFiles()
.prepareCreateReportFile(context)
.addInputParameter("DEFECT_TYPES", defectTypes)
.outputFormat(outputFormat)
.reportId("defectsReportSimpleByType")
.fileName(fileName)
.create();
var response = api.response()
.prepareCreateClientResponse(context)
.prepareAddTemporaryFile()
.fileId(tempFile.getId())
.add()
.create();
return api.result()
.prepareCreateActionResult(context)
.result(response)
.create();
}
An example of ending a script in case we do not want to download the exported report immediately but only attach it as an attachment to the feature instance.
api.features()
.attachments()
.prepareCreateAttachmentFromTemplateResult(context)
.templateEngine("samo-docx")
.entityRef(context.entity)
.templateId("bs/protocols/types/" + context.entityType + ".docx")
.model(model)
.fileName(context.entityType + ".pdf")
.output("pdf")
.attachmentType("att_boProtocolDocument")
.noSecurity()
.create();
How to create simple Jasper report using LIDS​
If we want to use only LIDS and not SAMO BS for creating reports, we only need to perform the first three steps, also with the difference that the intent is of type report.
1. Report template creation​
First of all you need to create .jrxml report file (using JasperSoft Studio) according to your needs. All reports are stored in the project package (..\metadata-packages\package_name\lids-business-service\resources\report).
Fonts may be missing at the server from which the application is launched (mostly on LINUX servers) and report generating can crash. If that occurs, you need to add given xxx.ttf file in the font's folder in the main project package (..\metadata-packages\package_name\lids-business-service\templates\fonts). Name of the file must be in a specific format (e.g. Arial_bold.ttf or TimesNewRoman.ttf)
<!-- Created with Jaspersoft Studio version 7.0.0.final using JasperReports Library version 7.0.0-b478feaa9aab4375eba71de77b4ca138ad2f62aa -->
<jasperReport name="waterMainsPipelineMasterReport" language="java" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b12d98a7-c4ec-48c5-8c1d-b2b533ef4305">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DMO DEV data adapter"/>
<parameter name="REPORT_DIR" class="java.lang.String"/>
<parameter name="SID_LIST" class="java.util.Collection"/>
<query language="SQL"><![CDATA[SELECT
wm.SID,
wm.C_W_MAINS_FUNC,
wm.C_W_WATER_VARIETY,
cwmf.DESCRIPTION AS CWMF_DESCRIPTION, -- Alias for DESCRIPTION
wm.IDENTIFICATION,
cwv.DESCRIPTION AS CWV_DESCRIPTION -- Alias for DESCRIPTION
FROM W_MAINS wm
JOIN C_W_MAINS_FUNC cwmf ON wm.C_W_MAINS_FUNC = cwmf.C_W_MAINS_FUNC
JOIN C_W_WATER_VARIETY cwv ON wm.C_W_WATER_VARIETY = cwv.C_W_WATER_VARIETY
WHERE $X{IN,wm.SID,SID_LIST}]]></query>
<field name="SID" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="SID"/>
</field>
<field name="CWMF_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="C_W_MAINS_FUNC DESCRIPTION"/>
</field>
<field name="IDENTIFICATION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="IDENTIFICATION"/>
</field>
<field name="CWV_DESCRIPTION" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="C_W_WATER_VARIETY DESCRIPTION"/>
</field>
<field name="C_W_MAINS_FUNC" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="C_W_MAINS_FUNC"/>
</field>
<field name="C_W_WATER_VARIETY" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="C_W_WATER_VARIETY"/>
</field>
<background splitType="Stretch"/>
<title height="81" splitType="Stretch">
<element kind="rectangle" uuid="10f26312-7d87-4550-9f0b-87e0646c13b9" x="0" y="0" width="801" height="81" forecolor="#CFE1FF" backcolor="#CFE1FF"/>
<element kind="staticText" uuid="0f05f1d9-6602-4f7b-b7e9-d7d927eb4fcc" x="0" y="0" width="800" height="79" backcolor="#FFFFFF" fontSize="30.0" bold="true" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Water Mains with Segments Report]]></text>
</element>
</title>
<detail>
<band height="221" splitType="Stretch">
<element kind="textField" uuid="7ade2faa-b52e-4c40-9525-1a9d0fb9db2e" x="0" y="71" width="202" height="30" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{SID}]]></expression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b23b9626-68d5-488d-abde-cd5856fc767a"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="89f59862-2c3b-42d7-9bc1-339d3ed37b21" x="202" y="71" width="200" height="30" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{CWMF_DESCRIPTION}]]></expression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="aafeb981-109a-4c89-8abc-312be2625d1b"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="b248db3a-db53-4500-877d-80fc22c56604" x="402" y="71" width="200" height="30" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{IDENTIFICATION}]]></expression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0d73a46a-4c4a-4cbf-99c6-516b41c81af2"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="684297e6-a5e7-4ae3-a9d8-7fc244544311" x="602" y="71" width="200" height="30" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{CWV_DESCRIPTION}]]></expression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c846f4c9-542a-49e4-b0b2-d17bdfa95283"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="subreport" uuid="0f6fd789-3e9c-4c5e-b673-6d3c26bdf214" x="0" y="130" width="801" height="90">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<expression><![CDATA[$P{REPORT_DIR}+"waterPipelineSegmentsSubreport.jasper"]]></expression>
<parameter name="PAR_R_5040000_5012100">
<expression><![CDATA[$F{SID}]]></expression>
</parameter>
</element>
<element kind="staticText" uuid="cec137bb-c78a-42f9-bdee-9cc810a21269" x="20" y="110" width="180" height="30" fontSize="16.0" hTextAlign="Left" vTextAlign="Bottom">
<text><![CDATA[Pipeline Segments:]]></text>
</element>
<element kind="staticText" uuid="1e53ed3a-c8b3-4e64-bb87-1e601fa65fb5" x="0" y="41" width="202" height="30" bold="true" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[SID]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="b23b9626-68d5-488d-abde-cd5856fc767a"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="staticText" uuid="8dabf6e0-d02d-4dbd-8e16-8977a11de0da" x="202" y="41" width="200" height="30" bold="true" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Function]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="aafeb981-109a-4c89-8abc-312be2625d1b"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="staticText" uuid="18c77ae3-29ab-473c-a39c-4afdaa8e0be7" x="402" y="41" width="200" height="30" bold="true" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Identification]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0d73a46a-4c4a-4cbf-99c6-516b41c81af2"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="staticText" uuid="bbf5b9e5-d8b0-40d1-b43f-759ef82f008a" x="602" y="41" width="200" height="30" bold="true" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Variety]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c846f4c9-542a-49e4-b0b2-d17bdfa95283"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="staticText" uuid="06609cc0-6994-4d92-b464-804dc553971d" x="0" y="10" width="180" height="30" fontSize="16.0">
<text><![CDATA[Mains Pipeline:]]></text>
</element>
</band>
</detail>
<pageFooter height="31" splitType="Stretch">
<element kind="textField" uuid="5ab0d561-8acd-4e4d-aa6a-e296ceeffec6" x="580" y="0" width="100" height="30" hTextAlign="Right">
<expression><![CDATA["Page " + $V{PAGE_NUMBER}]]></expression>
</element>
<element kind="textField" uuid="027da387-d000-4876-9de5-3f0e1fcd274a" x="680" y="0" width="100" height="30" evaluationTime="Report" hTextAlign="Left">
<expression><![CDATA[" of " + $V{PAGE_NUMBER}]]></expression>
</element>
</pageFooter>
</jasperReport>
````
```xml title="example of .jrxml report file"
<!-- Created with Jaspersoft Studio version 7.0.0.final using JasperReports Library version 7.0.0-b478feaa9aab4375eba71de77b4ca138ad2f62aa -->
<jasperReport name="jdbc" language="java" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f43beab4-4da5-41db-a186-0cc764656856">
<property name="template.type" value="columnar"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="10"/>
<style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50.0" bold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18.0" bold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14.0" bold="true" pdfFontName="Times-Roman"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle mode="Opaque" backcolor="#F0EFEF">
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
</conditionalStyle>
</style>
<parameter name="SID_LIST" class="java.util.Collection">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<query language="sql"><![CDATA[SELECT c_w_material.description, pipelines.c_w_material,pipelines.minPress, pipelines.maxPress, pipelines.avgpress FROM c_w_material INNER JOIN
(SELECT c_w_material,MIN(real_press) as minPress, MAX(real_press) as maxPress, AVG(real_press) as avgPress FROM W_PIPELINE WHERE $X{IN,sid,SID_LIST} GROUP BY W_PIPELINE.c_w_material) pipelines
ON pipelines.c_w_material = c_w_material.c_w_material]]></query>
<field name="DESCRIPTION" class="java.lang.String"/>
<field name="C_W_MATERIAL" class="java.math.BigDecimal"/>
<field name="MINPRESS" class="java.math.BigDecimal"/>
<field name="MAXPRESS" class="java.math.BigDecimal"/>
<field name="AVGPRESS" class="java.math.BigDecimal"/>
<group name="Group2">
<expression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></expression>
</group>
<background splitType="Stretch"/>
<title height="97" splitType="Stretch">
<element kind="staticText" uuid="b8eea1a6-5116-4ddb-92c2-003211215017" x="34" y="21" width="505" height="54" fontSize="36.0" bold="false" hTextAlign="Center" style="Title">
<text><![CDATA[Pipelines Pressure Statistics]]></text>
</element>
</title>
<pageHeader splitType="Stretch"/>
<columnHeader splitType="Stretch"/>
<columnFooter height="7" splitType="Stretch">
<element kind="line" uuid="40f73eeb-1d3f-4fd0-a9c7-f0d040d04b84" positionType="FixRelativeToBottom" x="0" y="3" width="555" height="1">
<pen lineWidth="0.5" lineColor="#999999"/>
</element>
</columnFooter>
<pageFooter height="13" splitType="Stretch">
<element kind="frame" uuid="4510f781-a766-40eb-8733-84decd324bc0" mode="Opaque" x="2" y="0" width="555" height="13" forecolor="#D0B48E" backcolor="#9DB1B8">
<element kind="textField" uuid="bf8c1075-563f-4b8f-b375-cc4a1fa116d7" x="513" y="-1" width="40" height="13" forecolor="#FFFFFF" fontSize="10.0" evaluationTime="Report" bold="false" vTextAlign="Middle" style="Column header">
<expression><![CDATA[" " + $V{PAGE_NUMBER}]]></expression>
</element>
<element kind="textField" uuid="984432e1-1ce7-4e7e-85be-e504e2803dde" x="433" y="-1" width="80" height="13" forecolor="#FFFFFF" fontSize="10.0" bold="false" hTextAlign="Right" vTextAlign="Middle" style="Column header">
<expression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></expression>
</element>
<element kind="textField" uuid="e7ddbb1a-7b7a-42ce-b81a-48bf5fc1f0d7" x="2" y="0" width="197" height="13" forecolor="#FFFFFF" fontSize="10.0" pattern="EEEEE dd MMMMM yyyy" bold="false" vTextAlign="Middle" style="Column header">
<expression><![CDATA[new java.util.Date()]]></expression>
</element>
</element>
</pageFooter>
<summary height="368" splitType="Stretch">
<element kind="chart" chartType="bar3D" uuid="74ca1008-d21c-4a69-84e6-8afef8301a05" x="4" y="38" width="551" height="330">
<dataset kind="category">
<series>
<seriesExpression><![CDATA["Minimal pressure [bar]"]]></seriesExpression>
<categoryExpression><![CDATA[$F{DESCRIPTION}]]></categoryExpression>
<valueExpression><![CDATA[$F{MINPRESS}]]></valueExpression>
<labelExpression><![CDATA[$F{DESCRIPTION}]]></labelExpression>
</series>
<series>
<seriesExpression><![CDATA["Maximum pressure [bar]"]]></seriesExpression>
<categoryExpression><![CDATA[$F{DESCRIPTION}]]></categoryExpression>
<valueExpression><![CDATA[$F{MAXPRESS}]]></valueExpression>
<labelExpression><![CDATA[$F{DESCRIPTION}]]></labelExpression>
</series>
<series>
<seriesExpression><![CDATA["Avrage pressure [bar]"]]></seriesExpression>
<categoryExpression><![CDATA[$F{DESCRIPTION}]]></categoryExpression>
<valueExpression><![CDATA[$F{AVGPRESS}]]></valueExpression>
<labelExpression><![CDATA[$F{DESCRIPTION}]]></labelExpression>
</series>
</dataset>
<plot>
<itemLabel/>
</plot>
</element>
</summary>
</jasperReport>
2. Report template registration in presentation.xml​
Now register the report you just created in presentation.xml as dynamic Jasper report.
Id must correspond to the reportId in the corresponding report type intent (later in step 3). Use <ber:dynamicJasperReport> element for dynamic Jasper reports. Define output formats (there you can choose also default one) and specify input parameters in case there are any.
<ber:dynamicJasperReport id="djrwmx" name="Water pipelines with their Pipeline Segments Overview" orientation="landscape">
<ber:description>Dynamic Report for Water Mains with their Pipeline Segments Overview (using LIDS).</ber:description>
<ber:outputFormatArray>
<ber:outputFormat default="true">pdf</ber:outputFormat>
<ber:outputFormat>xls</ber:outputFormat>
</ber:outputFormatArray>
<ber:templateName>waterMainsPipelineMasterReport.jrxml</ber:templateName>
<ber:featureTypeArray>
<ber:featureType xlink:href="model.xml#ft_5040000"/>
</ber:featureTypeArray>
</ber:dynamicJasperReport>
<ber:dynamicJasperReport id="djrpx" name="Dynamic Jasper Report" orientation="portrait">
<ber:description>Pressure Statistics</ber:description>
<ber:outputFormatArray>
<ber:outputFormat default="true">pdf</ber:outputFormat>
<ber:outputFormat>xls</ber:outputFormat>
</ber:outputFormatArray>
<ber:templateName>jdbc.template.jrxml</ber:templateName>
<ber:featureTypeArray>
<ber:featureType xlink:href="model.xml#ft_5012100"/>
</ber:featureTypeArray>
</ber:dynamicJasperReport>
3. Intent button configuration​
Third step is to create an icon or button from which request will be invoked. Add intent configuration to ..\gateway\applications\applicationName\metadata\dynamic-client\samo-entities\intents folder.
The intent must be of the report type.
{
"entitiesGroup": "ft_5040000",
"icon": "samo-icons-action:print",
"title": "{tr:generateReport} (LIDS)",
"type": "report",
"reportId": "djrwmx",
"display": [
"all",
"multi",
"item"
]
}
{
"entitiesGroup": "ft_5012100",
"icon": "samo-icons-action:print",
"title": "{tr:generateReport}",
"type": "report",
"reportId": "djrpx",
"display": [
"all",
"multi",
"item"
]
}