Пример #1
0
  private Void executedeadLine(
      TaskContext ctx,
      TaskPersistenceContext persistenceContext,
      Task task,
      DeadlineSummaryImpl deadlineSummaryImpl,
      TaskData taskData) {
    Deadline deadline = persistenceContext.findDeadline(deadlineSummaryImpl.getDeadlineId());
    if (task == null || deadline == null) {
      return null;
    }

    if (taskData != null) {
      // check if task is still in valid status
      if (DeadlineType.START.isValidStatus(taskData.getStatus())
          || DeadlineType.END.isValidStatus(taskData.getStatus())) {
        Map<String, Object> variables = getVariables(ctx, persistenceContext, task, taskData);
        if (deadline == null || deadline.getEscalations() == null) {
          return null;
        }

        for (Escalation escalation : deadline.getEscalations()) {
          for (Notification notification : escalation.getNotifications()) {
            if (notification.getNotificationType() == NotificationType.Email) {
              logger.debug("Sending an Email");
              notificationListener.onNotification(
                  new NotificationEvent(notification, task, variables));
            }
          }
        }
      }
    }
    return null;
  }
Пример #2
0
  @PostConstruct
  public void init() {
    // make sure it has tx manager as it runs as background thread - no request scope available
    if (!((JbpmServicesPersistenceManagerImpl) pm).hasTransactionManager()) {
      ((JbpmServicesPersistenceManagerImpl) pm)
          .setTransactionManager(new JbpmJTATransactionManager());
    }

    long now = System.currentTimeMillis();
    List<DeadlineSummaryImpl> resultList =
        (List<DeadlineSummaryImpl>) pm.queryInTransaction("UnescalatedStartDeadlines");
    for (DeadlineSummaryImpl summary : resultList) {
      long delay = summary.getDate().getTime() - now;
      schedule(summary.getTaskId(), summary.getDeadlineId(), delay, DeadlineType.START);
    }

    resultList = (List<DeadlineSummaryImpl>) pm.queryInTransaction("UnescalatedEndDeadlines");
    for (DeadlineSummaryImpl summary : resultList) {
      long delay = summary.getDate().getTime() - now;
      schedule(summary.getTaskId(), summary.getDeadlineId(), delay, DeadlineType.END);
    }
  }