Search in sources :

Example 31 with CronSchedulableJob

use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.

the class PasswordExpirationSchedulerInternal method schedulePasswordReminderJob.

/**
 * Schedules password reminder job that will be run everyday at midnight.
 */
public void schedulePasswordReminderJob() {
    CronSchedulableJob job = new CronSchedulableJob(new MotechEvent(PASSWORD_EXPIRATION_CHECK_EVENT), "0 0 0 * * ? *");
    schedulerService.safeScheduleJob(job);
}
Also used : CronSchedulableJob(org.motechproject.scheduler.contract.CronSchedulableJob) MotechEvent(org.motechproject.event.MotechEvent)

Example 32 with CronSchedulableJob

use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.

the class MotechSchedulerActionProxyServiceImpl method scheduleCronJob.

@Override
public void scheduleCronJob(String subject, Map<Object, Object> parameters, String cronExpression, DateTime startTime, DateTime endTime, Boolean ignorePastFiresAtStart) {
    MotechEvent motechEvent = new MotechEvent(subject, createMotechEventParameters(parameters));
    CronSchedulableJob job = new CronSchedulableJob(motechEvent, cronExpression, startTime, endTime, ignorePastFiresAtStart);
    scheduler.scheduleJob(job);
}
Also used : CronSchedulableJob(org.motechproject.scheduler.contract.CronSchedulableJob) MotechEvent(org.motechproject.event.MotechEvent)

Example 33 with CronSchedulableJob

use of org.motechproject.scheduler.contract.CronSchedulableJob in project motech by motech.

the class MotechSchedulerServiceImpl method scheduleDayOfWeekJob.

private void scheduleDayOfWeekJob(DayOfWeekSchedulableJob job, boolean update) {
    logObjectIfNotNull(job);
    validateDayOfWeekSchedulableJob(job);
    MotechEvent motechEvent = job.getMotechEvent();
    Time time = job.getTime();
    CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.atHourAndMinuteOnGivenDaysOfWeek(time.getHour(), time.getMinute(), job.getCronDays().toArray(new Integer[job.getCronDays().size()]));
    CronTriggerImpl cronTrigger = (CronTriggerImpl) cronScheduleBuilder.build();
    CronSchedulableJob cronSchedulableJob = new CronSchedulableJob(motechEvent, cronTrigger.getCronExpression(), job.getStartDate(), job.getEndDate(), job.isIgnorePastFiresAtStart(), job.isUiDefined());
    scheduleCronJob(cronSchedulableJob, true, update);
}
Also used : CronScheduleBuilder(org.quartz.CronScheduleBuilder) SchedulableJobValidator.validateCronSchedulableJob(org.motechproject.scheduler.validation.SchedulableJobValidator.validateCronSchedulableJob) CronSchedulableJob(org.motechproject.scheduler.contract.CronSchedulableJob) CronTriggerImpl(org.quartz.impl.triggers.CronTriggerImpl) DateUtil.newDateTime(org.motechproject.commons.date.util.DateUtil.newDateTime) Time(org.motechproject.commons.date.model.Time) DateTime(org.joda.time.DateTime) MotechEvent(org.motechproject.event.MotechEvent)

Aggregations

CronSchedulableJob (org.motechproject.scheduler.contract.CronSchedulableJob)33 MotechEvent (org.motechproject.event.MotechEvent)27 Test (org.junit.Test)25 HashMap (java.util.HashMap)24 DateTime (org.joda.time.DateTime)10 DateUtil.newDateTime (org.motechproject.commons.date.util.DateUtil.newDateTime)10 JobBasicInfo (org.motechproject.scheduler.contract.JobBasicInfo)8 RepeatingSchedulableJob (org.motechproject.scheduler.contract.RepeatingSchedulableJob)4 RunOnceSchedulableJob (org.motechproject.scheduler.contract.RunOnceSchedulableJob)4 JobKey (org.quartz.JobKey)3 Time (org.motechproject.commons.date.model.Time)2 CronJobId (org.motechproject.scheduler.contract.CronJobId)2 JobsSearchSettings (org.motechproject.scheduler.contract.JobsSearchSettings)2 ArrayList (java.util.ArrayList)1 Period (org.joda.time.Period)1 Before (org.junit.Before)1 DayOfWeekSchedulableJob (org.motechproject.scheduler.contract.DayOfWeekSchedulableJob)1 RepeatingPeriodSchedulableJob (org.motechproject.scheduler.contract.RepeatingPeriodSchedulableJob)1 SchedulableJobValidator.validateCronSchedulableJob (org.motechproject.scheduler.validation.SchedulableJobValidator.validateCronSchedulableJob)1 TimeFaker.stopFakingTime (org.motechproject.testing.utils.TimeFaker.stopFakingTime)1