spring-boot-birt
A simple BIRT Rendition Engine
Run the Application
To run the applicatin, use the gradle wrapper (gradlew), which will download a Gradle Runtime and start the run task. If you have Gradle installed you can run the run task without the wrapper.
gradlew run
Alternatively you can create an uber-jar using the task installBootDist.
gradlew installBootDist
and run the report application using the ~/birt/build/install/birt-boot/bin/birt script.
You can even execute the jar: java -jar birt-0.0.1.jar
from either
~/birt/build/install/birt/lib or ~/birt/build/install/birt-boot/lib directory.
Overwrite the bundled properties in one of the following ways as described in the Spring.io documentation:
- Environment Variable
BIRT_REPORT_PARAMS_DATASET='{ "firstname": "Max", "lastname": "Schremser", "company": "Microsoft" }' java -jar birt/build/install/birt-boot/lib/birt-0.0.1.jar
- Java System Property
java -Dbirt.report.params.dataSet='{ "firstname": "Max", "lastname": "Schremser", "company": "Amazon" }' -jar birt/build/install/birt-boot/lib/birt-0.0.1.jar
- Command line argument
java -jar birt/build/install/birt-boot/lib/birt-0.0.1.jar --birt.report.params.dataSet='{ "firstname": "Max", "lastname": "Schremser", "company": "Google" }'
- External Properties file
java -jar birt/build/install/birt-boot/lib/birt-0.0.1.jar --spring.config.name=ms
or any different environment.
Instead of setting the report parameter dataset in JSON format, the parameters for firstname, lastname and company can be set to form the JSON object.
gradlew -Dbirt.report.param.firstname=Max -Dbirt.report.param.lastname=Schremser -Dbirt.report.param.company=IBM run
Birt Report (simple.rptdesign)
You can run the Report from within Birt Designer using the Default values. When running the spring boot application the report parameters are taken from the birt.properties file.
Data Source (dataSource)
The Data Source is the source for the data. It has two Script methods:
- open()
- close()
open()
Here we create a dataSource Object using the JSON syntax. The boolean moreData is used to exit the fetch() method. If you do not return from the fetch() method, the report render task will not finish.
dataSource = {"firstname": "Matt", "lastname": "Groening", "company": "Netflix"};
moreData = true
close()
The close method frees up the resources.
dataSource = null
Data Set (dataSet)
The Data Set (row) that holds the Column values. We implement the tree methods:
- open()
- close()
- fetch()
open()
moreData = true
close()
moreData = false
fetch()
Copies the values from the Data Source into the Data Set Row. Only 1 row. The values can also be calculated or fetched using Java. For more information on using Java classes for Birt's Rhino Engine look here: github.com/kstojanovski/birt
if (!moreData)
return false;
row["firstname"] = dataSource.firstname;
row["lastname"] = dataSource.lastname;
row["company"] = dataSource.company;
moreData = false;
return true;