use of org.quartz.TriggerKey in project syncope by apache.
the class ReportDataBinderImpl method getReportTO.
@Override
public ReportTO getReportTO(final Report report) {
ReportTO reportTO = new ReportTO();
reportTO.setKey(report.getKey());
reportTO.setTemplate(report.getTemplate().getKey());
BeanUtils.copyProperties(report, reportTO, IGNORE_REPORT_PROPERTIES);
reportTO.getReportlets().addAll(report.getReportlets().stream().map(Entity::getKey).collect(Collectors.toList()));
ReportExec latestExec = reportExecDAO.findLatestStarted(report);
if (latestExec == null) {
reportTO.setLatestExecStatus(StringUtils.EMPTY);
} else {
reportTO.setLatestExecStatus(latestExec.getStatus());
reportTO.setStart(latestExec.getStart());
reportTO.setEnd(latestExec.getEnd());
reportTO.setLastExec(reportTO.getStart());
}
reportTO.getExecutions().addAll(report.getExecs().stream().map(reportExec -> getExecTO(reportExec)).collect(Collectors.toList()));
String triggerName = JobNamer.getTriggerName(JobNamer.getJobKey(report).getName());
try {
Trigger trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
if (trigger != null) {
reportTO.setLastExec(trigger.getPreviousFireTime());
reportTO.setNextExec(trigger.getNextFireTime());
}
} catch (SchedulerException e) {
LOG.warn("While trying to get to " + triggerName, e);
}
return reportTO;
}
use of org.quartz.TriggerKey in project syncope by apache.
the class JobManagerImpl method unregisterJob.
private void unregisterJob(final String jobName) {
try {
scheduler.getScheduler().unscheduleJob(new TriggerKey(jobName, Scheduler.DEFAULT_GROUP));
scheduler.getScheduler().deleteJob(new JobKey(jobName, Scheduler.DEFAULT_GROUP));
} catch (SchedulerException e) {
LOG.error("Could not remove job " + jobName, e);
}
if (ApplicationContextProvider.getBeanFactory().containsSingleton(jobName)) {
ApplicationContextProvider.getBeanFactory().destroySingleton(jobName);
}
}
use of org.quartz.TriggerKey in project dubidubi by lzzzz4.
the class QuartzSessionValidationScheduler method disableSessionValidation.
public void disableSessionValidation() {
if (log.isDebugEnabled()) {
log.debug("Stopping Quartz session validation job...");
}
Scheduler scheduler;
try {
scheduler = getScheduler();
if (scheduler == null) {
if (log.isWarnEnabled()) {
log.warn("getScheduler() method returned a null Quartz scheduler, which is unexpected. Please check your configuration and/or implementation. Returning quietly since there is no validation job to remove (scheduler does not exist).");
}
return;
}
} catch (SchedulerException e) {
if (log.isWarnEnabled()) {
log.warn("Unable to acquire Quartz Scheduler. Ignoring and returning (already stopped?)", e);
}
return;
}
try {
scheduler.unscheduleJob(new TriggerKey("SessionValidationJob", "DEFAULT"));
if (log.isDebugEnabled())
log.debug("Quartz session validation job stopped successfully.");
} catch (SchedulerException e) {
if (log.isDebugEnabled()) {
log.debug("Could not cleanly remove SessionValidationJob from Quartz scheduler. Ignoring and stopping.", e);
}
}
this.enabled = false;
if (this.schedulerImplicitlyCreated)
try {
scheduler.shutdown();
} catch (SchedulerException e) {
if (log.isWarnEnabled())
log.warn("Unable to cleanly shutdown implicitly created Quartz Scheduler instance.", e);
} finally {
setScheduler(null);
this.schedulerImplicitlyCreated = false;
}
}
use of org.quartz.TriggerKey in project OpenOLAT by OpenOLAT.
the class ViteroModule method initCronJob.
private void initCronJob() {
try {
TriggerKey triggerKey = new TriggerKey("Vitero_Cleaner_Cron_Trigger", Scheduler.DEFAULT_GROUP);
if (scheduler.getTrigger(triggerKey) == null) {
// Create job with cron trigger configuration
JobDetail jobDetail = newJob(ViteroZombieSlayerJob.class).withIdentity("Vitero_Cleaner_Cron_Job", Scheduler.DEFAULT_GROUP).build();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 30);
Trigger trigger = newTrigger().withIdentity("Vitero_Cleaner_Cron_Trigger").withSchedule(cronSchedule(cronExpression)).startAt(cal.getTime()).build();
scheduler.scheduleJob(jobDetail, trigger);
}
} catch (Exception e) {
log.error("Cannot start the Quartz Job which clean the Vitero rooms", e);
}
}
use of org.quartz.TriggerKey in project motech by motech.
the class MotechSchedulerServiceImpl method getScheduledJobTimingsWithPrefix.
/*
* Loads all triggers and then loops over them to find the applicable trigger using string comparison. This
* will work regardless of the jobId being cron or repeating.
*/
@Override
public List<DateTime> getScheduledJobTimingsWithPrefix(String subject, String externalJobIdPrefix, DateTime startDate, DateTime endDate) {
JobId jobId = new CronJobId(subject, externalJobIdPrefix);
List<Date> messageTimings = new ArrayList<>();
try {
List<TriggerKey> triggerKeys = new ArrayList<TriggerKey>(scheduler.getTriggerKeys(GroupMatcher.triggerGroupContains(JOB_GROUP_NAME)));
for (TriggerKey triggerKey : triggerKeys) {
if (StringUtils.isNotEmpty(externalJobIdPrefix) && triggerKey.getName().contains(jobId.value())) {
Trigger trigger = scheduler.getTrigger(triggerKey);
messageTimings.addAll(TriggerUtils.computeFireTimesBetween((OperableTrigger) trigger, new BaseCalendar(), DateUtil.toDate(startDate), DateUtil.toDate(endDate)));
}
}
} catch (SchedulerException e) {
throw new MotechSchedulerException(String.format("Can not get scheduled job timings given subject and externalJobIdPrefix for dates : %s %s %s %s %s", subject, externalJobIdPrefix, startDate.toString(), endDate.toString(), e.getMessage()), e);
}
return DateUtil.datesToDateTimes(messageTimings);
}
Aggregations