org.kuali.kfs.sys.service.impl
Class ReportGenerationServiceImpl

java.lang.Object
  extended by org.kuali.kfs.sys.service.impl.ReportGenerationServiceImpl
All Implemented Interfaces:
ReportGenerationService

public class ReportGenerationServiceImpl
extends Object
implements ReportGenerationService

To provide utilities that can generate reports with JasperReport


Field Summary
protected  org.kuali.rice.kns.service.DateTimeService dateTimeService
           
static String DESIGN_FILE_EXTENSION
           
static String JASPER_REPORT_EXTENSION
           
static String PARAMETER_NAME_SUBREPORT_DIR
           
static String PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME
           
static String PDF_FILE_EXTENSION
           
static String SEPARATOR
           
 
Constructor Summary
ReportGenerationServiceImpl()
           
 
Method Summary
 String buildFullFileName(Date runDate, String directory, String fileName, String extension)
          build a full file name with the given information.
protected  void compileReportTemplate(String designTemplate, String jasperReport)
          complie the report template xml file into a Jasper report file if the compiled file does not exist or is out of update
protected  void compileSubReports(Map<String,String> subReports, String subReportDirectory)
          compile the given sub reports
 void generateReportToOutputStream(Map<String,Object> reportData, Object dataSource, String template, ByteArrayOutputStream baos)
          generate a report as PDF file and outputs to stream
 void generateReportToPdfFile(Map<String,Object> reportData, Object dataSource, String template, String reportFileName)
          The dataSource can be an instance of JRDataSource, java.util.Collection or object array.
 void generateReportToPdfFile(Map<String,Object> reportData, String template, String reportFileName)
          generate a report as PDF file with the given file name
protected  org.springframework.core.io.ClassPathResource getReportTemplateClassPathResource(String reportTemplateName)
          get a class path resource that references to the given report template
protected  String removeTemplateExtension(org.springframework.core.io.ClassPathResource template)
          remove the file extension of the given template if any
 void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
          Sets the DateTimeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dateTimeService

protected org.kuali.rice.kns.service.DateTimeService dateTimeService

PARAMETER_NAME_SUBREPORT_DIR

public static final String PARAMETER_NAME_SUBREPORT_DIR
See Also:
Constant Field Values

PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME

public static final String PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME
See Also:
Constant Field Values

DESIGN_FILE_EXTENSION

public static final String DESIGN_FILE_EXTENSION
See Also:
Constant Field Values

JASPER_REPORT_EXTENSION

public static final String JASPER_REPORT_EXTENSION
See Also:
Constant Field Values

PDF_FILE_EXTENSION

public static final String PDF_FILE_EXTENSION
See Also:
Constant Field Values

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values
Constructor Detail

ReportGenerationServiceImpl

public ReportGenerationServiceImpl()
Method Detail

generateReportToPdfFile

public void generateReportToPdfFile(Map<String,Object> reportData,
                                    String template,
                                    String reportFileName)
Description copied from interface: ReportGenerationService
generate a report as PDF file with the given file name

Specified by:
generateReportToPdfFile in interface ReportGenerationService
Parameters:
reportData - the data being written into the PDF report file
template - the report template full file name
reportFileName - the full name of the generated PDF file
See Also:
org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToPdfFile(java.util.Map, java.lang.String, java.lang.String)

generateReportToPdfFile

public void generateReportToPdfFile(Map<String,Object> reportData,
                                    Object dataSource,
                                    String template,
                                    String reportFileName)
The dataSource can be an instance of JRDataSource, java.util.Collection or object array.

Specified by:
generateReportToPdfFile in interface ReportGenerationService
Parameters:
reportData - the data being written into the PDF report file
dataSource - the data source being used for the PDF report
template - the report template full file name
reportFileName - the full name of the generated PDF file
See Also:
org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToPdfFile(java.util.Map, java.lang.Object, java.lang.String, java.lang.String)

generateReportToOutputStream

public void generateReportToOutputStream(Map<String,Object> reportData,
                                         Object dataSource,
                                         String template,
                                         ByteArrayOutputStream baos)
Description copied from interface: ReportGenerationService
generate a report as PDF file and outputs to stream

Specified by:
generateReportToOutputStream in interface ReportGenerationService
Parameters:
reportData - the data being written into the PDF report file
dataSource - the data source being used for the PDF report
template - the report template full file name
See Also:
org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToOutputStream(java.util.Map, java.lang.Object, java.lang.String, java.io.ByteArrayOutputStream)

buildFullFileName

public String buildFullFileName(Date runDate,
                                String directory,
                                String fileName,
                                String extension)
Description copied from interface: ReportGenerationService
build a full file name with the given information. The format of the file name is _.

Specified by:
buildFullFileName in interface ReportGenerationService
Parameters:
runDate - the run date which is used to generate a timestamp
directory - the directory where the file would be located
fileName - the given file name without file extension
extension - the given file extension
Returns:
a full file name built from the given information.
See Also:
org.kuali.kfs.sys.batch.service.ReportGenerationService#buildFullFileName(java.util.Date, java.lang.String, java.lang.String, java.lang.String)

getReportTemplateClassPathResource

protected org.springframework.core.io.ClassPathResource getReportTemplateClassPathResource(String reportTemplateName)
get a class path resource that references to the given report template

Parameters:
reportTemplateName - the given report template name with its full-qualified package name. It may not include extension. If an extension is included in the name, it should be prefixed ".jasper" or '.jrxml".
Returns:
a class path resource that references to the given report template

compileReportTemplate

protected void compileReportTemplate(String designTemplate,
                                     String jasperReport)
                              throws net.sf.jasperreports.engine.JRException
complie the report template xml file into a Jasper report file if the compiled file does not exist or is out of update

Parameters:
designTemplate - the full name of the report template xml file
jasperReport - the full name of the compiled report file
Throws:
net.sf.jasperreports.engine.JRException

compileSubReports

protected void compileSubReports(Map<String,String> subReports,
                                 String subReportDirectory)
                          throws Exception
compile the given sub reports

Parameters:
subReports - the sub report Map that hold the sub report templete names indexed with keys
subReportDirectory - the directory where sub report templates are located
Throws:
Exception

removeTemplateExtension

protected String removeTemplateExtension(org.springframework.core.io.ClassPathResource template)
                                  throws IOException
remove the file extension of the given template if any

Parameters:
template - the given template
Returns:
the template without file extension
Throws:
IOException

setDateTimeService

public void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
Sets the DateTimeService

Parameters:
dateTimeService - The dateTimeService to set.


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.