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

java.lang.Object
  extended by org.kuali.kfs.sys.service.impl.ReportWriterTextServiceImpl
All Implemented Interfaces:
WrappingBatchService, ReportWriterService
Direct Known Subclasses:
BalanceSummaryReportWriterTextServiceImpl, ScrubberListingReportWriterTextServiceImpl

public class ReportWriterTextServiceImpl
extends Object
implements ReportWriterService, WrappingBatchService

Text output implementation of ReportWriterService interface. If you are a developer attempting to add a new business object for error report writing, take a look at the Spring definitions for BusinessObjectReportHelper.
This class CANNOT be used by 2 processes simultaneously. It is for very specific batch processes that should not run at the same time, and initialize and destroy must be called and the beginning and end of each process that uses it.

See Also:
BusinessObjectReportHelper

Field Summary
protected  boolean aggregationModeOn
           
protected  Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass
           
protected  Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,BusinessObjectReportHelper> businessObjectReportHelpers
           
protected  Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,String> classToBusinessObjectReportHelperBeanNames
          A map of BO classes to BusinessObjectReportHelper bean names, to configure which BO's will be rendered by which BusinessObjectReportHelper.
protected  org.kuali.rice.kns.service.DateTimeService dateTimeService
           
protected  String errorFormat
           
protected  String errorSubTitle
           
protected  String fileNamePrefix
           
protected  String fileNameSuffix
           
protected  String filePath
           
protected static int INITIAL_LINE_NUMBER
           
protected  int initialPageNumber
           
protected  int line
           
protected  boolean modeParameters
           
protected  boolean modeStatistics
           
protected  String newLineCharacter
           
protected  boolean newPage
           
protected  int page
           
protected  String pageLabel
           
protected  int pageLength
           
protected  int pageWidth
           
protected  PrintStream printStream
           
protected  String statisticsLabel
           
protected  String statisticsLeftPadding
           
protected  String title
           
 
Constructor Summary
ReportWriterTextServiceImpl()
           
 
Method Summary
protected  boolean allFormattingEscaped(String format)
          Determines if all formatting on the given String is escaped - ie, that it has no formatting
 void destroy()
           
protected  Object[] escapeArguments(Object... args)
          Iterates through array and escapes special formatting characters
protected  String escapeFormatCharacters(String replacementString)
          Escapes characters in a string that have special meaning for formatting
protected  String generateFullFilePath()
           
 BusinessObjectReportHelper getBusinessObjectReportHelper(org.kuali.rice.kns.bo.BusinessObject businessObject)
          get the business report helper for the given business object
 BusinessObjectReportHelper getBusinessObjectReportHelper(Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass)
          get the business report helper for the given business object
 String[] getMultipleFormattedMessageLines(String format, Object... args)
          This method...
 String getParametersLabel()
          Gets the parametersLabel attribute.
 String getParametersLeftPadding()
          Gets the parametersLeftPadding attribute.
 void initialize()
           
protected  void initializeBusinessObjectReportHelpers()
           
 boolean isAggregationModeOn()
          Gets the aggregationModeOn attribute.
 void pageBreak()
          Breaking the page and write a new header
 void setAggregationModeOn(boolean aggregationModeOn)
          Sets the aggregationModeOn attribute value.
 void setClassToBusinessObjectReportHelperBeanNames(Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,String> classToBusinessObjectReportHelperBeanNames)
          Sets a map of BO classes to BusinessObjectReportHelper bean names, to configure which BO's will be rendered by which BusinessObjectReportHelper.
 void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
          Sets the DateTimeService
 void setErrorSubTitle(String errorSubTitle)
          Sets the errorSubTitle
 void setFileNamePrefix(String fileNamePrefix)
          Sets the fileNamePrefix
 void setFileNameSuffix(String fileNameSuffix)
          Sets the fileNameSuffix
 void setFilePath(String filePath)
          Sets the filePath
 void setInitialPageNumber(int initialPageNumber)
          Sets the initialPageNumber
 void setNewLineCharacter(String newLineCharacter)
          Sets the newLineCharacter
 void setPageLabel(String pageLabel)
          Sets the pageLabel
 void setPageLength(int pageLength)
          Sets the pageLength
 void setPageWidth(int pageWidth)
          Sets the pageWidth
 void setParametersLabel(String parametersLabel)
          Sets the parametersLabel attribute value.
 void setParametersLeftPadding(String parametersLeftPadding)
          Sets the parametersLeftPadding attribute value.
 void setStatisticsLabel(String statisticsLabel)
          Sets the statisticsLabel
 void setStatisticsLeftPadding(String statisticsLeftPadding)
          Sets the statisticsLeftPadding
 void setTitle(String title)
          Sets the title
 void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject, List<Message> messages)
          Same as writeError except that it provides for multiple messages for the BO.
 void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject, Message message)
          Writes an error message for the passed in business object.
 void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject, Message message, boolean printBusinessObjectValues)
           
