Scenario:
You have a JSON file that can be used as a data source from report. In TIBCO JasperReports® Server you want to create a new domain based on that JSON file and allow users to build ad hoc reports. How to achieve this?
Solution:
JasperReports® Server provides a few types of JSON based data sources and most of them include domains. The best one to use currently (7.5.0) is to use a JSONQL data source. To use that data source and build a domain over it you'll need to do the following:
- Enable the data source in the server. To enable it, edit the {JRS WAR}/WEB-INF/applicationContext-remote-services.xml. In the file locate the following list:
<util:set id="customDataSourcesToHide">
Inside the set, comment out jsonQLDataSource: <!--value>jsonQLDataSource</value--> - Save the file and restart JasperReports Server
- In JasperServer, create a new data source. In the data source type, select JSONQL Data Source.
- Configure the data source. Specify the location of your JSON file in the repository or provide a web URL where the file can be obtained from.
- Configure the number pattern and date pattern. Both can be left as empty but your dates and numbers in that case will be recognized as strings. The patterns are standard Java patterns:
- In the Query section just put an asterisk *. This means that we are going to select everything from the file.
- Use connection set to default false. This flag indicates whether we want to use the query from the data source exclusively or use the report query which can be different. In case of domains it doesn't matter but if you want to base other reports on this data source and have their query influence the result set, this needs to be set to false
- Save the data source
- Create a domain. In the domain data source, specify the JSONQL data source as the domain source
- Select the tables, create the domain, proceed to use with ad hoc editor
NB: JSONQL itself is a powerful data source with it's own JSON query language. You can read more about it here:
http://jasperreports.sourceforge.net/sample.reference/jsonqldatasource/index.html
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now