001: /*
002: * Copyright (C) 2003 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 ReportSchedule implements Serializable {
026: private static final long serialVersionUID = -679355847466582944l;
027:
028: public static final int ONCE = 0;
029: public static final int DAILY = 1;
030: public static final int WEEKLY = 2;
031: public static final int MONTHLY = 3;
032: public static final int WEEKDAYS = 4;
033: public static final int HOURLY = 5;
034: public static final int CRON = 6;
035:
036: private ReportUser user;
037: private Report report;
038: private ReportUserAlert alert;
039: private Map<String, Object> reportParameters;
040: private Date startDate;
041: private String startHour;
042: private String startMinute;
043: private String startAmPm;
044: private int scheduleType;
045: private int exportType;
046: private int hours;
047: private String cronExpression;
048:
049: private String recipients;
050:
051: private String scheduleName;
052:
053: private String xmlInput;
054: private String[] deliveryMethods;
055: private String deliveryReturnAddress;
056: private String requestId;
057: private int schedulePriority = 5;
058:
059: private Locale locale;
060:
061: private transient String scheduleDescription;
062: private transient Date nextFireDate;
063: private transient String scheduleState;
064:
065: public ReportSchedule() {
066:
067: }
068:
069: public Report getReport() {
070: return report;
071: }
072:
073: public void setReport(Report report) {
074: this .report = report;
075: }
076:
077: public Map<String, Object> getReportParameters() {
078: return reportParameters;
079: }
080:
081: public void setReportParameters(Map<String, Object> reportParameters) {
082: this .reportParameters = reportParameters;
083: }
084:
085: public int getScheduleType() {
086: return scheduleType;
087: }
088:
089: public String getScheduleTypeName() {
090: switch (scheduleType) {
091: case ONCE:
092: return "Once";
093: case DAILY:
094: return "Daily";
095: case WEEKLY:
096: return "Weekly";
097: case MONTHLY:
098: return "Monthly";
099: case WEEKDAYS:
100: return "Weekdays";
101: case HOURLY:
102: return "Hourly";
103: case CRON:
104: return "Cron";
105: default:
106: return "Unknown";
107: }
108: }
109:
110: public void setScheduleType(int scheduleType) {
111: this .scheduleType = scheduleType;
112: }
113:
114: public Date getStartDate() {
115: return startDate;
116: }
117:
118: public void setStartDate(Date startDate) {
119: this .startDate = startDate;
120: }
121:
122: public ReportUser getUser() {
123: return user;
124: }
125:
126: public void setUser(ReportUser user) {
127: this .user = user;
128: }
129:
130: public String getStartAmPm() {
131: return startAmPm;
132: }
133:
134: public void setStartAmPm(String startAmPm) {
135: this .startAmPm = startAmPm;
136: }
137:
138: public String getStartHour() {
139: return startHour;
140: }
141:
142: public void setStartHour(String startHour) {
143: this .startHour = startHour;
144: }
145:
146: public int getAbsoluteStartHour() {
147: int hour = Integer.parseInt(startHour);
148:
149: if (startAmPm.equalsIgnoreCase("PM") && hour != 12)
150: hour += 12;
151:
152: if (startAmPm.equalsIgnoreCase("AM") && hour == 12)
153: hour -= 12;
154:
155: return hour;
156: }
157:
158: public int getAbsoluteEndHour() {
159: return getAbsoluteStartHour() + hours;
160: }
161:
162: public int getDayOfWeek() {
163: Calendar calendar = Calendar.getInstance();
164: calendar.setTime(startDate);
165:
166: return calendar.get(Calendar.DAY_OF_WEEK);
167: }
168:
169: public int getDayOfMonth() {
170: Calendar calendar = Calendar.getInstance();
171: calendar.setTime(startDate);
172:
173: return calendar.get(Calendar.DAY_OF_MONTH);
174: }
175:
176: public String getStartMinute() {
177: return startMinute;
178: }
179:
180: public void setStartMinute(String startMinute) {
181: this .startMinute = startMinute;
182: }
183:
184: public String getScheduleName() {
185: return scheduleName;
186: }
187:
188: public void setScheduleName(String scheduleName) {
189: this .scheduleName = scheduleName;
190: }
191:
192: public String getScheduleGroup() {
193: return String.valueOf(user.getId());
194: }
195:
196: public Date getStartDateTime() {
197: Calendar calendar = Calendar.getInstance();
198:
199: if (startDate != null) {
200: calendar.setTime(startDate);
201: calendar.set(Calendar.HOUR_OF_DAY, getAbsoluteStartHour());
202: calendar
203: .set(Calendar.MINUTE, Integer.parseInt(startMinute));
204: }
205:
206: return calendar.getTime();
207: }
208:
209: public String getRecipients() {
210: return recipients;
211: }
212:
213: public void setRecipients(String recipients) {
214: this .recipients = recipients;
215: }
216:
217: public int getExportType() {
218: return exportType;
219: }
220:
221: public void setExportType(int exportType) {
222: this .exportType = exportType;
223: }
224:
225: public Date getNextFireDate() {
226: return nextFireDate;
227: }
228:
229: public void setNextFireDate(Date nextFireDate) {
230: this .nextFireDate = nextFireDate;
231: }
232:
233: public ReportUserAlert getAlert() {
234: return alert;
235: }
236:
237: public void setAlert(ReportUserAlert alert) {
238: this .alert = alert;
239: }
240:
241: public String getScheduleDescription() {
242: return scheduleDescription;
243: }
244:
245: public void setScheduleDescription(String scheduleDescription) {
246: this .scheduleDescription = scheduleDescription;
247: }
248:
249: public String getScheduleState() {
250: return scheduleState;
251: }
252:
253: public void setScheduleState(String scheduleState) {
254: this .scheduleState = scheduleState;
255: }
256:
257: public String getCronExpression() {
258: return cronExpression;
259: }
260:
261: public void setCronExpression(String cronExpression) {
262: this .cronExpression = cronExpression;
263: }
264:
265: public int getHours() {
266: return hours;
267: }
268:
269: public void setHours(int hours) {
270: this .hours = hours;
271: }
272:
273: public String getXmlInput() {
274: return xmlInput;
275: }
276:
277: public void setXmlInput(String xmlInput) {
278: this .xmlInput = xmlInput;
279: }
280:
281: public String[] getDeliveryMethods() {
282: return deliveryMethods;
283: }
284:
285: public void setDeliveryMethods(String[] deliveryMethods) {
286: this .deliveryMethods = deliveryMethods;
287: }
288:
289: public boolean isDeliveryMethodSelected(String deliveryMethod) {
290: if (deliveryMethods == null)
291: return false;
292:
293: for (int i = 0; i < deliveryMethods.length; i++) {
294: if (deliveryMethods[i].equals(deliveryMethod))
295: return true;
296: }
297:
298: return false;
299: }
300:
301: public String getDeliveryReturnAddress() {
302: return deliveryReturnAddress;
303: }
304:
305: public void setDeliveryReturnAddress(String deliveryReturnAddress) {
306: this .deliveryReturnAddress = deliveryReturnAddress;
307: }
308:
309: public String getRequestId() {
310: return requestId;
311: }
312:
313: public void setRequestId(String requestId) {
314: this .requestId = requestId;
315: }
316:
317: public int getSchedulePriority() {
318: return schedulePriority;
319: }
320:
321: public void setSchedulePriority(int schedulePriority) {
322: this .schedulePriority = schedulePriority;
323: }
324:
325: public Locale getLocale() {
326: return locale;
327: }
328:
329: public void setLocale(Locale locale) {
330: this.locale = locale;
331: }
332: }
|