protected  void writeErrorHeader(org.kuali.rice.kns.bo.BusinessObject businessObject)
          Helper method to write the error header
 void writeFormattedMessageLine(String format)
          Pass through to PrintStream.printf except that it also handles pagination.
 void writeFormattedMessageLine(String format, Object... args)
          Pass through to PrintStream.printf except that it also handles pagination.
protected  void writeHeader(String title)
          Helper method to write a header for placement at top of new page
 void writeMultipleFormattedMessageLines(String[] messageLines)
          write the given information as multiple lines if it contains more than one line breaks
protected  void writeMultipleFormattedMessageLines(String[] messageLines, String[] headerLinesInNewPage, boolean isRowBreakAcrossPageAllowed)
          write the given information as multiple lines if it contains more than one line breaks
 void writeMultipleFormattedMessageLines(String format, Object... args)
           
 void writeNewLines(int lines)
          Writes "lines" number of newlines to the report
 void writeParameterLine(String message, Object... args)
          Writes parameter usually placed at the end of the report.
 void writeStatisticLine(String message, Object... args)
          Writes statistics usually placed at the end of the report.
 void writeSubTitle(String message)
          Writes a centered message.
 void writeTable(List<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjects, boolean isHeaderRepeatedInNewPage, boolean isRowBreakAcrossPageAllowed)
          Write table into a report for the given list of business objects
 void writeTableHeader(org.kuali.rice.kns.bo.BusinessObject businessObject)
          Write table header into a report for the given business object
 void writeTableHeader(Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass)
          Writes out the table header, based on a business object class
 void writeTableRow(org.kuali.rice.kns.bo.BusinessObject businessObject)
          Write table row into a report for the given business object
 void writeTableRowSeparationLine(org.kuali.rice.kns.bo.BusinessObject businessObject)
          write a separation line in a table
 void writeTableRowWithColspan(org.kuali.rice.kns.bo.BusinessObject businessObject)
          Write table row into a report for the given business object and also take the colspan in account
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_LINE_NUMBER

protected static final int INITIAL_LINE_NUMBER
See Also:
Constant Field Values

filePath

protected String filePath

fileNamePrefix

protected String fileNamePrefix

fileNameSuffix

protected String fileNameSuffix

title

protected String title

pageWidth

protected int pageWidth

pageLength

protected int pageLength

initialPageNumber

protected int initialPageNumber

errorSubTitle

protected String errorSubTitle

statisticsLabel

protected String statisticsLabel

statisticsLeftPadding

protected String statisticsLeftPadding

pageLabel

protected String pageLabel

newLineCharacter

protected String newLineCharacter

dateTimeService

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

aggregationModeOn

protected boolean aggregationModeOn

classToBusinessObjectReportHelperBeanNames

protected Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,String> classToBusinessObjectReportHelperBeanNames
A map of BO classes to BusinessObjectReportHelper bean names, to configure which BO's will be rendered by which BusinessObjectReportHelper. This property should be configured via the spring bean definition


businessObjectReportHelpers

protected Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,BusinessObjectReportHelper> businessObjectReportHelpers

printStream

protected PrintStream printStream

page

protected int page

line

protected int line

errorFormat

protected String errorFormat

modeStatistics

protected boolean modeStatistics

modeParameters

protected boolean modeParameters

newPage

protected boolean newPage

businessObjectClass

protected Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass
Constructor Detail

ReportWriterTextServiceImpl

public ReportWriterTextServiceImpl()
Method Detail

initialize

public void initialize()
Specified by:
initialize in interface WrappingBatchService
See Also:
WrappingBatchService.initialize()

initializeBusinessObjectReportHelpers

protected void initializeBusinessObjectReportHelpers()

generateFullFilePath

