Search in sources :

Example 36 with TaskPersistenceContext

use of org.kie.internal.task.api.TaskPersistenceContext 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 37 with TaskPersistenceContext

use of org.kie.internal.task.api.TaskPersistenceContext 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)

Example 38 with TaskPersistenceContext

use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.

the class DeleteAuditEventsCommand method execute.

@Override
public Void execute(Context context) {
    TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
    if (this.taskId != null) {
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("taskId", this.taskId);
        persistenceContext.executeUpdate("deleteTaskEventsForTask", params);
    } else {
        persistenceContext.executeUpdate("deleteAllTaskEvents", null);
    }
    return null;
}
Also used : TaskContext(org.kie.internal.task.api.TaskContext) HashMap(java.util.HashMap) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext)

Example 39 with TaskPersistenceContext

use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.

the class DeleteBAMTaskSummariesCommand method execute.

@Override
public Void execute(Context context) {
    TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
    if (this.taskId != null) {
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("taskId", this.taskId);
        persistenceContext.executeUpdate("deleteBAMTaskSummariesForTask", params);
    } else {
        persistenceContext.executeUpdate("deleteAllBAMTaskSummaries", null);
    }
    return null;
}
Also used : TaskContext(org.kie.internal.task.api.TaskContext) HashMap(java.util.HashMap) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext)

Example 40 with TaskPersistenceContext

use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.

the class GetAllAdminAuditTasksByUserCommand method execute.

@Override
public List<AuditTask> execute(Context context) {
    TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
    boolean userExists = doCallbackUserOperation(userId, (TaskContext) context);
    List<String> groupIds = doUserGroupCallbackOperation(userId, null, (TaskContext) context);
    // Adding the user to check for groups and user as Business Administrators
    groupIds.add(userId);
    List<AuditTask> groupTasks = persistenceContext.queryWithParametersInTransaction("getAllAdminAuditTasksByUser", persistenceContext.addParametersToMap("businessAdmins", groupIds, "firstResult", filter.getOffset(), "maxResults", filter.getCount()), ClassUtil.<List<AuditTask>>castClass(List.class));
    return groupTasks;
}
Also used : TaskContext(org.kie.internal.task.api.TaskContext) List(java.util.List) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) AuditTask(org.kie.internal.task.api.AuditTask)

Aggregations

TaskPersistenceContext (org.kie.internal.task.api.TaskPersistenceContext)48 Task (org.kie.api.task.model.Task)31 AuditTaskImpl (org.jbpm.services.task.audit.impl.model.AuditTaskImpl)19 TaskEventImpl (org.jbpm.services.task.audit.impl.model.TaskEventImpl)19 List (java.util.List)14 HashMap (java.util.HashMap)13 TaskContext (org.kie.internal.task.api.TaskContext)9 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 TaskContext (org.jbpm.services.task.commands.TaskContext)7 TaskEventSupport (org.jbpm.services.task.events.TaskEventSupport)5 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)5 TaskContext (org.kie.api.task.TaskContext)5 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Date (java.util.Date)4 ClassUtil (org.jbpm.services.task.utils.ClassUtil)4 Content (org.kie.api.task.model.Content)4 Status (org.kie.api.task.model.Status)4