Search in sources :

Example 1 with TaskEventImpl

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

the class JPATaskLifeCycleEventListener method afterTaskStoppedEvent.

@Override
public void afterTaskStoppedEvent(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.STOPPED, 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.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 2 with TaskEventImpl

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

the class JPATaskLifeCycleEventListener method afterTaskActivatedEvent.

@Override
public void afterTaskActivatedEvent(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.ACTIVATED, 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.setDescription(ti.getDescription());
        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 3 with TaskEventImpl

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

the class JPATaskLifeCycleEventListener method afterTaskNominatedEvent.

@Override
public void afterTaskNominatedEvent(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.NOMINATED, userId, new Date()));
        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) Date(java.util.Date) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTaskImpl(org.jbpm.services.task.audit.impl.model.AuditTaskImpl)

Example 4 with TaskEventImpl

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

the class JPATaskLifeCycleEventListener method afterTaskSkippedEvent.

@Override
public void afterTaskSkippedEvent(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.SKIPPED, 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.setDescription(ti.getDescription());
        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 5 with TaskEventImpl

use of org.jbpm.services.task.audit.impl.model.TaskEventImpl 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)

Aggregations

TaskEventImpl (org.jbpm.services.task.audit.impl.model.TaskEventImpl)19 Task (org.kie.api.task.model.Task)19 TaskPersistenceContext (org.kie.internal.task.api.TaskPersistenceContext)19 AuditTaskImpl (org.jbpm.services.task.audit.impl.model.AuditTaskImpl)18 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 TaskIndexerManager (org.jbpm.services.task.audit.variable.TaskIndexerManager)2 TaskLifeCycleEventListener (org.jbpm.services.task.lifecycle.listeners.TaskLifeCycleEventListener)2 PersistableEventListener (org.jbpm.services.task.persistence.PersistableEventListener)2 ClassUtil (org.jbpm.services.task.utils.ClassUtil)2 TaskEvent (org.kie.api.task.TaskEvent)2 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)2 TaskContext (org.kie.internal.task.api.TaskContext)2 TaskVariable (org.kie.internal.task.api.TaskVariable)2 VariableType (org.kie.internal.task.api.TaskVariable.VariableType)2