protected String generateFullFilePath()

destroy

public void destroy()
Specified by:
destroy in interface WrappingBatchService
See Also:
WrappingBatchService.destroy()

writeSubTitle

public void writeSubTitle(String message)
Description copied from interface: ReportWriterService
Writes a centered message. The purpose of this is primarily to write custom subtitles necessary in some reports

Specified by:
writeSubTitle in interface ReportWriterService
Parameters:
message - to be written centered
See Also:
ReportWriterService.writeSubTitle(java.lang.String)

writeError

public void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject,
                       Message message)
Description copied from interface: ReportWriterService
Writes an error message for the passed in business object. If the business object is the first or different then the previous one a table header is printed per definition in the implementation of this service

Specified by:
writeError in interface ReportWriterService
Parameters:
businessObject - controlling the table header and values to be printed
message - associated with the businessObject
See Also:
org.kuali.kfs.sys.service.ReportWriterService#writeError(java.lang.Class, org.kuali.kfs.sys.Message)

writeError

public void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject,
                       Message message,
                       boolean printBusinessObjectValues)
Parameters:
printBusinessObjectValues - indicates whether the bo values should be printed before the message
See Also:
org.kuali.kfs.sys.service.ReportWriterService#writeError(java.lang.Class, org.kuali.kfs.sys.Message)

writeError

public void writeError(org.kuali.rice.kns.bo.BusinessObject businessObject,
                       List<Message> messages)
Description copied from interface: ReportWriterService
Same as writeError except that it provides for multiple messages for the BO. BO values are only printed once and then messages each row below that.

Specified by:
writeError in interface ReportWriterService
Parameters:
businessObject - controlling the table header and values to be printed
messages - associated with the businessObject
See Also:
org.kuali.kfs.sys.service.ReportWriterService#writeError(java.lang.Class, java.util.List)

writeNewLines

public void writeNewLines(int lines)
Description copied from interface: ReportWriterService
Writes "lines" number of newlines to the report

Specified by:
writeNewLines in interface ReportWriterService
Parameters:
lines - number of newlines to write to the report
See Also:
ReportWriterService.writeNewLines(int)

writeStatisticLine

public void writeStatisticLine(String message,
                               Object... args)
Description copied from interface: ReportWriterService
Writes statistics usually placed at the end of the report. If this is the first time this method is called then a statistics header is written. All messages are indented per STATISTICS_LEFT_PADDING. If multiple lines are needed, call this method multiple times to assure pagination works properly

Specified by:
writeStatisticLine in interface ReportWriterService
Parameters:
message - to write
args - for the message per standard String.format
See Also:
ReportWriterService.writeStatisticLine(java.lang.String, java.lang.Object[])

writeParameterLine

public void writeParameterLine(String message,
                               Object... args)
Description copied from interface: ReportWriterService
Writes parameter usually placed at the end of the report. If this is the first time this method is called then a parameter header is written. All messages are indented per PARAMETERS_LEFT_PADDING. If multiple lines are needed, call this method multiple times to assure pagination works properly

Specified by:
writeParameterLine in interface ReportWriterService
Parameters:
message - to write
args - for the message per standard String.format
See Also:
ReportWriterService.writeParameterLine(java.lang.String, java.lang.Object[])

writeFormattedMessageLine

public void writeFormattedMessageLine(String format)
Description copied from interface: ReportWriterService
Pass through to PrintStream.printf except that it also handles pagination. If multiple lines are needed, call this method multiple times to assure pagination works properly

Specified by:
writeFormattedMessageLine in interface ReportWriterService
See Also:
ReportWriterService.writeFormattedMessageLine(java.lang.String)

writeFormattedMessageLine

public void writeFormattedMessageLine(String format,
                                      Object... args)
Description copied from interface: ReportWriterService
Pass through to PrintStream.printf except that it also handles pagination. If multiple lines are needed, call this method multiple times to assure pagination works properly

Specified by:
writeFormattedMessageLine in interface ReportWriterService
See Also:
ReportWriterService.writeFormattedMessageLine(java.lang.String, java.lang.Object[])

allFormattingEscaped

protected boolean allFormattingEscaped(String format)
Determines if all formatting on the given String is escaped - ie, that it has no formatting

Parameters:
format - the format to test
Returns:
true if the String is without formatting, false otherwise

pageBreak

