Search in sources :

Example 16 with AuditTaskImpl

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

the class JPATaskLifeCycleEventListener method afterTaskReassignedEvent.

@Override
public void afterTaskReassignedEvent(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 17 with AuditTaskImpl

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

the class JPATaskLifeCycleEventListener method afterTaskForwardedEvent.

@Override
public void afterTaskForwardedEvent(TaskEvent event) {
    String userId = event.getTaskContext().getUserId();
    Task ti = event.getTask();
    TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
    try {
        StringBuilder message = new StringBuilder();
        String entitiesAsString = (ti.getPeopleAssignments().getPotentialOwners()).stream().map(oe -> oe.getId()).collect(Collectors.joining(","));
        message.append("Forward to [" + entitiesAsString + "]");
        persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.FORWARDED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message.toString()));
        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 : PersistableEventListener(org.jbpm.services.task.persistence.PersistableEventListener) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Task(org.kie.api.task.model.Task) Date(java.util.Date) TaskVariable(org.kie.internal.task.api.TaskVariable) TaskEventImpl(org.jbpm.services.task.audit.impl.model.TaskEventImpl) VariableType(org.kie.internal.task.api.TaskVariable.VariableType) LoggerFactory(org.slf4j.LoggerFactory) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl) HashMap(java.util.HashMap) ClassUtil(org.jbpm.services.task.utils.ClassUtil) Collectors(java.util.stream.Collectors) TaskLifeCycleEventListener(org.jbpm.services.task.lifecycle.listeners.TaskLifeCycleEventListener) TaskEvent(org.kie.api.task.TaskEvent) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskIndexerManager(org.jbpm.services.task.audit.variable.TaskIndexerManager) List(java.util.List) TaskContext(org.kie.internal.task.api.TaskContext) EntityManagerFactory(javax.persistence.EntityManagerFactory) Map(java.util.Map) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) 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 18 with AuditTaskImpl

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

the class JPATaskLifeCycleEventListener method afterTaskSuspendedEvent.

@Override
public void afterTaskSuspendedEvent(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.SUSPENDED, 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 19 with AuditTaskImpl

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

the class JPATaskLifeCycleEventListener method afterTaskExitedEvent.

@Override
public void afterTaskExitedEvent(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.EXITED, 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)

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