01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.labor.report;
17:
18: import java.util.Date;
19: import java.util.List;
20:
21: import org.kuali.module.gl.util.AbstractPdfReportGenerator;
22:
23: import com.lowagie.text.Element;
24: import com.lowagie.text.Phrase;
25: import com.lowagie.text.Rectangle;
26: import com.lowagie.text.pdf.PdfPCell;
27: import com.lowagie.text.pdf.PdfPTable;
28:
29: /**
30: * This class can generate PDF report with the given transaction summary
31: */
32: public class TransactionSummaryReport extends
33: AbstractPdfReportGenerator {
34: private Element reportContents;
35:
36: /**
37: * generate the PDF report according to the given report information
38: *
39: * @param reportSummary the given report contents
40: * @param reportingDate the given reporting data
41: * @param reportTitle the given report title
42: * @param reportFilename the given report file name
43: * @param reportsDirectory the given dirctory where the generated report will be stored
44: */
45: public void generateReport(List<String> reportSummary,
46: Date reportingDate, String reportTitle,
47: String reportFilename, String reportsDirectory) {
48: setReportContents(reportSummary);
49: String filename = this .generateReportFileName(reportFilename,
50: reportsDirectory, reportingDate);
51: this .generatePdfReport(reportingDate, reportTitle, filename);
52: }
53:
54: /**
55: * @see org.kuali.module.gl.util.AbstractPdfReportGenerator#getReportContents()
56: */
57: @Override
58: public Element getReportContents() {
59: return this .reportContents;
60: }
61:
62: /**
63: * setup the report contents with the given information
64: *
65: * @param reportSummary the given report contents
66: */
67: public void setReportContents(List<String> reportSummary) {
68: reportContents = this .buildSummaryTable(reportSummary);
69: }
70:
71: // construct the summary table
72: private PdfPTable buildSummaryTable(List<String> reportSummary) {
73:
74: float[] cellWidths = { 100 };
75: PdfPTable summaryTable = new PdfPTable(cellWidths);
76: summaryTable.setWidthPercentage(60);
77:
78: PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S",
79: this .getHeaderFont()));
80: cell.setColspan(1);
81: cell.setBorder(Rectangle.NO_BORDER);
82: cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
83: summaryTable.addCell(cell);
84:
85: for (String itemline : reportSummary) {
86: cell = new PdfPCell(
87: new Phrase(itemline, this.getTextFont()));
88: cell.setBorder(Rectangle.NO_BORDER);
89: summaryTable.addCell(cell);
90: }
91: return summaryTable;
92: }
93: }
|