use of org.motechproject.scheduler.contract.RepeatingPeriodJobId in project motech by motech.
the class MotechSchedulerServiceImpl method scheduleRepeatingPeriodJob.
private void scheduleRepeatingPeriodJob(RepeatingPeriodSchedulableJob job, boolean update) {
logObjectIfNotNull(job);
validateRepeatingPeriodSchedulableJob(job);
MotechEvent motechEvent = job.getMotechEvent();
JobId jobId = new RepeatingPeriodJobId(motechEvent);
JobDetail jobDetail = newJob(MotechScheduledJob.class).withIdentity(jobKey(jobId.value(), JOB_GROUP_NAME)).build();
putMotechEventDataToJobDataMap(jobDetail.getJobDataMap(), motechEvent);
jobDetail.getJobDataMap().put(EVENT_METADATA, createMetadataForMisfireSchedulableJob(job, motechEvent));
ScheduleBuilder scheduleBuilder = PeriodIntervalScheduleBuilder.periodIntervalSchedule().withRepeatPeriod(job.getRepeatPeriod()).withMisfireHandlingInstructionFireAndProceed();
Trigger trigger = buildJobDetail(job, DateUtil.toDate(job.getStartDate()), DateUtil.toDate(job.getEndDate()), jobId, jobDetail, scheduleBuilder);
scheduleJob(jobDetail, trigger, update);
}
Aggregations