本文整理汇总了Java中org.quartz.Scheduler.getTriggerKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.getTriggerKeys方法的具体用法?Java Scheduler.getTriggerKeys怎么用?Java Scheduler.getTriggerKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.getTriggerKeys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unscheduleAll
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Remove all schedules matching the given predicate from the current
* scheduler, then from the data base.
*/
private void unscheduleAll(final Predicate<TriggerKey> predicate) throws SchedulerException {
// Remove current schedules from the memory
final Scheduler scheduler = vmSchedulerFactoryBean.getObject();
for (final TriggerKey triggerKey : scheduler.getTriggerKeys(GroupMatcher.groupEquals(SCHEDULE_TRIGGER_GROUP))) {
if (predicate.test(triggerKey)) {
// Match subscription and operation, unschedule this trigger
scheduler.unscheduleJob(triggerKey);
}
}
}
示例2: showScheduledEmails
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Renders a page listing all scheduled emails.
*/
public ActionForward showScheduledEmails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException {
getUserManagementService();
Scheduler scheduler = getScheduler();
TreeSet<EmailScheduleMessageJobDTO> scheduleList = new TreeSet<EmailScheduleMessageJobDTO>();
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(),
"show scheduled lesson email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the lesson");
return null;
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, getCurrentUser().getUserID(),
"show scheduled course email notifications", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the organisation");
return null;
}
}
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(EmailNotificationsAction.TRIGGER_PREFIX_NAME)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// filter triggers
if (isLessonNotifications) {
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if ((jobLessonId == null) || (!lessonId.equals(jobLessonId))) {
continue;
}
} else {
Object jobOrganisationId = jobDataMap.get(AttributeNames.PARAM_ORGANISATION_ID);
if ((jobOrganisationId == null) || (!organisationId.equals(jobOrganisationId))) {
continue;
}
}
Date triggerDate = trigger.getNextFireTime();
String emailBody = WebUtil.convertNewlines((String) jobDataMap.get("emailBody"));
int searchType = (Integer) jobDataMap.get("searchType");
EmailScheduleMessageJobDTO emailScheduleJobDTO = new EmailScheduleMessageJobDTO();
emailScheduleJobDTO.setTriggerName(triggerName);
emailScheduleJobDTO.setTriggerDate(triggerDate);
emailScheduleJobDTO.setEmailBody(emailBody);
emailScheduleJobDTO.setSearchType(searchType);
scheduleList.add(emailScheduleJobDTO);
}
}
request.setAttribute("scheduleList", scheduleList);
request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId);
return mapping.findForward("scheduledEmailList");
}
示例3: getEmailProgressDates
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Gets learners or monitors of the lesson and organisation containing it.
*
* @throws SchedulerException
*/
public ActionForward getEmailProgressDates(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException, SchedulerException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
return null;
}
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
JSONObject responseJSON = new JSONObject();
JSONArray datesJSON = new JSONArray();
// find all the current dates set up to send the emails
Scheduler scheduler = getScheduler();
String triggerPrefix = getTriggerPrefix(lessonId);
SortedSet<Date> currentDatesSet = new TreeSet<Date>();
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.startsWith(triggerPrefix)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
// get only the trigger for the current lesson
Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID);
if (lessonId.equals(jobLessonId)) {
Date triggerDate = trigger.getNextFireTime();
currentDatesSet.add(triggerDate);
}
}
}
for (Date date : currentDatesSet) {
datesJSON.put(createDateJSON(request.getLocale(), user, date, null));
}
responseJSON.put("dates", datesJSON);
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(responseJSON.toString());
return null;
}
示例4: deleteNotification
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Delete a scheduled emails.
*
* @throws JSONException
*/
public ActionForward deleteNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException, JSONException {
String inputTriggerName = WebUtil.readStrParam(request, "triggerName");
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
Integer userId = getCurrentUser().getUserID();
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
IMonitoringService monitoringService = MonitoringServiceProxy
.getMonitoringService(getServlet().getServletContext());
getUserManagementService();
Scheduler scheduler = getScheduler();
JSONObject jsonObject = new JSONObject();
String error = null;
try {
// if this method throws an Exception, there will be no deleteNotification=true in the JSON reply
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, userId, "show scheduled lesson email notifications",
false)) {
error = "Unable to delete notification: the user is not a monitor in the lesson";
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, userId,
"show scheduled course course email notifications", false)) {
error = "Unable to delete notification: the user is not a monitor in the organisation";
}
}
if (error == null) {
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.equals(inputTriggerName)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobKey jobKey = trigger.getJobKey();
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME,
"Deleting unsent scheduled notification " + jobKey + " "
+ jobDataMap.getString("emailBody"));
scheduler.deleteJob(jobKey);
}
}
}
} catch (Exception e) {
String[] msg = new String[1];
msg[0] = e.getMessage();
error = monitoringService.getMessageService().getMessage("error.system.error", msg);
}
jsonObject.put("deleteNotification", error == null ? "true" : error);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(jsonObject);
return null;
}
示例5: updateEmailProgressDate
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Add or remove a date for the email progress
*/
public ActionForward updateEmailProgressDate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
return null;
}
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
// as we are using ms since UTC 0 calculated on the client, this will be correctly set up as server date
// and does not need changing (assuming the user's LAMS timezone matches the user's computer timezone).
long dateId = WebUtil.readLongParam(request, "id");
Date newDate = new Date(dateId);
boolean add = WebUtil.readBooleanParam(request, "add");
// calculate scheduleDate
String scheduledTriggerName = getTriggerName(lessonId, newDate);
JSONObject dateJSON = null;
try {
Scheduler scheduler = getScheduler();
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher
.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
Trigger trigger = null;
for (TriggerKey triggerKey : triggerKeys) {
if (scheduledTriggerName.equals(triggerKey.getName())) {
trigger = scheduler.getTrigger(triggerKey);
break;
}
}
if (add) {
if (trigger == null) {
String desc = new StringBuilder("Send progress email. Lesson ")
.append(lessonId).append(" on ").append(newDate).toString();
// build job detail based on the bean class
JobDetail EmailProgressMessageJob = JobBuilder.newJob(EmailProgressMessageJob.class)
.withIdentity(getJobName(lessonId, newDate))
.withDescription(desc)
.usingJobData(AttributeNames.PARAM_LESSON_ID, lessonId).build();
// create customized triggers
Trigger startLessonTrigger = TriggerBuilder.newTrigger().withIdentity(scheduledTriggerName)
.startAt(newDate).build();
// start the scheduling job
scheduler.scheduleJob(EmailProgressMessageJob, startLessonTrigger);
dateJSON = createDateJSON(request.getLocale(), user, newDate, "added");
} else {
dateJSON = createDateJSON(request.getLocale(), user, newDate, "none");
}
} else if (!add) {
if (trigger != null) {
// remove trigger
scheduler.deleteJob(trigger.getJobKey());
dateJSON = createDateJSON(request.getLocale(), user, null, "deleted");
} else {
dateJSON = createDateJSON(request.getLocale(), user, null, "none");
}
}
} catch (SchedulerException e) {
LamsDispatchAction.log.error("Error occurred at " + "[EmailProgressAction]- fail to email scheduling", e);
}
if (dateJSON != null) {
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(dateJSON.toString());
}
return null;
}