Part I - Integrate reporting engine

You need a plugin on the server side which holds all necessary files for the reporting engine. The scout sdk provides an easy way to create such a plugin. But first you have to download the Jasper Reports project from sourceforge and extract the contents somewhere.

Now create a new library bundle linked with the server.

Add all jars from the lib folder and jasperreports-X.Y.Z.jar from the dist folder of jasperreports to the bundle.

Use org.eclipse.scout.minicrm.jasperreports as bundle name.

Part II - Create the company report

The next step would be to create a basic company report. To bundle the report files with the server we need to create a new Plug-In Project org.eclipse.scout.minicrm.reports, add it as Required-Plug-in to the server bundle and as dependency to the server product.

Now switch to the Package Explorer and create a folder reports in the new plugin. Add the reports folder to the binary build in the build.properties file of the reports plugin.

Use either iReport to create a new company report company.jrxml in the reports folder or copy and paste the xml-code below in an eclipse text editor.

In iReport create a new Parameter COMPANY_ID type Long

add two String-fields SHORT_NAME and NAME.

Delete all bands except Detail 1.

Create a query

SELECT*FROM COMPANY WHERE COMPANY_NR=$P{COMPANY_NR}

Pull the fields SHORT_NAME and NAME into the Detail 1 band to create two text fields.

Now save and compile the report.

The resulting company.jrxml file should look like this:

<?xmlversion="1.0"encoding="UTF-8"?><jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"name="company"language="groovy"pageWidth="595"pageHeight="842"columnWidth="555"leftMargin="20"rightMargin="20"topMargin="20"bottomMargin="20"uuid="1323c093-d996-4147-9bf1-70dd55938124"><propertyname="ireport.zoom"value="1.0"/><propertyname="ireport.x"value="0"/><propertyname="ireport.y"value="0"/><parametername="COMPANY_NR"class="java.lang.Long"/><queryStringlanguage="SQL"><![CDATA[SELECT * FROM COMPANY WHERE COMPANY_NR=$P{COMPANY_NR}]]></queryString><fieldname="SHORT_NAME"class="java.lang.String"/><fieldname="NAME"class="java.lang.String"/><background><bandsplitType="Stretch"/></background><detail><bandheight="42"splitType="Stretch"><textField><reportElementuuid="fa7e30cb-3ea6-440b-b63a-dc78ad1a9b75"x="0"y="0"width="100"height="20"/><textElement/><textFieldExpression><![CDATA[$F{SHORT_NAME}]]></textFieldExpression></textField><textField><reportElementuuid="16560b8b-c67b-434e-a669-0f1cf2a7d7ec"x="0"y="20"width="100"height="20"/><textElement/><textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression></textField></band></detail></jasperReport>

Part III - Create the report on the server

Now you have to create a service which generates the report. First you need a new Custom Service Package called org.eclipse.scout.minicrm.server.services.custom.reporting. In this package you can create a new ReportingService.

In this ReportingService you need to create a new Service Operation createCompanyReport.