public void pageBreak()
Description copied from interface: ReportWriterService
Breaking the page and write a new header

Specified by:
pageBreak in interface ReportWriterService
See Also:
ReportWriterService.pageBreak()

writeHeader

protected void writeHeader(String title)
Helper method to write a header for placement at top of new page

Parameters:
title - that should be printed on this header

writeErrorHeader

protected void writeErrorHeader(org.kuali.rice.kns.bo.BusinessObject businessObject)
Helper method to write the error header

Parameters:
businessObject - to print header for

writeTableHeader

public void writeTableHeader(org.kuali.rice.kns.bo.BusinessObject businessObject)
Description copied from interface: ReportWriterService
Write table header into a report for the given business object

Specified by:
writeTableHeader in interface ReportWriterService
Parameters:
businessObject - the given business object
See Also:
ReportWriterService.writeTableHeader(org.kuali.rice.kns.bo.BusinessObject)

writeTableHeader

public void writeTableHeader(Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass)
Writes out the table header, based on a business object class

Specified by:
writeTableHeader in interface ReportWriterService
Parameters:
businessObjectClass - the class to write the header out for

writeTableRowSeparationLine

public void writeTableRowSeparationLine(org.kuali.rice.kns.bo.BusinessObject businessObject)
Description copied from interface: ReportWriterService
write a separation line in a table

Specified by:
writeTableRowSeparationLine in interface ReportWriterService
Parameters:
businessObject - the given business object
See Also:
ReportWriterService.writeTableRow(org.kuali.rice.kns.bo.BusinessObject)

writeTableRow

public void writeTableRow(org.kuali.rice.kns.bo.BusinessObject businessObject)
Description copied from interface: ReportWriterService
Write table row into a report for the given business object

Specified by:
writeTableRow in interface ReportWriterService
Parameters:
businessObject - the given business object
See Also:
ReportWriterService.writeTableRow(org.kuali.rice.kns.bo.BusinessObject)

writeTableRowWithColspan

public void writeTableRowWithColspan(org.kuali.rice.kns.bo.BusinessObject businessObject)
Description copied from interface: ReportWriterService
Write table row into a report for the given business object and also take the colspan in account

Specified by:
writeTableRowWithColspan in interface ReportWriterService
Parameters:
businessObject - the given business object
See Also:
ReportWriterService.writeTableRowWithColspan(org.kuali.rice.kns.bo.BusinessObject)

writeTable

public void writeTable(List<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjects,
                       boolean isHeaderRepeatedInNewPage,
                       boolean isRowBreakAcrossPageAllowed)
Description copied from interface: ReportWriterService
Write table into a report for the given list of business objects

Specified by:
writeTable in interface ReportWriterService
Parameters:
businessObjects - the given business objects
isHeaderRepeatedInNewPage - instruct if the header row needs to be repeated in a new page
isRowBreakAcrossPageAllowed - determine whether a row can be broken across pages
See Also:
ReportWriterService.writeTable(java.util.List, boolean, boolean)

getBusinessObjectReportHelper

public BusinessObjectReportHelper getBusinessObjectReportHelper(org.kuali.rice.kns.bo.BusinessObject businessObject)
get the business report helper for the given business object

Parameters:
businessObject - the given business object
Returns:
the business report helper for the given business object

getBusinessObjectReportHelper

public BusinessObjectReportHelper getBusinessObjectReportHelper(Class<? extends org.kuali.rice.kns.bo.BusinessObject> businessObjectClass)
get the business report helper for the given business object

Parameters:
businessObject - the given business object
Returns:
the business report helper for the given business object

writeMultipleFormattedMessageLines

protected void writeMultipleFormattedMessageLines(String[] messageLines,
                                                  String[] headerLinesInNewPage,
                                                  boolean isRowBreakAcrossPageAllowed)
write the given information as multiple lines if it contains more than one line breaks

Parameters:
format - the given text format definition
messageLines - the given information being written out
headerLinesInNewPage - the given header lines being written in the begin of a new page

writeMultipleFormattedMessageLines

public void writeMultipleFormattedMessageLines(String[] messageLines)
write the given information as multiple lines if it contains more than one line breaks

Parameters:
format - the given text format definition
args - the given information being written out

writeMultipleFormattedMessageLines

public void writeMultipleFormattedMessageLines(String format,
                                               Object... args)
