Home > Cloud Cruiser 4 > Administering > Managing reports > Creating custom reports

Creating custom reports

You can create custom reports by using the Jaspersoft Studio application. This section of articles contains the following:

This article explains how to create a new report, either by creating a report from scratch or by modifying an existing report, and how to change the style of all standard reports.

Before you begin

Before you begin the process of creating custom reports, you must install Jaspersoft Studio and ensure that you have a Cloud Cruiser stored procedure to obtain the data you want to use in your report. Optionally, you can configure Jaspersoft Studio to connect with your Cloud Cruiser database.

Installing Jaspersoft Studio

The Community version of Jaspersoft Studio is available for free. For more information, visit the Jaspersoft Community website at http://community.jaspersoft.com/project/jaspersoft-studio.

Writing a stored procedure

In Jaspersoft Studio you define what data you want in your report, but the actual retrieval of data from the Cloud Cruiser database at runtime is handled by a stored procedure. Within the stored procedure you define the SQL statements necessary to retrieve the data you want. You then use the call_procedure property in your report .jrxml file to call the stored procedure. If an existing stored procedure retrieves the data you need, new reports can reuse that stored procedure. For more information, see Managing stored procedures.

(optional) Configuring Jaspersoft Studio to connect with your Cloud Cruiser database

As an optional procedure, you can configure Jaspersoft Studio to connect with your Cloud Cruiser database. This enables you to include Cloud Cruiser database fields in your report and view the quality of your report with real data before you load it to Cloud Cruiser.

To configure Jaspersoft Studio to connect with Cloud Cruiser

  1. In the Jaspersoft Studio Repository Explorer, right-click Data Adapters and select Create Data Adapter.
    NewDataAdapter.jpg
  2. In the Data Adapter Wizard, select Database JDBC Connection, and then click Next.
  3. In the Database Location tab, enter data for the following fields: DatabaseLocation.jpg
    • Name: A name for this adapter, such as Cloud Cruiser Adapter.
    • JDBC Driver: The driver needed for your Cloud Cruiser database connection. For example, if you are using Microsoft SQL Server, select MS SQL Server (net.sourceforge.jtds.jdbc.Driver)
    • JDBC Url: The URL to your Cloud Cruiser database, including the port number. For example: jdbc:jtds:sqlserver://localhost:1433/ccdb
    • Username: The username to your Cloud Cruiser database.
    • Password: The password to your Cloud Cruiser database.
  4. Click Test to validate the connection information you entered. When the test is successful, proceed to the next step.
  5. Click the Driver Classpath tab.
  6. Click Add, and then browse to find the JDBC .jar file installed with Cloud Cruiser.
    For example: <install_directory>\Cloud Cruiser\lib\jtds-1.2.6.jar
    DriverClasspath.jpg
  7. Click Finish.

Creating a report from scratch

