Skip to main content

Overview

Header

Level: Padawan/Jedi Knight

Keywords: report, template, JasperReports, messaging, attachments, temporary file

The result: overview of report's types used in SAMO

Reports creating or "templating" is a way how to create a report with attributes from one instance of feature type (FT) or collection of FT's. It can be used as a body of message or as a file for downloading. This chapter gives basic overview of templating in SAMO application.

Use of Reportsโ€‹

Reports have a very wide range of use:

  • generate report from defined FT(s)
  • use of report as an attachment to emails
  • use of report as a body of message (sms, email)
  • create report as a temporary file for downloading
  • create report as an attachment to FT

Formats of Reportsโ€‹

Reports can be generated in many formats: pdf, docx, xlsx, html, txt, csv, rtf

Types of Reportsโ€‹

Basically there are two types of reports which can be used in SAMO application. Here you can find basic informations. Both of them are described in more detail in individual pages.

  1. LIDS Reports: basic type with declarative regulation, using common technology of LIDS AS nad Jasper Reports tool library

    • two basic types: static and dynamic
    • data source is SQL query
    • input template is JasperReports XML-file
    • possibility to use input parameters
    • output formats include pdf, docx, xlsx, html, csv, rtf
    • suitable for use as an attachment in messaging or for FT, or as temporary file for downloading
  2. SAMO BS Reports: advanced type of templating with the use of SAMO BS

    • data source is mostly "JSON model" prepared in JS or SQL query (it is possible to combine both sources)
    • input template is mostly JasperReports XML-file, but can be docx or html
    • possibility to use input parameters
    • output formats include pdf, docx, xlsx, html, csv, rtf
    • suitable for all purposes (messaging, attachments, temporary file)
tip

Connect to the DB is provided through JDBC driver which is obtained from LIDS connector. This means that you don't need to take care of anything and your SQL queries will return the data for chosen feature instances.

Creating Reports templateโ€‹

First of all, you need to create the template which is processed by the server with result of report with filled attributes inputs from client application. There are two main ways how to create reports. Choosing which approach to use, depends on purpose.

Creating report template in docx format:โ€‹

The simplest approach is to create a report template in docx format. It is possible to write and format your own text and put there references to the attributes obtained from model object in business action. It is also possible to use some functions from FreeMarker which is a Java library to generate text output. Docx template has a big advantage in the simplicity of creation, because final report will look like exactly how you format it in the template (colors, fonts, text formatting, text offset, text alignment, pictures, watermarks).

Docx template is suitable for simple text, when you need to fill few attributes from master FT or related FT. But it can't be used for dynamic lists of FT's (collection of FT's).

Example of docx template can be downloaded here. This example only used simple freemarker notation, here is an example of a simple template using the SAMO-docx engine.

Advantages of docx template

  • no need of additional specialized software
  • easy text formatting
  • template can be edited easily

Disadvantages of docx template

  • can't create dynamic lists
  • impossibile to use complex conditions
warning

Template created in docx format has some limitations. It is not able to use dynamic lists (collection of FTs). E.g. if you want to list all instances of related FT to the master FT. For this purpose use JasperReports XML-file.

Creating report template in JasperReports XML-file:โ€‹

Advanced approach is using JasperReports XML-file. For creating this type of file it is recommended to use JasperSoft Studio design tool โ€” an open source WYSIWYG report designer for JasperReports. It is used to design templates even with a very complex layout. The JasperSoft Studio is capable of querying multiple data sources including databases using JDBC driver and JSON.

tip

It is recommended to use the latest TIBCO Jaspersoftยฎ Studio 7.0.0, it can be downloaded at Jaspersoft Community page

Due to JasperSoft Studio's wide range of functions and possibilities, this type of template is suitable for more complex reports, when you want to print collection of FT's or combine more data sources.

Example of JasperReports XML-file template can be downloaded here.

Advantages of JasperReports XML-file template

  • combining more data sources
  • possibility of a very complex layout
  • wide range of built-in functions and text formatting
  • possibility to create dynamic lists of FT's collection
  • possibility to compose complex conditions with use of JAVA language
  • possibility to add static map (need to prepare in JS)

Disadvantages of JasperReports XML-file template

  • need for knowledge of specialized software
  • long time to get familiar with JasperReports XML-file
  • converting all objects as table objects
  • difficult to edit template (by customer)
  • no objects in template may overlap with each other (impossibility to use watermark or picture as a background)

How to create a simple template in JasperSoft Studio is written in LIDS Implementation Guide, chapter 18.5

Complex description of JasperSoft Studio and its possibilites can be found here. Recommend seeing JasperSoft Studio User Guide Chapters 1โ€“4, 6โ€“8, 10โ€“11. An overview of functions which can be used in an expression can be found here.

warning

The "docx4j library" is used during the creation of final report in docx format through client application. That's why all objects in final report look like table objects and no objects in template may overlap each other. This results in a more complicated editing of final report.