cron = reportSchedule.getCronExpression();
runToFile = reportSchedule.isDeliveryMethodSelected(DeliveryMethod.FILE.getName());
if (reportSchedule.getAlert() != null)
{
ReportUserAlert userAlert = reportSchedule.getAlert();
alertId = userAlert.getAlert().getId().intValue();
alertLimit = userAlert.getLimit();
alertOperator = userAlert.getOperator();
}
}
catch (Exception e)
{
addActionError(e.getMessage());
return INPUT;
}
}
else
{
report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT);
Calendar calendar = Calendar.getInstance();
startDate = dateProvider.formatDate(calendar.getTime());
startHour = String.valueOf(calendar.get(Calendar.HOUR));
startMinute = String.valueOf(calendar.get(Calendar.MINUTE));
if (calendar.get(Calendar.AM_PM) == Calendar.PM) startAmPm = "PM";
}
return INPUT;
}
if (startDate == null || startDate.length() < 1 || startHour == null || startHour.length() < 1
|| startMinute == null || startMinute.length() < 1 || startAmPm == null
|| startAmPm.length() < 1)
{
addActionError(LocalStrings.ERROR_DATEANDTIME_REQUIRED);
return INPUT;
}
int hour = Integer.parseInt(startHour);
int minute = Integer.parseInt(startMinute);
if (hour > 12 || hour < 1 || minute < 0 || minute > 59)
{
addActionError(LocalStrings.ERROR_DATEANDTIME_INVALID);
return INPUT;
}
ReportSchedule reportSchedule = new ReportSchedule();
try
{
if (scheduleName != null && scheduleName.length() > 0)
{
reportSchedule = schedulerProvider.getScheduledReport(user, scheduleName);
}
else
{
report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT);
int exportType = Integer.parseInt((String) ActionContext.getContext().getSession().get(
ORStatics.EXPORT_TYPE));
reportSchedule.setReport(report);
reportSchedule.setUser(user);
reportSchedule.setReportParameters(getReportParameters());
reportSchedule.setExportType(exportType);
reportSchedule.setScheduleName(report.getId() + "|" + new Date().getTime());
}
reportSchedule.setScheduleType(scheduleType);
reportSchedule.setStartDate(dateProvider.parseDate(startDate));
reportSchedule.setStartHour(startHour);
reportSchedule.setStartMinute(startMinute);
reportSchedule.setStartAmPm(startAmPm);
reportSchedule.setRecipients(recipients);
reportSchedule.setScheduleDescription(description);
reportSchedule.setHours(hours);
reportSchedule.setCronExpression(cron);
if (runToFile)
{
reportSchedule.setDeliveryMethods(new String[]{DeliveryMethod.FILE.getName()});
}
else
{
reportSchedule.setDeliveryMethods(new String[]{DeliveryMethod.EMAIL.getName()});
}
if (alertId != -1)
{
ReportAlert alert = alertProvider.getReportAlert(new Integer(alertId));
ReportUserAlert userAlert = new ReportUserAlert();
userAlert.setAlert(alert);
userAlert.setUser(user);
userAlert.setLimit(alertLimit);
userAlert.setOperator(alertOperator);
reportSchedule.setAlert(userAlert);
}
else
{