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(); }