Search in sources :

Example 1 with RepeatingPeriodJobId

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);
}
Also used : JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) OperableTrigger(org.quartz.spi.OperableTrigger) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) PeriodIntervalScheduleBuilder(org.motechproject.scheduler.trigger.PeriodIntervalScheduleBuilder) ScheduleBuilder(org.quartz.ScheduleBuilder) SimpleScheduleBuilder(org.quartz.SimpleScheduleBuilder) CalendarIntervalScheduleBuilder(org.quartz.CalendarIntervalScheduleBuilder) CronScheduleBuilder(org.quartz.CronScheduleBuilder) RepeatingPeriodJobId(org.motechproject.scheduler.contract.RepeatingPeriodJobId) MotechEvent(org.motechproject.event.MotechEvent) RunOnceJobId(org.motechproject.scheduler.contract.RunOnceJobId) JobId(org.motechproject.scheduler.contract.JobId) RepeatingJobId(org.motechproject.scheduler.contract.RepeatingJobId) RepeatingPeriodJobId(org.motechproject.scheduler.contract.RepeatingPeriodJobId) CronJobId(org.motechproject.scheduler.contract.CronJobId)

Aggregations

MotechEvent (org.motechproject.event.MotechEvent)1 CronJobId (org.motechproject.scheduler.contract.CronJobId)1 JobId (org.motechproject.scheduler.contract.JobId)1 RepeatingJobId (org.motechproject.scheduler.contract.RepeatingJobId)1 RepeatingPeriodJobId (org.motechproject.scheduler.contract.RepeatingPeriodJobId)1 RunOnceJobId (org.motechproject.scheduler.contract.RunOnceJobId)1 PeriodIntervalScheduleBuilder (org.motechproject.scheduler.trigger.PeriodIntervalScheduleBuilder)1 CalendarIntervalScheduleBuilder (org.quartz.CalendarIntervalScheduleBuilder)1 CronScheduleBuilder (org.quartz.CronScheduleBuilder)1 CronTrigger (org.quartz.CronTrigger)1 JobDetail (org.quartz.JobDetail)1 ScheduleBuilder (org.quartz.ScheduleBuilder)1 SimpleScheduleBuilder (org.quartz.SimpleScheduleBuilder)1 SimpleTrigger (org.quartz.SimpleTrigger)1 Trigger (org.quartz.Trigger)1 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)1 OperableTrigger (org.quartz.spi.OperableTrigger)1