The World's Most Widely Used Business Intelligence Software
0

The JasperReports Server Advantage

 
Posted by lshannon Monday, April 18, 2011 at 11:16am

The JasperReports Server Advantage

This article reviews the benifits of using JasperReports Server (formerly called JasperServer) in your JasperReports Library (JR) based solutions. For a complete overview of Jaspersoft's product suite, please review this article.

JasperReports Server (JRS) is a web application that is optimized for hosting JasperReport templates. This means you could build a report using the iReport Designer and then deploy it to JRS. Users would then log into JRS and execute the report, export it to the desired output, or schedule it to execute at a later date (perhaps re-occuring).

Also thanks to JRS web services API, other applications could display reports that are hosted in JRS without having to manage the report template or any of its dependancies.

JRS can offer a lot to your reporting solution. This article will provide a brief overview of advantages it provides.

JasperReports Server Advantages:

  1. Flexible and robust security
  2. Report Execution and Scheduling
  3. Repository
  4. Web Services API
  5. Source Code is available
  6. Configurable and extensible
  7. Professional Features

We will discuss each of these in detail.

Flexible and Robust Security

Back to top

JRS is built on the Spring Framework (version 2.5). It uses Spring Security to secure the application (version 2.0). Spring Security is a mature and widely used security framework (see Ben Alex's presentation for more information).

Spring Security is configured in JRS using the older Acegi style XML configuration file.

This more verbose XML configuration gives a fine level of control for configuring the Authentication and Authorization within JRS as well as the opportunity to extend modules in the security implementation.

The product ships with some alternate authenticator options which are ready to be enabled. For example there is an LDAP authenticator. All one needs to do is to uncomment some XML snippets, make updates to contain settings from your environment, save the XML and restart the server and (in theory) LDAP authentication should be enabled. A similar configuration is in place for CAS.

Also its possible to add custom authenticators to the authentication chain that support single sign on (SSO) functionality.

Jaspersoft sells an excellent guide outlining the configuration of LDAP and CAS with JasperReports Server called the Authentication Cookbook.

Lets review how security works in JS:

JRS has Users >> JRS has Roles >> Users have Roles >> Elements in JRS are assigned permissions >> Permissions are associated with Roles or Users

Note: The enterprise version of JRS has the concept of organizations, we will address this a little later on in the article.

Once you have gotten into the application you can begin working. Lets review what you can do.

Report Execution and Scheduling

Back to top

Once a report is deployed to JRS, users can log in and perform the following:

  1. Execute the report in real time
  2. Execute the report in the background
  3. Schedule the report to execute (Calendar or Cron style reoccurance, functionality provided by Quartz)
  4. Export reports executed in real time different output options

Many times I have seen developers create a custom solution built around JR and coded functionality like the above only to ended up building JRS (something to keep in mind if you are just getting started).

Lets review a few relevant points and see some screen shots from each example.

Here we see the options for a non adminstrative user when right clicking on a report in JRS. By clicking View we can run the report, run in background will execute the report on a seperate thread allowing the user to explore the application will it executes.

In the next screenshot we see the full scheduling options when setting up a reoccuring report execution.

Next we look at the options for output. As can be seen a PDF export of this report will be emailed to the address provided. Should the query return no results and the report be blank, the email will not be sent. To send emails all you need to do is specify SMTP details in a property file within your deployed JRS. The output is also stored in the repository. At present the job is creating sequentially named files. This means the file name will include the date. If this is not desired you can select overwrite files. This option will overwrite the output each time.

Finally here is what an report looks like after it has been executed. As you can see the HTML version of the report is displayed complete with pagination controls. In the upper left we see all the export options. Since the filled report is stored as a JasperPrint object in the session, generating an export does not require another trip to the data source.

Lastly JRS provides many options for Input Controls. These are widgets that collect data from the user running the report that can be used to inject into the report query or dynamically modify the report layout (input controls map to parameters for those already familar with JRXML).

These controls can be driven by data base values or when the user is required to type in values, can include validation to ensure input falls into a specific range.

Below you can see a grouping of controls on the left that combines date driven controls with text and date inputs. Next to this are three data based controls are are cascading. This means a selection of the first control updates the choices in the second, and the choices of the third depend on the selections made in the first and second.

 

Repository

Back to top

When you deploy a report to JRS or export a report within JRS (perhaps through scheduling) the contents are stored in the repository. The repository is not on the file system, but rather in a data base.
As JRS is running its in constant communication with the repository using Hibernate. Even Jar files and Images are stored in the repository (as blobs).

The main advantage here is easy back up and restoration of the repository when setting up a new JRS instance or upgrading to a new version.

To assist in this Jaspersoft has also provided import and export scripts. These are command line based scripts (there are shell and .bat versions) that can be used to export/import the entire repository, a single folder or even a single report.

Upon Import those same elements will be created (if they don't exist) and if the elements currently exist, you can set an update flag to overwrite them. This can be useful when migrating a report from one JRS (test) to another JRS (production).

Here is what an export looks like using the export script. A zip file is generated with all the content required for the import script to recreate the element in another JRS.

Web Services API

Back to top

JRS allows for the following functionality to be performed using Web Services:

  • Report Scheduling and Execution
  • Creation/Modification of elements in the Repository
  • Creation/Modification of Users/Roles/Organizations/Permissions
  • Obtaining Meta Data against Domains as well as executing Domain queries

JRS uses a XML/RPC SOAP based web services arcitecture. In the source code there are some helper classes to assist with sending and receiving responses to the server. I will be publishing an article in the next few weeks addressing Web Services specifically.

Source Code

Back to top

With all editions of the product the source code is available. Jaspersoft provides a ant based command line tool affectionately called 'Build-o-Matic' that automates the building and deploying of the source code to several supported platforms.

You can also build the source in your IDE of choice. With this is place you can put in break points and debug as well as step through running code to gain a better understanding of how things work. See my article on this subject.

Configurable and extensible

Back to top

Another advantage having the source is it makes it easier to extend things. Since JRS is built with Spring, its easy to find a component currently wired into the application, extend it with your own logic and then wire your version into the application (this requires a change to an XML file and a restart of the server). Common Extensions Points:

  1. Data Sources
  2. Security Extension

For a good example of custom data sources see my article on Creating Switching Data Sources in JRS.

Professional Features

Back to top

The commerical edition of JRS has many features that make it compelling. The following is a brief overview of a few of them.

Multi-Tenancy

In JRS Enterprise you can create organizations which in turn have Users and Roles. When a user logs in they only see their organization and not any parallel ones (they can see sub organizations). This is nice when you want to ensure data will be secure across different organizations in your business.

Dashboard Designer

JRS Professional and Enterprise has a nice dashboard designer which is browser based. It allows a user to create a dashboard in a drag and drop fashion using reports that have been deployed to Jasperserver's repository. You can also add content from external sources by providing the URL to the site you wish to display.

Dashboards can have input controls to capture input from the user allowing them to constrain the data in the dashboard. The values selected in these controls can also be passed in the HTTP request to the external content.


Adhoc Report Design

This is another browser based design tool which allows less technical users to create Table/Chart or Cross Tab style reports in a web browser. This can be done in a drag and drop fashion with properties and settings changed with right click menus.

The starting point can be a report (deployed to JRS from iReport) or a Domain (will discuss this next). Either way the user is working with a list of columns from a data source and determining how to display them in the report layout.

The table view is a simple way to display the data which allows users to:

  1. Create custom fields (numberic operations and date comparisons)
  2. Pick columns for grouping and Sorting
  3. Changing the formatting of data (dates, currency, numbers)
  4. Add Summaries
  5. Change the theme of the report

The chart layout allows the users to create simple charts, modify their look and feel and even change the chart type after creation.

The cross tab allows for some simple analysis of the data by aggregating the data by column and group. You can drill down into measures to get a table report showing all the data that made up the aggregation. By placing fields in the same row/column grouping you can also create hierarchies (in the screen shot below you can see Country -> City).

And with all fields with a simple right click you can create a filter that can be used to constrain the data set. When you save the report, the filter becomes an input control.

And course any report created in Adhoc can be opened back up in the designer provided the user has the permissions to edit the unit. This allows users to edit reports they have created or modify and then save with a different name.

Auditing

The Enterprise edition allows you to configure the application to log certain events in the system. The framework that auditing is built around also makes for a great extension point. Basically audit data is accumulated in the repository DB and then you can report off it using the tools with in JasperReports Server.

Domains

In JRS Professional and Enterprise edition the Domains act as data sources. They are a meta layer between the reports and the underlying data base.

The idea with Domains is they allow for easy joining of the data base tables and organize the resulting columns into a nice business friendly presentation.

This is done with an easy to use web based designer within JRS.

Domains also allow for calculated fields. The calculations are created using DomEL (domain expression language). This is a simple language that allows for manipulation of fields that resolves to SQL in the underlying DB. (example: There is a concat function that simply takes a comma seperated list of string, the domain engine generates SQL for this operation for a robust list of data base vendors). Its possible to define custom domEL functions. One can also bind custom java objects allowing for data from a third party to be combined with data from the data base when the users is running their report (example: imagine an field in the report that contains the current exchange rate for US -> CAN conversations that is automatically update with each report execution. Users could then use this field in custom calculations when designing the report).

In the following screen shot we can see some tables being joined within the web based designer

Domains also have a feature called Virtual tables in which you pass any SQL down to the underlying DB for evaluation. You can do all the joins in this route, rather than using the UI. From a high level how domains work is they act as a data source. Users pick columns from them to get data and the engine generates the SQL to the underlying data base.

Here we can see a calculated field being created. The syntax is the domEL.

Here we see a nice business friendly representation of the join tree being created. Formatting for columns can be applied at the domain level as well.

Domains come with data level security. The data returned be a domain be filtered based on user generated filters or security constraints. Security constraints can be for row filtering and column access rules based on the User running the report. This allows you to create one domain for an entire set of organizations and build rules around filtering of data based on the organization name/user name/roles associated with the user or a profile attribute. See my posting on securing Domain data for more details on this.

Lastly the commercial edition of JRS caches result sets generated by the domain engine. This can greatly improve performance. The cache can be configured to determine how long data sets can exist in the cache.

The application can be configured to do filtering of data (both user generated filters and security) in memory. This reduces the load on the data base and increases response time of reports. This is a configurable behavior, with larger data sets a well tuned data base can often perform better than in memory.

Conclusion

Hopefully this will give you a little taste of the benifits of JasperReports Server.

Please continue to check the site for more articles or tutorials. Please send me comments or questions on this article here.