use of org.motechproject.scheduler.contract.RepeatingJobId in project motech by motech.
the class MotechSchedulerServiceImpl method safeScheduleRepeatingPeriodJob.
@Override
public void safeScheduleRepeatingPeriodJob(RepeatingPeriodSchedulableJob repeatingPeriodSchedulableJob) {
logObjectIfNotNull(repeatingPeriodSchedulableJob);
assertArgumentNotNull(repeatingPeriodSchedulableJob);
JobId jobId = new RepeatingJobId(repeatingPeriodSchedulableJob.getMotechEvent());
try {
unscheduleJob(jobId);
} catch (MotechSchedulerException e) {
LOGGER.error("Unable to unschedule repeating job with id {}", jobId.value(), e);
}
scheduleRepeatingPeriodJob(repeatingPeriodSchedulableJob);
}
use of org.motechproject.scheduler.contract.RepeatingJobId in project motech by motech.
the class MotechSchedulerServiceImpl method safeScheduleRepeatingJob.
@Override
public void safeScheduleRepeatingJob(RepeatingSchedulableJob repeatingSchedulableJob) {
logObjectIfNotNull(repeatingSchedulableJob);
assertArgumentNotNull(repeatingSchedulableJob);
JobId jobId = new RepeatingJobId(repeatingSchedulableJob.getMotechEvent());
try {
unscheduleJob(jobId);
} catch (MotechSchedulerException e) {
LOGGER.error("Unable to unschedule repeating job with ID {}", jobId.value(), e);
}
scheduleRepeatingJob(repeatingSchedulableJob);
}
use of org.motechproject.scheduler.contract.RepeatingJobId in project motech by motech.
the class JobIdTest method initializeUsingMotechEvent.
@Test
public void initializeUsingMotechEvent() {
MotechEvent motechEvent = new MotechEvent(SUBJECT_VALUE);
motechEvent.getParameters().put(MotechSchedulerService.JOB_ID_KEY, JOB_ID_VALUE);
JobId jobId = new CronJobId(motechEvent);
assertEquals(String.format("%s-%s", SUBJECT_VALUE, JOB_ID_VALUE), jobId.value());
jobId = new RepeatingJobId(motechEvent);
assertEquals(String.format("%s-%s%s", SUBJECT_VALUE, JOB_ID_VALUE, RepeatingJobId.SUFFIX_REPEATJOBID), jobId.value());
}
use of org.motechproject.scheduler.contract.RepeatingJobId in project motech by motech.
the class MotechSchedulerListener method handleUnscheduleRepeatingJobEvent.
/**
* Handles the motech event unscheduling an existing repeating job.
*
* @param event the event to be handled
*/
@MotechListener(subjects = { UNSCHEDULE_REPEATING_JOB })
public void handleUnscheduleRepeatingJobEvent(MotechEvent event) {
Map<String, Object> metadata = event.getMetadata();
String jobSubject = (String) metadata.get(JOB_SUBJECT);
MotechEvent jobEvent = new MotechEvent(jobSubject, null);
JobId jobId = new RepeatingJobId(jobEvent);
schedulerService.unscheduleJob(jobId);
}
use of org.motechproject.scheduler.contract.RepeatingJobId in project motech by motech.
the class JobIdTest method repeatingId.
@Test
public void repeatingId() {
JobId jobId = new RepeatingJobId(SUBJECT_VALUE, JOB_ID_VALUE);
assertEquals(String.format("%s-%s%s", SUBJECT_VALUE, JOB_ID_VALUE, RepeatingJobId.SUFFIX_REPEATJOBID), jobId.value());
}
Aggregations