Specified by:
writeMultipleFormattedMessageLines in interface ReportWriterService

getMultipleFormattedMessageLines

public String[] getMultipleFormattedMessageLines(String format,
                                                 Object... args)
This method...

Parameters:
format -
args -
Returns:

escapeArguments

protected Object[] escapeArguments(Object... args)
Iterates through array and escapes special formatting characters

Parameters:
args - Object array to process
Returns:
Object array with String members escaped

escapeFormatCharacters

protected String escapeFormatCharacters(String replacementString)
Escapes characters in a string that have special meaning for formatting

Parameters:
replacementString - string to escape
Returns:
string with format characters escaped
See Also:
KFSConstants.ReportConstants.FORMAT_ESCAPE_CHARACTERS

setFilePath

public void setFilePath(String filePath)
Sets the filePath

Parameters:
filePath - The filePath to set.

setFileNamePrefix

public void setFileNamePrefix(String fileNamePrefix)
Sets the fileNamePrefix

Parameters:
fileNamePrefix - The fileNamePrefix to set.

setFileNameSuffix

public void setFileNameSuffix(String fileNameSuffix)
Sets the fileNameSuffix

Parameters:
fileNameSuffix - The fileNameSuffix to set.

setTitle

public void setTitle(String title)
Sets the title

Parameters:
title - The title to set.

setPageWidth

public void setPageWidth(int pageWidth)
Sets the pageWidth

Parameters:
pageWidth - The pageWidth to set.

setPageLength

public void setPageLength(int pageLength)
Sets the pageLength

Parameters:
pageLength - The pageLength to set.

setInitialPageNumber

public void setInitialPageNumber(int initialPageNumber)
Sets the initialPageNumber

Parameters:
initialPageNumber - The initialPageNumber to set.

setErrorSubTitle

public void setErrorSubTitle(String errorSubTitle)
Sets the errorSubTitle

Parameters:
errorSubTitle - The errorSubTitle to set.

setStatisticsLabel

public void setStatisticsLabel(String statisticsLabel)
Sets the statisticsLabel

Parameters:
statisticsLabel - The statisticsLabel to set.

setStatisticsLeftPadding

public void setStatisticsLeftPadding(String statisticsLeftPadding)
Sets the statisticsLeftPadding

Parameters:
statisticsLeftPadding - The statisticsLeftPadding to set.

setPageLabel

public void setPageLabel(String pageLabel)
Sets the pageLabel

Parameters:
pageLabel - The pageLabel to set.

setNewLineCharacter

public void setNewLineCharacter(String newLineCharacter)
Sets the newLineCharacter

Parameters:
newLineCharacter - The newLineCharacter to set.

setDateTimeService

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

Parameters:
dateTimeService - The DateTimeService to set.

setClassToBusinessObjectReportHelperBeanNames

public void setClassToBusinessObjectReportHelperBeanNames(Map<Class<? extends org.kuali.rice.kns.bo.BusinessObject>,String> classToBusinessObjectReportHelperBeanNames)
Sets a map of BO classes to BusinessObjectReportHelper bean names, to configure which BO's will be rendered by which BusinessObjectReportHelper. This property should be configured via the spring bean definition

Parameters:
classToBusinessObjectReportHelperBeanNames - The classToBusinessObjectReportHelperBeanNames to set.

getParametersLabel

public String getParametersLabel()
Gets the parametersLabel attribute.

Returns:
Returns the parametersLabel.

setParametersLabel

public void setParametersLabel(String parametersLabel)
Sets the parametersLabel attribute value.

Parameters:
parametersLabel - The parametersLabel to set.

getParametersLeftPadding

public String getParametersLeftPadding()
Gets the parametersLeftPadding attribute.

Returns:
Returns the parametersLeftPadding.

setParametersLeftPadding

public void setParametersLeftPadding(String parametersLeftPadding)
Sets the parametersLeftPadding attribute value.

Parameters:
parametersLeftPadding - The parametersLeftPadding to set.

isAggregationModeOn

public boolean isAggregationModeOn()
Gets the aggregationModeOn attribute.

Returns:
Returns the aggregationModeOn.

setAggregationModeOn

public void setAggregationModeOn(boolean aggregationModeOn)
Sets the aggregationModeOn attribute value.

Parameters:
aggregationModeOn - The aggregationModeOn to set.


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