Search in sources :

Example 6 with AuditTaskImpl

use of org.jbpm.services.task.audit.impl.model.AuditTaskImpl in project jbpm by kiegroup.

the class JPATaskLifeCycleEventListener method afterTaskResumedEvent.

@Override
public void afterTaskResumedEvent(TaskEvent event) {
    String userId = event.getTaskContext().getUserId();
    Task ti = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    try {
        persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.RESUMED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId));
        AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
        if (auditTaskImpl == null) {
            logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
            return;
        }
        auditTaskImpl.setDescription(ti.getDescription());
        auditTaskImpl.setName(ti.getName());
        auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
        auditTaskImpl.setPriority(ti.getPriority());
        auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
        auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
        auditTaskImpl.setActualOwner(getActualOwner(ti));
        auditTaskImpl.setLastModificationDate(event.getEventDate());
        persistenceContext.merge(auditTaskImpl);
    } finally {
        cleanup(persistenceContext);
    }
}
Also used : Task(org.kie.api.task.model.Task) TaskEventImpl(org.jbpm.services.task.audit.impl.model.TaskEventImpl) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Example 7 with AuditTaskImpl

use of org.jbpm.services.task.audit.impl.model.AuditTaskImpl in project jbpm by kiegroup.

the class JPATaskLifeCycleEventListener method afterTaskReleasedEvent.

@Override
public void afterTaskReleasedEvent(TaskEvent event) {
    String userId = event.getTaskContext().getUserId();
    Task ti = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    try {
        AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
        if (auditTaskImpl == null) {
            logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
            return;
        }
        auditTaskImpl.setDescription(ti.getDescription());
        auditTaskImpl.setName(ti.getName());
        auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
        auditTaskImpl.setPriority(ti.getPriority());
        auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
        auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
        auditTaskImpl.setActualOwner(getActualOwner(ti));
        auditTaskImpl.setLastModificationDate(event.getEventDate());
        persistenceContext.merge(auditTaskImpl);
    } finally {
        cleanup(persistenceContext);
    }
}
Also used : Task(org.kie.api.task.model.Task) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Example 8 with AuditTaskImpl

use of org.jbpm.services.task.audit.impl.model.AuditTaskImpl in project jbpm by kiegroup.

the class JPATaskLifeCycleEventListener method afterTaskDelegatedEvent.

@Override
public void afterTaskDelegatedEvent(TaskEvent event) {
    String userId = event.getTaskContext().getUserId();
    Task ti = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    try {
        persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.DELEGATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId));
        AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
        if (auditTaskImpl == null) {
            logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
            return;
        }
        auditTaskImpl.setDescription(ti.getDescription());
        auditTaskImpl.setName(ti.getName());
        auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
        auditTaskImpl.setPriority(ti.getPriority());
        auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
        auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
        auditTaskImpl.setActualOwner(getActualOwner(ti));
        auditTaskImpl.setLastModificationDate(event.getEventDate());
        persistenceContext.merge(auditTaskImpl);
    } finally {
        cleanup(persistenceContext);
    }
}
Also used : Task(org.kie.api.task.model.Task) TaskEventImpl(org.jbpm.services.task.audit.impl.model.TaskEventImpl) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Example 9 with AuditTaskImpl

use of org.jbpm.services.task.audit.impl.model.AuditTaskImpl in project jbpm by kiegroup.

the class JPATaskLifeCycleEventListener method afterTaskFailedEvent.

@Override
public void afterTaskFailedEvent(TaskEvent event) {
    String userId = event.getTaskContext().getUserId();
    Task ti = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    try {
        persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.FAILED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId));
        AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
        if (auditTaskImpl == null) {
            logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
            return;
        }
        auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
        auditTaskImpl.setActualOwner(getActualOwner(ti));
        auditTaskImpl.setLastModificationDate(event.getEventDate());
        persistenceContext.merge(auditTaskImpl);
    } finally {
        cleanup(persistenceContext);
    }
}
Also used : Task(org.kie.api.task.model.Task) TaskEventImpl(org.jbpm.services.task.audit.impl.model.TaskEventImpl) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Example 10 with AuditTaskImpl

use of org.jbpm.services.task.audit.impl.model.AuditTaskImpl in project jbpm by kiegroup.

the class JPATaskLifeCycleEventListener method afterTaskOutputVariableChangedEvent.

@Override
public void afterTaskOutputVariableChangedEvent(TaskEvent event, Map<String, Object> variables) {
    String userId = event.getTaskContext().getUserId();
    Task task = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    // first cleanup previous values if any
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("type", VariableType.OUTPUT);
    params.put("taskId", task.getId());
    int removed = persistenceContext.executeUpdate("DeleteTaskVariableForTask", params);
    logger.debug("Deleted {} output variables logs for task id {}", removed, task.getId());
    if (variables == null || variables.isEmpty()) {
        return;
    }
    indexAndPersistVariables(task, variables, persistenceContext, VariableType.OUTPUT);
    String message = "Task output data updated";
    persistenceContext.persist(new TaskEventImpl(task.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, task.getTaskData().getProcessInstanceId(), task.getTaskData().getWorkItemId(), userId, message));
    AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, task);
    if (auditTaskImpl == null) {
        logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", task.getId(), task.getName());
        return;
    }
    auditTaskImpl.setLastModificationDate(event.getEventDate());
    persistenceContext.merge(auditTaskImpl);
}
Also used : Task(org.kie.api.task.model.Task) HashMap(java.util.HashMap) TaskEventImpl(org.jbpm.services.task.audit.impl.model.TaskEventImpl) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Aggregations

AuditTaskImpl (org.jbpm.services.task.audit.impl.model.AuditTaskImpl)19 Task (org.kie.api.task.model.Task)19 TaskPersistenceContext (org.kie.internal.task.api.TaskPersistenceContext)18 TaskEventImpl (org.jbpm.services.task.audit.impl.model.TaskEventImpl)17 Date (java.util.Date)3 HashMap (java.util.HashMap)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)1 DeleteAuditEventsCommand (org.jbpm.services.task.audit.commands.DeleteAuditEventsCommand)1 DeleteBAMTaskSummariesCommand (org.jbpm.services.task.audit.commands.DeleteBAMTaskSummariesCommand)1 GetAuditEventsCommand (org.jbpm.services.task.audit.commands.GetAuditEventsCommand)1 GetBAMTaskSummariesCommand (org.jbpm.services.task.audit.commands.GetBAMTaskSummariesCommand)1 BAMTaskSummaryImpl (org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl)1 TaskIndexerManager (org.jbpm.services.task.audit.variable.TaskIndexerManager)1 TaskLifeCycleEventListener (org.jbpm.services.task.lifecycle.listeners.TaskLifeCycleEventListener)1 PersistableEventListener (org.jbpm.services.task.persistence.PersistableEventListener)1