コード例 #1
0
  public void executeEscalatedDeadline(
      Task task, Deadline deadline, EntityManager em, TaskService service) {
    if (deadline == null || deadline.getEscalations() == null) {
      return;
    }

    for (Escalation escalation : deadline.getEscalations()) {
      // we won't impl constraints for now
      // escalation.getConstraints()
      String language = "es_CL";
      for (Notification notification : escalation.getNotifications()) {
        if (notification.getNotificationType() == NotificationType.Email) {
          executeEmailNotification((EmailNotification) notification, task, em);
        }
      }

      if (!escalation.getReassignments().isEmpty()) {
        // get first and ignore the rest.
        Reassignment reassignment = escalation.getReassignments().get(0);
        em.getTransaction().begin();
        task.getTaskData().setStatus(Status.Ready);
        List potentialOwners = new ArrayList(reassignment.getPotentialOwners());
        task.getPeopleAssignments().setPotentialOwners(potentialOwners);
        em.getTransaction().commit();
      }
    }
    em.getTransaction().begin();
    deadline.setEscalated(true);
    em.getTransaction().commit();
  }
コード例 #2
0
  private void doCallbackOperationForTaskDeadlines(Deadlines deadlines) {
    if (deadlines != null) {
      if (deadlines.getStartDeadlines() != null) {
        List<Deadline> startDeadlines = deadlines.getStartDeadlines();
        for (Deadline startDeadline : startDeadlines) {
          List<Escalation> escalations = startDeadline.getEscalations();
          if (escalations != null) {
            for (Escalation escalation : escalations) {
              List<Notification> notifications = escalation.getNotifications();
              List<Reassignment> ressignments = escalation.getReassignments();
              if (notifications != null) {
                for (Notification notification : notifications) {
                  List<OrganizationalEntity> recipients = notification.getRecipients();
                  if (recipients != null) {
                    for (OrganizationalEntity recipient : recipients) {
                      if (recipient instanceof User) {
                        doCallbackUserOperation(recipient.getId());
                      }
                      if (recipient instanceof Group) {
                        doCallbackGroupOperation(recipient.getId());
                      }
                    }
                  }
                  List<OrganizationalEntity> administrators =
                      notification.getBusinessAdministrators();
                  if (administrators != null) {
                    for (OrganizationalEntity administrator : administrators) {
                      if (administrator instanceof User) {
                        doCallbackUserOperation(administrator.getId());
                      }
                      if (administrator instanceof Group) {
                        doCallbackGroupOperation(administrator.getId());
                      }
                    }
                  }
                }
              }
              if (ressignments != null) {
                for (Reassignment reassignment : ressignments) {
                  List<OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners();
                  if (potentialOwners != null) {
                    for (OrganizationalEntity potentialOwner : potentialOwners) {
                      if (potentialOwner instanceof User) {
                        doCallbackUserOperation(potentialOwner.getId());
                      }
                      if (potentialOwner instanceof Group) {
                        doCallbackGroupOperation(potentialOwner.getId());
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }

      if (deadlines.getEndDeadlines() != null) {
        List<Deadline> endDeadlines = deadlines.getEndDeadlines();
        for (Deadline endDeadline : endDeadlines) {
          List<Escalation> escalations = endDeadline.getEscalations();
          if (escalations != null) {
            for (Escalation escalation : escalations) {
              List<Notification> notifications = escalation.getNotifications();
              List<Reassignment> ressignments = escalation.getReassignments();
              if (notifications != null) {
                for (Notification notification : notifications) {
                  List<OrganizationalEntity> recipients = notification.getRecipients();
                  if (recipients != null) {
                    for (OrganizationalEntity recipient : recipients) {
                      if (recipient instanceof User) {
                        doCallbackUserOperation(recipient.getId());
                      }
                      if (recipient instanceof Group) {
                        doCallbackGroupOperation(recipient.getId());
                      }
                    }
                  }
                  List<OrganizationalEntity> administrators =
                      notification.getBusinessAdministrators();
                  if (administrators != null) {
                    for (OrganizationalEntity administrator : administrators) {
                      if (administrator instanceof User) {
                        doCallbackUserOperation(administrator.getId());
                      }
                      if (administrator instanceof Group) {
                        doCallbackGroupOperation(administrator.getId());
                      }
                    }
                  }
                }
              }
              if (ressignments != null) {
                for (Reassignment reassignment : ressignments) {
                  List<OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners();
                  if (potentialOwners != null) {
                    for (OrganizationalEntity potentialOwner : potentialOwners) {
                      if (potentialOwner instanceof User) {
                        doCallbackUserOperation(potentialOwner.getId());
                      }
                      if (potentialOwner instanceof Group) {
                        doCallbackGroupOperation(potentialOwner.getId());
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }