001: /*
002: * Copyright (C) 2002 Erik Swenson - erik@oreports.com
003: *
004: * This program is free software; you can redistribute it and/or modify it
005: * under the terms of the GNU General Public License as published by the Free
006: * Software Foundation; either version 2 of the License, or (at your option)
007: * any later version.
008: *
009: * This program is distributed in the hope that it will be useful, but WITHOUT
010: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
012: * more details.
013: *
014: * You should have received a copy of the GNU General Public License along with
015: * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
016: * Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: */
019:
020: package org.efs.openreports.objects;
021:
022: import java.io.Serializable;
023: import java.util.*;
024:
025: public class Report implements Comparable<Report>, Serializable {
026: private static final long serialVersionUID = 4068258161793785996l;
027:
028: private Integer id;
029:
030: private String name;
031:
032: private String description;
033:
034: private String file;
035:
036: private String query;
037:
038: private ReportDataSource dataSource;
039:
040: private ReportChart reportChart;
041:
042: private List<ReportParameterMap> parameters;
043:
044: private boolean pdfExportEnabled;
045:
046: private boolean htmlExportEnabled;
047:
048: private boolean csvExportEnabled;
049:
050: private boolean xlsExportEnabled;
051:
052: private boolean rtfExportEnabled;
053:
054: private boolean textExportEnabled;
055:
056: private boolean excelExportEnabled;
057:
058: private boolean imageExportEnabled;
059:
060: private boolean virtualizationEnabled;
061:
062: private boolean hidden;
063:
064: private ReportExportOption reportExportOption;
065:
066: private transient boolean displayInline;
067:
068: public Report() {
069: }
070:
071: public boolean isBirtReport() {
072: if (file != null && file.endsWith("rptdesign"))
073: return true;
074:
075: return false;
076: }
077:
078: public boolean isJasperReport() {
079: if (file != null && file.endsWith("jasper"))
080: return true;
081:
082: return false;
083: }
084:
085: public boolean isQueryReport() {
086: if (query != null && query.length() > 0
087: && !file.endsWith("xls") && !file.endsWith("xml")
088: && !file.endsWith("vm")) {
089: return true;
090: }
091:
092: return false;
093: }
094:
095: public boolean isChartReport() {
096: if ((query == null || query.trim().length() < 1)
097: && (file == null || file.equals("-1"))
098: && reportChart != null) {
099: return true;
100: }
101:
102: return false;
103: }
104:
105: public boolean isJFreeReport() {
106: if (query != null && query.length() > 0 && file != null
107: && file.endsWith("xml") && !isJPivotReport()) {
108: return true;
109: }
110:
111: return false;
112: }
113:
114: public boolean isJXLSReport() {
115: if (file != null && file.endsWith("xls")) {
116: return true;
117: }
118:
119: return false;
120: }
121:
122: public boolean isJPivotReport() {
123: if (file != null && file.equalsIgnoreCase("datasources.xml"))
124: return true;
125:
126: return false;
127: }
128:
129: public boolean isVelocityReport() {
130: if (file != null && file.endsWith("vm"))
131: return true;
132:
133: return false;
134: }
135:
136: public void setId(Integer id) {
137: this .id = id;
138: }
139:
140: @Override
141: public String toString() {
142: return name;
143: }
144:
145: public String getDescription() {
146: return description;
147: }
148:
149: public String getFile() {
150: return file;
151: }
152:
153: public Integer getId() {
154: return id;
155: }
156:
157: public String getName() {
158: return name;
159: }
160:
161: public void setDescription(String description) {
162: this .description = description;
163: }
164:
165: public void setFile(String file) {
166: this .file = file;
167: }
168:
169: public void setName(String name) {
170: this .name = name;
171: }
172:
173: public List<ReportParameterMap> getParameters() {
174: return parameters;
175: }
176:
177: public List<ReportParameterMap> getSubReportParameters() {
178: ArrayList<ReportParameterMap> subReportParameters = new ArrayList<ReportParameterMap>();
179:
180: if (parameters != null) {
181: Iterator<ReportParameterMap> iterator = parameters
182: .iterator();
183: while (iterator.hasNext()) {
184: ReportParameterMap rpMap = iterator.next();
185:
186: if (rpMap.getReportParameter().getType().equals(
187: ReportParameter.SUBREPORT_PARAM)) {
188: subReportParameters.add(rpMap);
189: }
190: }
191: }
192:
193: return subReportParameters;
194: }
195:
196: public void setParameters(List<ReportParameterMap> parameters) {
197: this .parameters = parameters;
198: }
199:
200: public ReportParameterMap getReportParameterMap(Integer parameterId) {
201: Iterator<ReportParameterMap> iterator = parameters.iterator();
202: while (iterator.hasNext()) {
203: ReportParameterMap rpMap = iterator.next();
204:
205: if (rpMap.getReportParameter().getId().equals(parameterId)) {
206: return rpMap;
207: }
208: }
209:
210: return null;
211: }
212:
213: public List<ReportParameterMap> getReportParametersByStep(int step) {
214: List<ReportParameterMap> list = new ArrayList<ReportParameterMap>();
215:
216: Iterator<ReportParameterMap> iterator = parameters.iterator();
217: while (iterator.hasNext()) {
218: ReportParameterMap rpMap = iterator.next();
219:
220: if (rpMap.getStep() == step) {
221: list.add(rpMap);
222: }
223: }
224:
225: Collections.sort(list);
226:
227: return list;
228: }
229:
230: public ReportDataSource getDataSource() {
231: return dataSource;
232: }
233:
234: public void setDataSource(ReportDataSource dataSource) {
235: this .dataSource = dataSource;
236: }
237:
238: public int compareTo(Report report) {
239: return name.compareTo(report.getName());
240: }
241:
242: public ReportChart getReportChart() {
243: return reportChart;
244: }
245:
246: public void setReportChart(ReportChart reportChart) {
247: this .reportChart = reportChart;
248: }
249:
250: public boolean isCsvExportEnabled() {
251: return csvExportEnabled;
252: }
253:
254: public void setCsvExportEnabled(boolean csvExportEnabled) {
255: this .csvExportEnabled = csvExportEnabled;
256: }
257:
258: public boolean isHtmlExportEnabled() {
259: return htmlExportEnabled;
260: }
261:
262: public void setHtmlExportEnabled(boolean htmlExportEnabled) {
263: this .htmlExportEnabled = htmlExportEnabled;
264: }
265:
266: public boolean isPdfExportEnabled() {
267: return pdfExportEnabled;
268: }
269:
270: public void setPdfExportEnabled(boolean pdfExportEnabled) {
271: this .pdfExportEnabled = pdfExportEnabled;
272: }
273:
274: public boolean isXlsExportEnabled() {
275: return xlsExportEnabled;
276: }
277:
278: public void setXlsExportEnabled(boolean xlsExportEnabled) {
279: this .xlsExportEnabled = xlsExportEnabled;
280: }
281:
282: public String getQuery() {
283: return query;
284: }
285:
286: public void setQuery(String query) {
287: this .query = query;
288: }
289:
290: public boolean isExcelExportEnabled() {
291: return excelExportEnabled;
292: }
293:
294: public void setExcelExportEnabled(Boolean excelExportEnabled) {
295: if (excelExportEnabled == null)
296: excelExportEnabled = new Boolean(false);
297: this .excelExportEnabled = excelExportEnabled.booleanValue();
298: }
299:
300: public boolean isRtfExportEnabled() {
301: return rtfExportEnabled;
302: }
303:
304: public void setRtfExportEnabled(Boolean rtfExportEnabled) {
305: if (rtfExportEnabled == null)
306: rtfExportEnabled = new Boolean(false);
307: this .rtfExportEnabled = rtfExportEnabled.booleanValue();
308: }
309:
310: public boolean isTextExportEnabled() {
311: return textExportEnabled;
312: }
313:
314: public void setTextExportEnabled(Boolean textExportEnabled) {
315: if (textExportEnabled == null)
316: textExportEnabled = new Boolean(false);
317: this .textExportEnabled = textExportEnabled.booleanValue();
318: }
319:
320: public boolean isImageExportEnabled() {
321: return imageExportEnabled;
322: }
323:
324: public void setImageExportEnabled(Boolean imageExportEnabled) {
325: if (imageExportEnabled == null)
326: imageExportEnabled = new Boolean(false);
327: this .imageExportEnabled = imageExportEnabled.booleanValue();
328: }
329:
330: public ReportExportOption getReportExportOption() {
331: if (reportExportOption == null)
332: reportExportOption = new ReportExportOption();
333: return reportExportOption;
334: }
335:
336: public void setReportExportOption(
337: ReportExportOption reportExportOption) {
338: this .reportExportOption = reportExportOption;
339: }
340:
341: public boolean isVirtualizationEnabled() {
342: return virtualizationEnabled;
343: }
344:
345: public void setVirtualizationEnabled(Boolean virtualizationEnabled) {
346: if (virtualizationEnabled == null)
347: virtualizationEnabled = new Boolean(false);
348: this .virtualizationEnabled = virtualizationEnabled
349: .booleanValue();
350: }
351:
352: public boolean isHidden() {
353: return hidden;
354: }
355:
356: public void setHidden(Boolean hidden) {
357: if (hidden == null)
358: hidden = new Boolean(false);
359: this .hidden = hidden.booleanValue();
360: }
361:
362: public boolean isDisplayInline() {
363: return displayInline;
364: }
365:
366: public void setDisplayInline(boolean displayInline) {
367: this.displayInline = displayInline;
368: }
369:
370: }
|