1 19 20 package org.efs.openreports.objects; 21 22 import java.io.Serializable ; 23 import java.util.*; 24 25 public class ReportSchedule implements Serializable 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 startHour; 43 private String startMinute; 44 private String startAmPm; 45 private int scheduleType; 46 private int exportType; 47 private int hours; 48 private String cronExpression; 49 50 private String recipients; 51 52 private String scheduleName; 53 54 private transient String scheduleDescription; 55 private transient Date nextFireDate; 56 private transient String 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 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 getStartAmPm() 137 { 138 return startAmPm; 139 } 140 141 public void setStartAmPm(String startAmPm) 142 { 143 this.startAmPm = startAmPm; 144 } 145 146 public String getStartHour() 147 { 148 return startHour; 149 } 150 151 public void setStartHour(String 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 getStartMinute() 192 { 193 return startMinute; 194 } 195 196 public void setStartMinute(String startMinute) 197 { 198 this.startMinute = startMinute; 199 } 200 201 public String getScheduleName() 202 { 203 return scheduleName; 204 } 205 206 public void setScheduleName(String scheduleName) 207 { 208 this.scheduleName = scheduleName; 209 } 210 211 public String 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 getRecipients() 231 { 232 return recipients; 233 } 234 235 public void setRecipients(String 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 getScheduleDescription() 271 { 272 return scheduleDescription; 273 } 274 275 public void setScheduleDescription(String scheduleDescription) 276 { 277 this.scheduleDescription = scheduleDescription; 278 } 279 280 public String getScheduleState() 281 { 282 return scheduleState; 283 } 284 285 public void setScheduleState(String scheduleState) 286 { 287 this.scheduleState = scheduleState; 288 } 289 290 public String getCronExpression() 291 { 292 return cronExpression; 293 } 294 295 public void setCronExpression(String 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 |