public abstract String getManagedBeanName();
public abstract List<? extends OperationSchedule> getOperationScheduleList();
public SimpleTrigger getTrigger() {
OperationDetailsScheduleComponent component = this.getOperationDetails();
SimpleTrigger trigger = new SimpleTrigger();
//Validate if a start date is specified
Date now = Calendar.getInstance().getTime();
if ((component.getStart().equals("immediate"))) {
trigger.setStartTime(now);
} else {
component.setDeferred(true);
if (component.getStartDate() == null) {
throw new IllegalArgumentException("Please select a start date");
}
if (now.after(component.getStartDate())) {
throw new IllegalArgumentException("Scheduling cannot occur in the past");
// FacesMessages.instance().addToControl("start", "Scheduling cannot occur in the past");
} else {
trigger.setStartTime(component.getStartDate());
if (component.getRecur().equals("never")) {
} else {
//set the repetition interval of the trigger
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
component.setRepeat(true);
long repeatInterval = component.getUnit().getMillis() * component.getRepeatInterval();
trigger.setRepeatInterval(repeatInterval);
if (component.getEnd().equals("endDate")) {
if (component.getEndDate() == null) {
throw new IllegalArgumentException("Please select an end date");
}
component.setTerminate(true);
if (component.getEndDate().before(component.getStartDate())) {
throw new IllegalArgumentException("Scheduling cannot occur before the start date");
} else {
//set the end date of the trigger
trigger.setEndTime(component.getEndDate());
}
}
}
}
}