AsyncTaskLifeCycleEventProducer extends PersistableEventListener implements TaskLifeCycleEventListener { @Override public void afterTaskUpdatedEvent(TaskEvent event) { String userId = event.getTaskContext().getUserId(); Task ti = event.getTask(); List<TaskEventImpl> taskEvents = new ArrayList<>(); TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext)event.getTaskContext()).getPersistenceContext()); try { AuditTaskImpl auditTaskImpl = getAuditTask(persistenceContext, ti); if((ti.getDescription() != null && !ti.getDescription().equals(auditTaskImpl.getDescription())) || (ti.getDescription() == null && auditTaskImpl.getDescription() != null)){ String message = getUpdateFieldLog("Description", auditTaskImpl.getDescription(), ti.getDescription()); TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message); taskEvents.add(taskEvent); } if( (ti.getName() != null && !ti.getName().equals(auditTaskImpl.getName())) || (ti.getName() == null && auditTaskImpl.getName() != null)){ String message = getUpdateFieldLog("Name", auditTaskImpl.getName(), ti.getName()); TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message); taskEvents.add(taskEvent); } if( auditTaskImpl.getPriority() != ti.getPriority()){ String message = getUpdateFieldLog("Priority", String.valueOf(auditTaskImpl.getPriority()), String.valueOf(ti.getPriority())); TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message); taskEvents.add(taskEvent); } if((auditTaskImpl.getDueDate() != null && ti.getTaskData().getExpirationTime() != null && auditTaskImpl.getDueDate().getTime() != ti.getTaskData().getExpirationTime().getTime()) || (auditTaskImpl.getDueDate() == null && ti.getTaskData().getExpirationTime() != null) || (auditTaskImpl.getDueDate() != null && ti.getTaskData().getExpirationTime() == null)){ String fromDate = (auditTaskImpl.getDueDate() != null ? new Date(auditTaskImpl.getDueDate().getTime()).toString(): null); String toDate = (ti.getTaskData().getExpirationTime()!= null ? ti.getTaskData().getExpirationTime().toString() : "" ); String message = getUpdateFieldLog( "DueDate", fromDate, toDate ); TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message); taskEvents.add(taskEvent); } auditTaskImpl.setDescription(ti.getDescription()); auditTaskImpl.setName(ti.getName()); auditTaskImpl.setPriority(ti.getPriority()); auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime()); auditTaskImpl.setLastModificationDate(event.getEventDate()); sendMessage(new AuditTaskData(auditTaskImpl, taskEvents), 4); } finally { cleanup(persistenceContext); } } AsyncTaskLifeCycleEventProducer(); ConnectionFactory getConnectionFactory(); void setConnectionFactory(ConnectionFactory connectionFactory); Queue getQueue(); void setQueue(Queue queue); boolean isTransacted(); void setTransacted(boolean transacted); @Override void afterTaskStartedEvent(TaskEvent event); @Override void afterTaskActivatedEvent(TaskEvent event); @Override void afterTaskClaimedEvent(TaskEvent event); @Override void afterTaskSkippedEvent(TaskEvent event); @Override void afterTaskStoppedEvent(TaskEvent event); @Override void afterTaskCompletedEvent(TaskEvent event); @Override void afterTaskFailedEvent(TaskEvent event); @Override void afterTaskAddedEvent(TaskEvent event); @Override void afterTaskExitedEvent(TaskEvent event); @Override void afterTaskReleasedEvent(TaskEvent event); @Override void afterTaskResumedEvent(TaskEvent event); @Override void afterTaskSuspendedEvent(TaskEvent event); @Override void afterTaskForwardedEvent(TaskEvent event); @Override void afterTaskDelegatedEvent(TaskEvent event); @Override void afterTaskNominatedEvent(TaskEvent event); @Override void beforeTaskReleasedEvent(TaskEvent event); @Override void afterTaskUpdatedEvent(TaskEvent event); @Override void afterTaskReassignedEvent(TaskEvent event); @Override void afterTaskOutputVariableChangedEvent(TaskEvent event, Map<String, Object> variables); @Override void afterTaskInputVariableChangedEvent(TaskEvent event, Map<String, Object> variables); @Override void afterTaskAssignmentsAddedEvent(TaskEvent event, AssignmentType type, List<OrganizationalEntity> entities); @Override void afterTaskAssignmentsRemovedEvent(TaskEvent event, AssignmentType type, List<OrganizationalEntity> entities); @Override void beforeTaskActivatedEvent(TaskEvent event); @Override void beforeTaskClaimedEvent(TaskEvent event); @Override void beforeTaskSkippedEvent(TaskEvent event); @Override void beforeTaskStartedEvent(TaskEvent event); @Override void beforeTaskStoppedEvent(TaskEvent event); @Override void beforeTaskCompletedEvent(TaskEvent event); @Override void beforeTaskFailedEvent(TaskEvent event); @Override void beforeTaskAddedEvent(TaskEvent event); @Override void beforeTaskExitedEvent(TaskEvent event); @Override void beforeTaskResumedEvent(TaskEvent event); @Override void beforeTaskSuspendedEvent(TaskEvent event); @Override void beforeTaskForwardedEvent(TaskEvent event); @Override void beforeTaskDelegatedEvent(TaskEvent event); @Override void beforeTaskNominatedEvent(TaskEvent event); @Override void beforeTaskUpdatedEvent(TaskEvent event); @Override void beforeTaskReassignedEvent(TaskEvent event); @Override void beforeTaskNotificationEvent(TaskEvent event); @Override void afterTaskNotificationEvent(TaskEvent event); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testAfterTaskUpdated() throws JMSException { logProducer.afterTaskUpdatedEvent(event); assertMessage("<type>UPDATED</type>", 4); }