@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ScheduledTaskDeadline)) { return false; } ScheduledTaskDeadline other = (ScheduledTaskDeadline) obj; if (deadlineId != other.deadlineId) { return false; } if (taskId != other.taskId) { return false; } if (type == null) { if (other.getType() != null) { return false; } } else if (type.equals(other.getType())) { return false; } return true; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (deadlineId ^ (deadlineId >>> 32)); result = prime * result + (int) (taskId ^ (taskId >>> 32)); result = prime * result + type.hashCode(); return result; }
private void executeEscalatedDeadline(long taskId, long deadlineId, DeadlineType type) { // 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()); } TaskImpl task = (TaskImpl) pm.find(TaskImpl.class, taskId); Deadline deadline = (DeadlineImpl) pm.find(DeadlineImpl.class, deadlineId); TaskData taskData = task.getTaskData(); if (taskData != null) { // check if task is still in valid status if (type.isValidStatus(taskData.getStatus())) { Map<String, Object> variables = null; ContentImpl content = (ContentImpl) pm.find(ContentImpl.class, taskData.getDocumentContentId()); if (content != null) { Object objectFromBytes = ContentMarshallerHelper.unmarshall( content.getContent(), getEnvironment(), getClassLoader()); if (objectFromBytes instanceof Map) { variables = (Map) objectFromBytes; } else { variables = new HashMap<String, Object>(); variables.put("content", objectFromBytes); } } else { variables = Collections.emptyMap(); } if (deadline == null || deadline.getEscalations() == null) { return; } for (Escalation escalation : deadline.getEscalations()) { // we won't impl constraints for now // escalation.getConstraints() // run reassignment first to allow notification to be send to new potential owners if (!escalation.getReassignments().isEmpty()) { // get first and ignore the rest. Reassignment reassignment = escalation.getReassignments().get(0); task.getTaskData().setStatus(Status.Ready); List potentialOwners = new ArrayList(reassignment.getPotentialOwners()); task.getPeopleAssignments().setPotentialOwners(potentialOwners); task.getTaskData().setActualOwner(null); } for (Notification notification : escalation.getNotifications()) { if (notification.getNotificationType() == NotificationType.Email) { logger.log(Level.INFO, " ### Sending an Email"); notificationEvents.fire(new NotificationEvent(notification, task, variables)); } } } } } deadline.setEscalated(true); }