KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > web > reports > AbstractITrackerReport


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.web.reports;
20
21 import java.io.*;
22 import java.net.*;
23 import java.util.*;
24 import javax.servlet.ServletOutputStream JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.http.HttpServletResponse JavaDoc;
27 import javax.servlet.http.HttpSession JavaDoc;
28
29 import org.apache.struts.action.ActionMapping;
30 import org.apache.struts.util.RequestUtils;
31
32 import cowsultants.itracker.ejb.client.exceptions.*;
33 import cowsultants.itracker.ejb.client.models.*;
34 import cowsultants.itracker.ejb.client.resources.*;
35 import cowsultants.itracker.ejb.client.util.*;
36
37 /**
38   * This class encapsulates a basic ITracker report. Only the initialize method has been
39   * implemented in this class, and it only provides some basic access to provided input
40   * data.
41   */

42 public abstract class AbstractITrackerReport implements ITrackerReport {
43     protected IssueModel[] issues = null;
44     protected ReportModel report = null;
45     protected Locale locale = null;
46     protected String JavaDoc reportOutput = null;
47     protected HttpSession JavaDoc session = null;
48
49     public AbstractITrackerReport() {
50     }
51
52     /**
53       * Initializes the ITrackerReport. This implementation only takes the input data and stores
54       * it for later use.
55       */

56     public void initializeReport(IssueModel[] issues, ReportModel report, Locale locale, String JavaDoc reportOutput, HttpSession JavaDoc session) throws ReportException {
57         storeInputs(issues, report, locale, reportOutput, session);
58     }
59
60     /**
61       * This method must be overriden by subclasses to perform any customization that can only
62       * be performed through the API. This method should be called after initializeReport.
63       */

64     public abstract void augmentReport() throws ReportException;
65
66     /**
67       * Outputs the report as PDF. It can be assumed that the initializeReport and augementReport have
68       * already been called prior to this method.
69       * @param request the HttpServletRequest for the report request
70       * @param response the HttpServletResponse to send the report output
71       * @param mapping the ActionMapping for the display report action
72       * @exception ReportException thrown if there is an error outputing the report as PDF
73       */

74     public abstract void outputPDF(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, ActionMapping mapping) throws ReportException;
75
76     /**
77       * Outputs the report as HTML. It can be assumed that the initializeReport and augementReport have
78       * already been called prior to this method.
79       * @param request the HttpServletRequest for the report request
80       * @param response the HttpServletResponse to send the report output
81       * @param mapping the ActionMapping for the display report action
82       * @exception ReportException thrown if there is an error outputing the report as HTML
83       */

84     public abstract void outputHTML(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, ActionMapping mapping) throws ReportException;
85
86     /**
87       * Outputs the report as an Excel spreadsheet (XLS). It can be assumed that the initializeReport and augementReport have
88       * already been called prior to this method.
89       * @param request the HttpServletRequest for the report request
90       * @param response the HttpServletResponse to send the report output
91       * @param mapping the ActionMapping for the display report action
92       * @exception ReportException thrown if there is an error outputing the report as XLS
93       */

94     public abstract void outputXLS(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, ActionMapping mapping) throws ReportException;
95
96     /**
97       * Outputs the report as CSV. It can be assumed that the initializeReport and augementReport have
98       * already been called prior to this method.
99       * @param request the HttpServletRequest for the report request
100       * @param response the HttpServletResponse to send the report output
101       * @param mapping the ActionMapping for the display report action
102       * @exception ReportException thrown if there is an error outputing the report as CSV
103       */

104     public abstract void outputCSV(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, ActionMapping mapping) throws ReportException;
105
106     /**
107       * Returns the current report object. The class of the report depends on underlying framework
108       * the report is based upon.
109       * @exception ReportException thrown if the report has not been properly initialized
110       */

111     public abstract Object JavaDoc getReport() throws ReportException;
112
113     protected void storeInputs(IssueModel[] issues, ReportModel report, Locale locale, String JavaDoc reportOutput, HttpSession JavaDoc session) {
114         this.issues = issues;
115         this.report = report;
116         this.locale = locale;
117         this.reportOutput = reportOutput;
118         this.session = session;
119     }
120 }
121
Popular Tags