001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.service; 017 018 import java.util.List; 019 import java.util.Map; 020 021 import org.kuali.kfs.sys.KFSConstants; 022 import org.kuali.kfs.sys.Message; 023 import org.kuali.kfs.sys.report.BusinessObjectReportHelper; 024 import org.kuali.rice.kns.bo.BusinessObject; 025 026 /** 027 * Service interface defines methods that are relevant to writing a report 028 */ 029 public interface ReportWriterService { 030 /** 031 * Writes a centered message. The purpose of this is primarily to write custom subtitles necessary in some reports 032 * @param message to be written centered 033 */ 034 public void writeSubTitle(String message); 035 036 /** 037 * Writes an error message for the passed in business object. If the business object is the first or different then the 038 * previous one a table header is printed per definition in the implementation of this service 039 * @param businessObject controlling the table header and values to be printed 040 * @param message associated with the businessObject 041 */ 042 public void writeError(BusinessObject businessObject, Message message); 043 044 /** 045 * Same as writeError except that it provides for multiple messages for the BO. BO values are only printed once and then messages each 046 * row below that. 047 * @param businessObject controlling the table header and values to be printed 048 * @param messages associated with the businessObject 049 */ 050 public void writeError(BusinessObject businessObject, List<Message> messages); 051 052 /** 053 * Writes statistics usually placed at the end of the report. If this is the first time this method is called then a statistics header 054 * is written. All messages are indented per STATISTICS_LEFT_PADDING. If multiple lines are needed, call this method multiple times to 055 * assure pagination works properly 056 * @param message to write 057 * @param args for the message per standard String.format 058 */ 059 public void writeStatisticLine(String message, Object ... args); 060 061 /** 062 * Writes parameter usually placed at the end of the report. If this is the first time this method is called then a parameter header 063 * is written. All messages are indented per PARAMETERS_LEFT_PADDING. If multiple lines are needed, call this method multiple times to 064 * assure pagination works properly 065 * @param message to write 066 * @param args for the message per standard String.format 067 */ 068 public abstract void writeParameterLine(String message, Object ... args); 069 070 /** 071 * Writes "lines" number of newlines to the report 072 * @param lines number of newlines to write to the report 073 */ 074 public void writeNewLines(int lines); 075 076 /** 077 * Pass through to PrintStream.printf except that it also handles pagination. If multiple lines are needed, call this method multiple 078 * times to assure pagination works properly 079 * @param format 080 */ 081 public void writeFormattedMessageLine(String format); 082 083 /** 084 * Pass through to PrintStream.printf except that it also handles pagination. If multiple lines are needed, call this method multiple 085 * times to assure pagination works properly 086 * @param format 087 * @param args 088 */ 089 public void writeFormattedMessageLine(String format, Object ... args); 090 091 public void writeMultipleFormattedMessageLines(String format, Object... args); 092 093 /** 094 * Write table header into a report for the given business object 095 * @param businessObject the given business object 096 */ 097 public void writeTableHeader(BusinessObject businessObject); 098 099 /** 100 * Write table header into a report for business objects of the given class 101 * @param businessObjectClass the given class of a business object 102 */ 103 public abstract void writeTableHeader(Class<? extends BusinessObject> businessObjectClass); 104 105 /** 106 * Write table row into a report for the given business object 107 * @param businessObject the given business object 108 */ 109 public void writeTableRow(BusinessObject businessObject); 110 111 /** 112 * Write table into a report for the given list of business objects 113 * @param businessObjects the given business objects 114 * @param isHeaderRepeatedInNewPage instruct if the header row needs to be repeated in a new page 115 * @param isRowBreakAcrossPageAllowed determine whether a row can be broken across pages 116 */ 117 public void writeTable(List<? extends BusinessObject> businessObjects, boolean isHeaderRepeatedInNewPage, boolean isRowBreakAcrossPageAllowed); 118 119 /** 120 * Breaking the page and write a new header 121 */ 122 public void pageBreak(); 123 124 /** 125 * Write table row into a report for the given business object and also take the colspan in account 126 * @param businessObject the given business object 127 */ 128 public void writeTableRowWithColspan(BusinessObject businessObject); 129 130 /** 131 * write a separation line in a table 132 * @param businessObject the given business object 133 */ 134 public void writeTableRowSeparationLine(BusinessObject businessObject); 135 }