Class Sample1


  • public class Sample1
    extends AbstractReportGenerator
    Generates a report in the following scenario:
    1. The report definition file is a .prpt file which will be loaded and parsed
    2. The data factory is a simple JDBC data factory using HSQLDB
    3. There are no runtime report parameters used
    • Constructor Detail

      • Sample1

        public Sample1()
        Default constructor for this sample report generator
    • Method Detail

      • getReportDefinition

        public org.pentaho.reporting.engine.classic.core.MasterReport getReportDefinition()
        Returns the report definition which will be used to generate the report. In this case, the report will be loaded and parsed from a file contained in this package.
        Specified by:
        getReportDefinition in class AbstractReportGenerator
        Returns:
        the loaded and parsed report definition to be used in report generation.
      • getDataFactory

        public org.pentaho.reporting.engine.classic.core.DataFactory getDataFactory()
        Returns the data factory which will be used to generate the data used during report generation. In this example, we will return null since the data factory has been defined in the report definition.
        Specified by:
        getDataFactory in class AbstractReportGenerator
        Returns:
        the data factory used with the report generator
      • getReportParameters

        public Map<String,​Object> getReportParameters()
        Returns the set of runtime report parameters. This sample report uses the following three parameters:
        • Report Title - The title text on the top of the report
        • Customer Names - an array of customer names to show in the report
        • Col Headers BG Color - the background color for the column headers
        Specified by:
        getReportParameters in class AbstractReportGenerator
        Returns:
        null indicating the report generator does not use any report parameters
      • main

        public static void main​(String[] args)
                         throws IOException,
                                org.pentaho.reporting.engine.classic.core.ReportProcessingException
        Simple command line application that will generate a PDF version of the report. In this report, the report definition has already been created with the Hitachi Vantara Report Designer application and it located in the same package as this class. The data query is located in that report definition as well, and there are a few report-modifying parameters that will be passed to the engine at runtime.

        The output of this report will be a PDF file located in the current directory and will be named SimpleReportGeneratorExample.pdf.

        Parameters:
        args - none
        Throws:
        IOException - indicates an error writing to the filesystem
        org.pentaho.reporting.engine.classic.core.ReportProcessingException - indicates an error generating the report