KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (C) 2003 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 ReportSchedule implements Serializable JavaDoc
26 {
27     private static final long serialVersionUID = -679355847466582944l;
28     
29     public static final int ONCE = 0;
30     public static final int DAILY = 1;
31     public static final int WEEKLY = 2;
32     public static final int MONTHLY = 3;
33     public static final int WEEKDAYS = 4;
34     public static final int HOURLY = 5;
35     public static final int CRON = 6;
36     
37     private ReportUser user;
38     private Report report;
39     private ReportUserAlert alert;
40     private Map reportParameters;
41     private Date startDate;
42     private String JavaDoc startHour;
43     private String JavaDoc startMinute;
44     private String JavaDoc startAmPm;
45     private int scheduleType;
46     private int exportType;
47     private int hours;
48     private String JavaDoc cronExpression;
49     
50     private String JavaDoc recipients;
51     
52     private String JavaDoc scheduleName;
53     
54     private transient String JavaDoc scheduleDescription;
55     private transient Date nextFireDate;
56     private transient String JavaDoc scheduleState;
57     
58     public ReportSchedule()
59     {
60         
61     }
62
63     public Report getReport()
64     {
65         return report;
66     }
67
68     public void setReport(Report report)
69     {
70         this.report = report;
71     }
72
73     public Map getReportParameters()
74     {
75         return reportParameters;
76     }
77
78     public void setReportParameters(Map reportParameters)
79     {
80         this.reportParameters = reportParameters;
81     }
82
83     public int getScheduleType()
84     {
85         return scheduleType;
86     }
87     
88     public String JavaDoc getScheduleTypeName()
89     {
90         switch (scheduleType)
91         {
92             case ONCE:
93                 return "Once";
94             case DAILY:
95                 return "Daily";
96             case WEEKLY:
97                 return "Weekly";
98             case MONTHLY:
99                 return "Monthly";
100             case WEEKDAYS:
101                 return "Weekdays";
102             case HOURLY:
103                 return "Hourly";
104             case CRON:
105                 return "Cron";
106             default:
107                 return "Unknown";
108         }
109     }
110
111     public void setScheduleType(int scheduleType)
112     {
113         this.scheduleType = scheduleType;
114     }
115
116     public Date getStartDate()
117     {
118         return startDate;
119     }
120
121     public void setStartDate(Date startDate)
122     {
123         this.startDate = startDate;
124     }
125
126     public ReportUser getUser()
127     {
128         return user;
129     }
130
131     public void setUser(ReportUser user)
132     {
133         this.user = user;
134     }
135
136     public String JavaDoc getStartAmPm()
137     {
138         return startAmPm;
139     }
140
141     public void setStartAmPm(String JavaDoc startAmPm)
142     {
143         this.startAmPm = startAmPm;
144     }
145
146     public String JavaDoc getStartHour()
147     {
148         return startHour;
149     }
150
151     public void setStartHour(String JavaDoc startHour)
152     {
153         this.startHour = startHour;
154     }
155     
156     public int getAbsoluteStartHour()
157     {
158         int hour = Integer.parseInt(startHour);
159         
160         if (startAmPm.equalsIgnoreCase("PM") && hour != 12)
161             hour += 12;
162         
163         if (startAmPm.equalsIgnoreCase("AM") && hour == 12)
164             hour -= 12;
165         
166         return hour;
167     }
168     
169     public int getAbsoluteEndHour()
170     {
171         return getAbsoluteStartHour() + hours;
172     }
173     
174     public int getDayOfWeek()
175     {
176         Calendar calendar = Calendar.getInstance();
177         calendar.setTime(startDate);
178         
179         return calendar.get(Calendar.DAY_OF_WEEK);
180     }
181     
182     public int getDayOfMonth()
183     {
184         Calendar calendar = Calendar.getInstance();
185         calendar.setTime(startDate);
186         
187         return calendar.get(Calendar.DAY_OF_MONTH);
188     }
189     
190
191     public String JavaDoc getStartMinute()
192     {
193         return startMinute;
194     }
195
196     public void setStartMinute(String JavaDoc startMinute)
197     {
198         this.startMinute = startMinute;
199     }
200     
201     public String JavaDoc getScheduleName()
202     {
203         return scheduleName;
204     }
205     
206     public void setScheduleName(String JavaDoc scheduleName)
207     {
208         this.scheduleName = scheduleName;
209     }
210     
211     public String JavaDoc getScheduleGroup()
212     {
213         return String.valueOf(user.getId());
214     }
215     
216     public Date getStartDateTime()
217     {
218         Calendar calendar = Calendar.getInstance();
219         
220         if (startDate != null)
221         {
222             calendar.setTime(startDate);
223             calendar.set(Calendar.HOUR_OF_DAY, getAbsoluteStartHour());
224             calendar.set(Calendar.MINUTE, Integer.parseInt(startMinute));
225         }
226         
227         return calendar.getTime();
228     }
229
230     public String JavaDoc getRecipients()
231     {
232         return recipients;
233     }
234
235     public void setRecipients(String JavaDoc recipients)
236     {
237         this.recipients = recipients;
238     }
239     
240     public int getExportType()
241     {
242         return exportType;
243     }
244
245     public void setExportType(int exportType)
246     {
247         this.exportType = exportType;
248     }
249     
250     public Date getNextFireDate()
251     {
252         return nextFireDate;
253     }
254     
255     public void setNextFireDate(Date nextFireDate)
256     {
257         this.nextFireDate = nextFireDate;
258     }
259
260     public ReportUserAlert getAlert()
261     {
262         return alert;
263     }
264
265     public void setAlert(ReportUserAlert alert)
266     {
267         this.alert = alert;
268     }
269
270     public String JavaDoc getScheduleDescription()
271     {
272         return scheduleDescription;
273     }
274
275     public void setScheduleDescription(String JavaDoc scheduleDescription)
276     {
277         this.scheduleDescription = scheduleDescription;
278     }
279
280     public String JavaDoc getScheduleState()
281     {
282         return scheduleState;
283     }
284
285     public void setScheduleState(String JavaDoc scheduleState)
286     {
287         this.scheduleState = scheduleState;
288     }
289
290     public String JavaDoc getCronExpression()
291     {
292         return cronExpression;
293     }
294
295     public void setCronExpression(String JavaDoc cronExpression)
296     {
297         this.cronExpression = cronExpression;
298     }
299
300     public int getHours()
301     {
302         return hours;
303     }
304
305     public void setHours(int hours)
306     {
307         this.hours = hours;
308     }
309 }
Popular Tags