use of org.quartz.CalendarIntervalTrigger in project motech by motech.
the class MotechSchedulerDatabaseServiceImpl method getJobInfo.
private String getJobInfo(Trigger trigger, String jobType) throws SchedulerException {
if (jobType.equals(JobBasicInfo.JOBTYPE_REPEATING)) {
Integer timesTriggered = 0;
String repeatMaxCount = "-";
if (trigger instanceof CalendarIntervalTrigger) {
CalendarIntervalTrigger calendarIntervalTrigger = (CalendarIntervalTrigger) trigger;
timesTriggered = calendarIntervalTrigger.getTimesTriggered();
} else if (trigger instanceof SimpleTrigger) {
SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
timesTriggered = simpleTrigger.getTimesTriggered();
}
if (trigger.getEndTime() != null) {
repeatMaxCount = Integer.toString(TriggerUtils.computeFireTimesBetween((OperableTrigger) trigger, null, trigger.getStartTime(), trigger.getEndTime()).size() + timesTriggered);
}
return String.format("%d/%s", timesTriggered, repeatMaxCount);
} else if (jobType.equals(JobBasicInfo.JOBTYPE_CRON)) {
CronScheduleBuilder cronScheduleBuilder = (CronScheduleBuilder) trigger.getScheduleBuilder();
CronTrigger cronTrigger = (CronTrigger) cronScheduleBuilder.build();
return cronTrigger.getCronExpression();
} else {
return "-";
}
}
use of org.quartz.CalendarIntervalTrigger in project motech by motech.
the class SchedulableJobBuilder method buildRepeatingSchedulableJob.
private static SchedulableJob buildRepeatingSchedulableJob(Trigger trigger, JobDataMap dataMap) {
RepeatingSchedulableJob job = new RepeatingSchedulableJob();
long interval;
if (trigger instanceof CalendarIntervalTrigger) {
CalendarIntervalTrigger calendarTrigger = (CalendarIntervalTrigger) trigger;
interval = calendarTrigger.getRepeatInterval();
} else {
SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
job.setRepeatCount(simpleTrigger.getRepeatCount());
interval = simpleTrigger.getRepeatInterval() / SECOND;
}
job.setEndDate(getEndDate(trigger));
job.setRepeatIntervalInSeconds((int) interval);
job.setIgnorePastFiresAtStart(dataMap.getBoolean(IGNORE_PAST_FIRES_AT_START));
job.setUseOriginalFireTimeAfterMisfire(dataMap.getBoolean(USE_ORIGINAL_FIRE_TIME_AFTER_MISFIRE));
return job;
}
Aggregations