Report Generator management (3/3)


Warning message

You can't delete this newsletter because it has not been sent to all its subscribers.

This tutorial explains how to manage the Report gneration based on the Jasper Server tool and is indicated particularly for users with a profile as administrators.

This is the third part of a tutorial dedicated to the integration and management of the report generation integrated in Snap4City. In fact, this tutorial is divided in three parts as follow:

  1. How to create a Snap4City Report Model. This part is aimed at a developer user.
  2. How to activate and download a Report. This part is aimed at a final user/manager.
  3. How to manage the Report generator, for administrator user (this page).

1. Jasper Report Server

As explained in the part 1 of this tutorial, Jaspersoft Studio is the tool used for the creation of the report templates. To make the reports public and generate them asynchronously it is necessary to use TIBCO JasperReport Server, of which a version already is installed in Snap4city and is used for the generation and management of the reports.

Additional information about the TIBCO JasperReport Server can be found here:

JasperReport Server is organized as a repository divided into directories that are used to manage various report elements such as jrxml files, datasources, images and so on.

The upload of a template file can be done both from the graphic interface of Jaspersoft Studio, through a special dialog, and in JasperReports Server through the "Add resource" command, as shown in the following image.

In both cases, a directory will be created on the server with the project's jrxml file and you will be prompted to select the datasources among those present in the server repository. The project will also upload images, and jrxml files for subreports if it is specified.


A data source is a resource in the repository that defines how and where to obtain the data displayed by reports.

So that to make a report using a data adapter usable on the server, it is necessary to create a datasources through a specific menu, as shown in the following image.

The data source will be used to create a connection with the data of the external data source similar to the data adapter of Jaspersoft Studio. The location of this datasources within the JasperReports Server file system is important for the correctness of the report.

Job scheduling

Among the features of JasperReports Server there is the possibility of making the execution of the report projects asynchronous in order to generate output files according to a predefined time interval, specifying the format of the output files that the destination directory within the server repository. A precise time can be specified for the scheduling start, or a date for the end of the execution.

If the report requires parameters, the user must provide them when starting the scheduler command. If the report project has been updated, the output files generated after this update will also inherit these changes. the following image shows a list of scheduled jobs based on the same report template.

A Job is an instance that manages the scheduled execution of a report template. Multiple jobs of the same report template can be created, the only condition is that they have a different name.

In the case of the Snap4city Report for devices, the name is made up of "Device_report_" and the addition of the Device identification name.

Among the various metadata, the time interval to manage the execution of the template has to be specified for each job. Also the value of the parameter (in this case the identification name of the Device) and some information such as the name of the output file to be generated, its format and destination directory are necessary. All this data are passed to the JasperReport Server via an api, activated by the Data Inspector tool in Snap4City.

JasperReport Server API REST

In Snap4city the creation of the Reports to be scheduled is largely carried out by a JasperReport Server REST API, which allows the creation, modification or deletion of running jobs.

This request includes: a description of the job, a trigger with the definition of the time interval to be scheduled, an insertion of the input parameters required by the report and a description of the output directory in which the file must be generated.

To avoid that the generated reports have the same name and are overwritten among the parameters to be inserted, some parameters must be set as follows:

       "overwriteFiles": false,

       "sequentialFilenames": true,

Example of API REST Request for job creation:


{  "label":"Test_report_job",

   "description":"Schedule Device job Example test",












         "months":{  "month":[  "1", "10","11","12","2","3", "4", "5", "6", "7","8", "9" ]}


















More information about API REST are available here: 

Report activation in Data Inspector

The creation of the report template and its publication on the JasperReport Server are necessary to manage the activation of the report generation jobs through the Data Inspector interface.

JasperReport Server has a REST API system that allows the activation, modification or deleting of jobs. To use them it is necessary that a report template already exists on the server.

In the Data Inspector interface, by clicking the colored point in the Helthness column, it is possible to access to the Data Inspector modal menu. In particlar, in the Report tab the user can activate or deactivate the activation of a job of the scheduler inherent to the specific device selected and set the time interval for the report generation. By clicking the Confim button, this command activates a REST API request in the JasperReport Server that creates the job scheduler, it sends to the server the parameters with the name of the device, the information regarding the name of the files to be created and the destination table (defined in a specific configuration file in the Snap4city tool) and the metadata on the time interval of the scheduling, such as the start date of the creation of the files.

Currently the creation of reports allows the management and asynchronous creation of reports fore devices, through a scheduler which, on the basis of some parameters extracted from some databases and from the servicemap, allows the generation of the output files.

The same features can also be used to create similar reports for other resources managed by Snap4City, such as dashboards and MyKPIs, customizing them to obtain corresponding data to be reported.

These operations are relatively simple if related to the extraction of data from relational databases or other simple data collection systems. The Jaspersoft Studio Editor allows the insertion of small scripts or java expressions to manage data.

However, in the case of data that require some processing or the use of sparql queries to be extracted, the creation of api for supporting data structures may be required, as already described above for the data adapter of the servicemap necessary for the data extraction for graphs generation.

The creation of the reports from the sensor devices required the insertion of a single input parameter, because the Data Inspector structure that was used as a basis for creating the data already exploited the presence of multiple databases connected via the device name.

In fact, a limitation of Jaspersoft already encountered is that of being conceived to carry out processing based on queries or datasources with a rather simple structure.

An example of report can be download by clicking here.