private void initScheduleEditor(Schedule sched) throws CronParseException { DualModeScheduleEditor scheduleEditor = scheduleCreatorDialog.getScheduleEditor(); scheduleEditor.setSubscriptionSchedule(sched.isSubscriptionSchedule()); scheduleEditor.setName(sched.getJobName()); scheduleEditor.setGroupName(sched.getJobGroup()); scheduleEditor.setDescription(sched.getDescription()); String repeatIntervalInMillisecs = sched.getRepeatInterval(); if (sched.isCronSchedule()) { scheduleEditor.setCronString(sched.getCronString()); // throws CronParseException } else if (sched.isRepeatSchedule()) { long repeatIntervalInSecs = TimeUtil.millsecondsToSecs(Long.parseLong(repeatIntervalInMillisecs)); if (0 == repeatIntervalInSecs) { // run once scheduleEditor.setScheduleType(ScheduleEditor.ScheduleType.RUN_ONCE); } else { // run multiple scheduleEditor.setRepeatInSecs((int) repeatIntervalInSecs); } } else { throw new RuntimeException( Messages.getString("illegalStateMissingCronAndRepeat")); // $NON-NLS-1$ } String timePart = null; String strDate = sched.getStartDate(); if (null != strDate) { Date startDate = TimeUtil.getDate(strDate); if (sched.isRepeatSchedule()) { timePart = TimeUtil.getTimePart(startDate); scheduleEditor.setStartTime(timePart); startDate = TimeUtil.zeroTimePart(startDate); } scheduleEditor.setStartDate(startDate); } // scheduleEditor.getRunOnceEditor().setStartTime(strTime) // scheduleEditor.getRunOnceEditor().setStartDate(strTime) strDate = sched.getEndDate(); if (null != strDate) { scheduleEditor.setEndBy(); Date endDate = TimeUtil.getDate(strDate); if (sched.isRepeatSchedule()) { endDate = TimeUtil.zeroTimePart(endDate); } scheduleEditor.setEndDate(endDate); } else { scheduleEditor.setNoEndDate(); } }
private List<Schedule> getFilteredSchedulesList(List<Schedule> scheduleList) { List<Schedule> filteredList = null; String filterVal = schedulerToolbar.getFilterValue(); if (!SchedulerToolbar.ALL_GROUPS_FILTER.equals(filterVal)) { filteredList = new ArrayList<Schedule>(); for (int ii = 0; ii < scheduleList.size(); ++ii) { Schedule s = scheduleList.get(ii); if (s.getJobGroup().equals(filterVal)) { filteredList.add(s); } } } else { filteredList = scheduleList; } return filteredList; }
private void initFilterList() { String currentFilter = schedulerToolbar.getFilterValue(); currentFilter = (null == currentFilter) ? SchedulerToolbar.ALL_GROUPS_FILTER : currentFilter; Set<String> groupNames = new HashSet<String>(); List<Schedule> scheduleList = schedulesModel.getScheduleList(); for (int ii = 0; ii < scheduleList.size(); ++ii) { Schedule s = scheduleList.get(ii); String groupName = s.getJobGroup(); if (!groupNames.contains(groupName)) { groupNames.add(groupName); } } schedulerToolbar.clearFilters(); schedulerToolbar.addFilterItem(SchedulerToolbar.ALL_GROUPS_FILTER); for (String name : groupNames) { schedulerToolbar.addFilterItem(name); } schedulerToolbar.setFilterValue(currentFilter); }
private void updateSchedule() { AsyncCallback<Object> updateScheduleResponseCallback = new AsyncCallback<Object>() { public void onSuccess(Object o) { scheduleCreatorDialog.hide(); loadJobsTable(); } public void onFailure(Throwable caught) { MessageDialogBox messageDialog = new MessageDialogBox( ExceptionParser.getErrorHeader(caught.getMessage()), ExceptionParser.getErrorMessage(caught.getMessage(), caught.getMessage()), false, false, true); messageDialog.center(); } }; final List<Schedule> scheduleList = schedulesListCtrl.getSelectedSchedules(); Schedule oldSchedule = scheduleList.get(0); DualModeScheduleEditor scheduleEditor = scheduleCreatorDialog.getScheduleEditor(); ISchedulerServiceAsync schedSvc = scheduleEditor.isSubscriptionSchedule() ? PacServiceFactory.getSubscriptionService() : PacServiceFactory.getSchedulerService(); String cronStr = scheduleEditor.getCronString(); Date startDate = scheduleEditor.getStartDate(); Date endDate = scheduleEditor.getEndDate(); if (null == cronStr) { // must be a repeating schedule String startTime = scheduleEditor .getStartTime(); // format of string should be: HH:MM:SS AM/PM, e.g. 7:12:28 PM startDate = TimeUtil.getDateTime(startTime, startDate); endDate = (null != endDate) ? TimeUtil.getDateTime(startTime, endDate) : null; } ScheduleEditor.ScheduleType rt = scheduleEditor.getScheduleType(); switch (rt) { case RUN_ONCE: schedSvc.updateRepeatSchedule( oldSchedule.getJobName(), oldSchedule.getJobGroup(), oldSchedule.getSchedId(), scheduleEditor.getName().trim(), scheduleEditor.getGroupName().trim(), scheduleEditor.getDescription().trim(), startDate, endDate, "0" /*repeat count*/, //$NON-NLS-1$ "0" /*repeat time*/, //$NON-NLS-1$ scheduleCreatorDialog .getSolutionRepositoryActionSequenceEditor() .getActionsAsString() .trim(), updateScheduleResponseCallback); break; case SECONDS: // fall through case MINUTES: // fall through case HOURS: // fall through case DAILY: // fall through case WEEKLY: // fall through case MONTHLY: // fall through case YEARLY: if (null == cronStr) { String repeatInterval = Long.toString(TimeUtil.secsToMillisecs(scheduleEditor.getRepeatInSecs())); schedSvc.updateRepeatSchedule( oldSchedule.getJobName(), oldSchedule.getJobGroup(), oldSchedule.getSchedId(), scheduleEditor.getName().trim(), scheduleEditor.getGroupName().trim(), scheduleEditor.getDescription().trim(), startDate, endDate, null /*repeat count*/, repeatInterval.trim(), scheduleCreatorDialog .getSolutionRepositoryActionSequenceEditor() .getActionsAsString() .trim(), updateScheduleResponseCallback); break; } else { // fall through to case CRON } case CRON: schedSvc.updateCronSchedule( oldSchedule.getJobName(), oldSchedule.getJobGroup(), oldSchedule.getSchedId(), scheduleEditor.getName().trim(), scheduleEditor.getGroupName().trim(), scheduleEditor.getDescription().trim(), startDate, endDate, cronStr.trim(), scheduleCreatorDialog .getSolutionRepositoryActionSequenceEditor() .getActionsAsString() .trim(), updateScheduleResponseCallback); break; default: throw new RuntimeException( Messages.getString("invalidRunType", rt.toString())); // $NON-NLS-1$ } }