KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > efs > openreports > objects > Report


1 /*
2  * Copyright (C) 2002 Erik Swenson - erik@oreports.com
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */

19
20 package org.efs.openreports.objects;
21
22 import java.io.Serializable JavaDoc;
23 import java.util.*;
24
25 public class Report implements Comparable JavaDoc, Serializable JavaDoc
26 {
27     private static final long serialVersionUID = 4068258161793785996l;
28
29     private Integer JavaDoc id;
30
31     private String JavaDoc name;
32
33     private String JavaDoc description;
34
35     private String JavaDoc file;
36
37     private String JavaDoc query;
38
39     private ReportDataSource dataSource;
40
41     private ReportChart reportChart;
42
43     private List parameters;
44
45     private boolean pdfExportEnabled;
46
47     private boolean htmlExportEnabled;
48
49     private boolean csvExportEnabled;
50
51     private boolean xlsExportEnabled;
52
53     private boolean rtfExportEnabled;
54
55     private boolean textExportEnabled;
56
57     private boolean excelExportEnabled;
58     
59     private boolean virtualizationEnabled;
60     
61     private boolean hidden;
62
63     private ReportExportOption reportExportOption;
64     
65     private transient boolean displayInline;
66
67     public Report()
68     {
69     }
70
71     public boolean isBirtReport()
72     {
73         if (file != null && file.endsWith("rptdesign")) return true;
74         
75         return false;
76     }
77
78     public boolean isJasperReport()
79     {
80         if (file != null && file.endsWith("jasper")) return true;
81         
82         return false;
83     }
84     
85     public boolean isQueryReport()
86     {
87         if (query != null && query.length() > 0 && !file.endsWith("xls") && !file.endsWith("xml"))
88         {
89             return true;
90         }
91
92         return false;
93     }
94
95     public boolean isChartReport()
96     {
97         if ((query == null || query.trim().length() < 1)
98                 && (file == null || file.equals("-1")) && reportChart != null)
99         {
100             return true;
101         }
102
103         return false;
104     }
105     
106     public boolean isJFreeReport()
107     {
108         if (query != null && query.length() > 0 && file != null && file.endsWith("xml"))
109         {
110             return true;
111         }
112
113         return false;
114     }
115     
116     public boolean isJXLSReport()
117     {
118         if (file != null && file.endsWith("xls"))
119         {
120             return true;
121         }
122
123         return false;
124     }
125
126     public void setId(Integer JavaDoc id)
127     {
128         this.id = id;
129     }
130
131     public String JavaDoc toString()
132     {
133         return name;
134     }
135
136     public String JavaDoc getDescription()
137     {
138         return description;
139     }
140
141     public String JavaDoc getFile()
142     {
143         return file;
144     }
145
146     public Integer JavaDoc getId()
147     {
148         return id;
149     }
150
151     public String JavaDoc getName()
152     {
153         return name;
154     }
155
156     public void setDescription(String JavaDoc description)
157     {
158         this.description = description;
159     }
160
161     public void setFile(String JavaDoc file)
162     {
163         this.file = file;
164     }
165
166     public void setName(String JavaDoc name)
167     {
168         this.name = name;
169     }
170
171     public List getParameters()
172     {
173         return parameters;
174     }
175
176     public List getSubReportParameters()
177     {
178         ArrayList subReportParameters = new ArrayList();
179
180         if (parameters != null)
181         {
182             Iterator iterator = parameters.iterator();
183             while (iterator.hasNext())
184             {
185                 ReportParameterMap rpMap = (ReportParameterMap) iterator.next();
186
187                 if (rpMap.getReportParameter().getType().equals(
188                         ReportParameter.SUBREPORT_PARAM))
189                 {
190                     subReportParameters.add(rpMap);
191                 }
192             }
193         }
194
195         return subReportParameters;
196     }
197
198     public void setParameters(List parameters)
199     {
200         this.parameters = parameters;
201     }
202
203     public ReportParameterMap getReportParameterMap(Integer JavaDoc parameterId)
204     {
205         Iterator iterator = parameters.iterator();
206         while (iterator.hasNext())
207         {
208             ReportParameterMap rpMap = (ReportParameterMap) iterator.next();
209
210             if (rpMap.getReportParameter().getId().equals(parameterId))
211             {
212                 return rpMap;
213             }
214         }
215
216         return null;
217     }
218
219     public List getReportParametersByStep(int step)
220     {
221         List list = new ArrayList();
222
223         Iterator iterator = parameters.iterator();
224         while (iterator.hasNext())
225         {
226             ReportParameterMap rpMap = (ReportParameterMap) iterator.next();
227
228             if (rpMap.getStep() == step)
229             {
230                 list.add(rpMap);
231             }
232         }
233
234         Collections.sort(list);
235
236         return list;
237     }
238
239     public ReportDataSource getDataSource()
240     {
241         return dataSource;
242     }
243
244     public void setDataSource(ReportDataSource dataSource)
245     {
246         this.dataSource = dataSource;
247     }
248
249     public int compareTo(Object JavaDoc object)
250     {
251         Report report = (Report) object;
252         return name.compareTo(report.getName());
253     }
254
255     public ReportChart getReportChart()
256     {
257         return reportChart;
258     }
259
260     public void setReportChart(ReportChart reportChart)
261     {
262         this.reportChart = reportChart;
263     }
264
265     public boolean isCsvExportEnabled()
266     {
267         return csvExportEnabled;
268     }
269
270     public void setCsvExportEnabled(boolean csvExportEnabled)
271     {
272         this.csvExportEnabled = csvExportEnabled;
273     }
274
275     public boolean isHtmlExportEnabled()
276     {
277         return htmlExportEnabled;
278     }
279
280     public void setHtmlExportEnabled(boolean htmlExportEnabled)
281     {
282         this.htmlExportEnabled = htmlExportEnabled;
283     }
284
285     public boolean isPdfExportEnabled()
286     {
287         return pdfExportEnabled;
288     }
289
290     public void setPdfExportEnabled(boolean pdfExportEnabled)
291     {
292         this.pdfExportEnabled = pdfExportEnabled;
293     }
294
295     public boolean isXlsExportEnabled()
296     {
297         return xlsExportEnabled;
298     }
299
300     public void setXlsExportEnabled(boolean xlsExportEnabled)
301     {
302         this.xlsExportEnabled = xlsExportEnabled;
303     }
304
305     public String JavaDoc getQuery()
306     {
307         return query;
308     }
309
310     public void setQuery(String JavaDoc query)
311     {
312         this.query = query;
313     }
314
315     public boolean isExcelExportEnabled()
316     {
317         return excelExportEnabled;
318     }
319
320     public void setExcelExportEnabled(Boolean JavaDoc excelExportEnabled)
321     {
322         if (excelExportEnabled == null) excelExportEnabled = new Boolean JavaDoc(false);
323         this.excelExportEnabled = excelExportEnabled.booleanValue();
324     }
325
326     public boolean isRtfExportEnabled()
327     {
328         return rtfExportEnabled;
329     }
330
331     public void setRtfExportEnabled(Boolean JavaDoc rtfExportEnabled)
332     {
333         if (rtfExportEnabled == null) rtfExportEnabled = new Boolean JavaDoc(false);
334         this.rtfExportEnabled = rtfExportEnabled.booleanValue();
335     }
336
337     public boolean isTextExportEnabled()
338     {
339         return textExportEnabled;
340     }
341
342     public void setTextExportEnabled(Boolean JavaDoc textExportEnabled)
343     {
344         if (textExportEnabled == null) textExportEnabled = new Boolean JavaDoc(false);
345         this.textExportEnabled = textExportEnabled.booleanValue();
346     }
347
348     public ReportExportOption getReportExportOption()
349     {
350         if (reportExportOption == null) reportExportOption = new ReportExportOption();
351         return reportExportOption;
352     }
353
354     public void setReportExportOption(ReportExportOption reportExportOption)
355     {
356         this.reportExportOption = reportExportOption;
357     }
358
359     public boolean isVirtualizationEnabled()
360     {
361         return virtualizationEnabled;
362     }
363
364     public void setVirtualizationEnabled(Boolean JavaDoc virtualizationEnabled)
365     {
366         if (virtualizationEnabled == null) virtualizationEnabled = new Boolean JavaDoc(false);
367         this.virtualizationEnabled = virtualizationEnabled.booleanValue();
368     }
369     
370     public boolean isHidden()
371     {
372         return hidden;
373     }
374
375     public void setHidden(Boolean JavaDoc hidden)
376     {
377         if (hidden == null) hidden = new Boolean JavaDoc(false);
378         this.hidden = hidden.booleanValue();
379     }
380
381     public boolean isDisplayInline()
382     {
383         return displayInline;
384     }
385
386     public void setDisplayInline(boolean displayInline)
387     {
388         this.displayInline = displayInline;
389     }
390
391 }
Popular Tags