To create a report from scratch

  1. In Jaspersoft Studio, select File > New > Jasper Report.
    The New Report Wizard opens.
  2. Select a template, and then click Next.
  3. Select a directory and a File name for your report, and then click Next.
    Save the report outside of the Cloud Cruiser installation directory to prevent import problems that result in the custom report being overwritten by future upgrades to Cloud Cruiser.
  4. In the Data Adapter field, select the Cloud Cruiser adapter you created in Configuring Jaspersoft Studio to connect with your Cloud Cruiser database.
  5. (optional) If you have configured Jaspersoft Studio to connect with your Cloud Cruiser database, you can complete the following steps to load your report with real data from the Cloud Cruiser database. Note that these steps are for only for viewing purposes as you write your report. Later in the procedure you will add a property to call a stored procedure that populates the report with data when it is run from the Cloud Cruiser console.
    1. In the Texts area, enter a SQL statement that includes the Cloud Cruiser data you want to see in your report, and then click Next.
      For example: SELECT * FROM dbo.account_field
      SqlStatement.jpg
    2. Move the database fields you want in your report from the Dataset Fields column to the Fields column, and then click Next.
      DatasetFields.jpg
    3. If you want the data in your report to be grouped by one or more fields, move those fields from the Dataset Fields column to the Fields column. If you do not want data to be grouped in your report, leave all of the fields in the Dataset Fields column. When you are done, click Next.
  6. On the Congratulations page, click Finish.
    The new report opens for editing.
  7. Customize the content and appearance of your report to meet your needs. For assistance, see the Jaspersoft Studio documentation at community.jaspersoft.com/documentation.
    From the Outline section of JasperSoft Studio, you can drag Cloud Cruiser database fields to the report Design area.
    OutlineArea.jpg
  8. Click the Source tab in the Jaspersoft Studio report designer to view the source XML of your report.
    Note that the opening <jasperReport> tag includes a name parameter with the name of your report as its value. This piece of metadata must be unique within Cloud Cruiser to distinguish this report from other reports. If there is no name attribute, or the value is not unique within Cloud Cruiser, the import of the report will fail.
  9. To the opening <jasperReport> tag, add the following attribute-value pair:
    scriptletClass="com.cloudcruiser.core.report.DataUtilScriptlet"
    This attribute allows the Jasper report to make use of Cloud Cruiser's DataUtilScriptlet library, which is required for parameters to work properly in the report.
  10. Immediately below the opening <jasperReport> tag, add the following properties, where <group_name> is the name of the report group that will contain this report on the Standard Reports page of the Cloud Cruiser console, and <sp_name> is the name of the stored procedure that will retrieve data from the Cloud Cruiser database. For more information about these and other properties you can define in your report, see Report properties and parameters.
    <property name="com.cloudcruiser.report.group" value="<group_name>"/>
    <property name="com.cloudcruiser.report.view_type" value="HTML"/>
    <property name="com.cloudcruiser.report.cache_type" value="REPORT"/>
    <property name="com.cloudcruiser.report.restricted" value="true"/>
    <property name="com.cloudcruiser.report.call_procedure" value="<sp_name>:inAccountLevel,inAccountFieldValues"/>
    
    For example, the following image shows a report that will be added to the Invoices group in Cloud Cruiser, and which calls a stored procedure named sp_sample:
    cc_properties_recommended.jpg
  11. (optional) If you want to add selectable parameters that allow you to pre-filter the results of your report, provide add those lines to the source XML of your report immediately above the <queryString> line. Parameters appear as fields on the Parameters page in Cloud Cruiser.
    For example, if you want to include Account Level and Account Filter as parameters for your report, add the following lines to the source XML:
    <parameter name="inAccountLevel" class="java.lang.String">
       <property name="com.cloudcruiser.param.account_level" value="All=0"/>
    </parameter>
    <parameter name="inAccountFieldValues" class="java.lang.String">
       <property name="com.cloudcruiser.param.account" value=""/>
    </parameter>
    cc_parameters.jpg
    For a full list of parameter properties, see Report properties and parameters.
  12. If you completed step 5 to add an SQL statement that allows you to view real data in Jaspersoft Studio, remove that query and the surrounding <queryString> tags from the .jrxml file.
    For example, if you added the statement SELECT * FROM dbo.account_field, you must remove the following lines:
    <queryString>
       <![CDATA[SELECT * FROM dbo.account_field]]>
    </queryString>
  13. Save your .jrxml file.
  14. In a text editor, create a .properties file with the same name as your report .jrxml file.
    For example: SampleReport.properties.
  15. Add the following lines to your properties file, where <title> is the name of your report and <description> is the description that appears under the title in Cloud Cruiser.
    com.cloudcruiser.report.default_title=<title>
    com.cloudcruiser.report.description=<description>
  16. (optional) If you added selectable parameters to your report .jrxml file, add a label and description for each parameter to the .properties file. This allows Cloud Cruiser to display the parameter and provide appropriate field values on the Parameters page of the report.
    For example,  if you added parameters named inAccountLevel and inAccountFieldValues to your .jrxml file, add the following lines to the .properties file:
    com.cloudcruiser.param.inAccountLevel.label=Account Level
    com.cloudcruiser.param.inAccountLevel.description=Select the account level you want to use for this report
    
  17. (optional) If your report .jrxml file includes $R{} resources, update your report .properties file to include a line that defines the string to be displayed when the report is run.
    For example, if your .jrxml file includes an $R{report.footer.total} resource to add the text string "Total" as a footer element under a column of data, you would include the following line in your report .properties file:
    report.footer.total=Total
  18. Save your .properties file.
  19. Load the report to Cloud Cruiser, as described in Loading and removing reports.

Creating a new report from an existing report

If an existing report is similar to the report you want, you can copy the report .jrxml and .properties files, and then edit them to suit the needs of your new report.

While copying a report can be faster than creating a report from scratch, it also has the potential to be more complicated, especially if you are copying one of the Cloud Cruiser standard reports. Some reports make extensive use of Jasper variables, parameters, and resources. Some parts of the report might have dependencies on other content, and these dependencies can be difficult to identify. Because changing or deleting lines from the .jrxml file can cause problems in the report, consider copying a report only if you need to make few and simple changes.

To create a new report from an existing report

  1. In the <install_directory>/reportfiles directory, locate the .jrxml and .properties files of the report you want to copy.
  2. Copy the files to a directory outside of the Cloud Cruiser directory, such as C:\cc-working\custom_reports.
    Perform the remaining steps of this procedure on the new files in this directory, and not on the source files in the reportfiles directory.
  3. If you want to keep the same report name and overwrite the original version, while retaining a backup of the original report in the reportfiles directory, skip to the next step. Otherwise, to give your new report a unique name, rename the report .jrxml and.properties files to match.
    For example, 
    to change the name from InvoiceWithTiers (the Standard Invoice in the Cloud Cruiser Portal) to CustomInvoice you must change the names if the InvoiceWithTiers.jrxml and InvoiceWithTiers.properties files to CustomInvoice.jrxml and CustomInvoice.properties.
  4. In the new report .jrxml file, change the values of the Report Name and Resource Bundle properties in the report template to match the new file name.
    For example, if the report files are named CustomInvoice, the Report Name and Resource Bundle properties must have a value of CustomInvoice.
  5. Open the report .jrxml file in Jaspersoft Studio and make the desired changes.
  6. Open the report .properties file in a text editor and make the desired changes.
  7. Load the report to Cloud Cruiser, as described in Loading and removing reports.
 

Modifying the style of all standard reports

The standard reports shipped with Cloud Cruiser reference a style template for common header colors and fonts. You can change these attributes.

To modify styles for all standard reports

  • Use Jaspersoft Studio to edit the file <installDir>\apache-tomcat-7.0.54\webapps\ROOT\skins\CC\StdReportStyleTemplate.jrtx.
Last modified

Tags

This page has no custom tags.

Classifications

This page has no classifications.
© Copyright 2018 Hewlett Packard Enterprise Development LP