示例#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
  @Override
  public Void execute(Context context) {
    TaskContext ctx = (TaskContext) context;
    if (notificationListener == null) {
      this.notificationListener =
          new EmailNotificationListener((UserInfo) context.get(EnvironmentName.TASK_USER_INFO));
    }

    TaskPersistenceContext persistenceContext = ctx.getPersistenceContext();

    try {
      Task task = persistenceContext.findTask(taskId);
      TaskData taskData = task.getTaskData();

      List<DeadlineSummaryImpl> resultList = null;
      resultList = getAlldeadlines(persistenceContext, taskData);

      if (resultList == null || resultList.size() == 0) {
        if (taskData.getActualOwner() == 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())) {
            logger.debug("Sending an Email");
            Map<String, Object> variables = getVariables(ctx, persistenceContext, task, taskData);
            Notification notification = buildDefaultNotification(taskData, task);
            notificationListener.onNotification(
                new NotificationEvent(notification, task, variables));
          }
        }
      } else {
        for (DeadlineSummaryImpl deadlineSummaryImpl : resultList) {
          executedeadLine(ctx, persistenceContext, task, deadlineSummaryImpl, taskData);
        }
      }
    } catch (Exception e) {

      logger.error("Error when executing deadlines", e);
    }
    return null;
  }