Search in sources :

Example 41 with TaskPersistenceContext

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

the class GetAllAuditTasksByStatusCommand method execute.

@Override
public List<AuditTask> execute(Context context) {
    TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
    List<AuditTask> groupTasks = persistenceContext.queryWithParametersInTransaction("getAllAuditTasksByStatus", persistenceContext.addParametersToMap("owner", userId, "statuses", filter.getParams().get("statuses"), "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)

Example 42 with TaskPersistenceContext

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

the class GetAllGroupAuditTasksByUserCommand 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);
    groupIds.add(userId);
    List<AuditTask> groupTasks = persistenceContext.queryWithParametersInTransaction("getAllGroupAuditTasksByUser", persistenceContext.addParametersToMap("potentialOwners", 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)

Example 43 with TaskPersistenceContext

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

the class GetTasksByVariableNameCommand method execute.

public List<TaskSummary> execute(Context cntxt) {
    TaskContext context = (TaskContext) cntxt;
    doCallbackUserOperation(userId, context);
    if (statuses == null) {
        statuses = new ArrayList<Status>();
        statuses.add(Status.Ready);
        statuses.add(Status.InProgress);
        statuses.add(Status.Reserved);
    }
    if (groupIds == null) {
        groupIds = doUserGroupCallbackOperation(userId, null, context);
        if (groupIds == null) {
            groupIds = new ArrayList<String>();
        }
    }
    TaskPersistenceContext persistenceContext = context.getPersistenceContext();
    List<TaskSummary> tasks = (List<TaskSummary>) persistenceContext.queryWithParametersInTransaction("TasksByStatusByVariableName", persistenceContext.addParametersToMap("userId", userId, "groupIds", groupIds, "variableName", variableName, "status", statuses), ClassUtil.<List<TaskSummary>>castClass(List.class));
    return tasks;
}
Also used : Status(org.kie.api.task.model.Status) TaskContext(org.jbpm.services.task.commands.TaskContext) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) List(java.util.List) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext)

Example 44 with TaskPersistenceContext

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

the class TaskCountLoadCalculator method getUserTaskLoad.

@Override
public UserTaskLoad getUserTaskLoad(User user, TaskContext context) {
    UserTaskLoad load = new UserTaskLoad(getIdentifier(), user);
    TaskPersistenceContext persistenceContext = ((org.jbpm.services.task.commands.TaskContext) context).getPersistenceContext();
    Map<String, Object> params = new HashMap<>();
    params.put("owner", user.getId());
    logger.debug("DB query to be used for finding assignments :: '{}'", getSingleUserQuery());
    List<Integer> assignmentCounts = persistenceContext.queryStringWithParametersInTransaction(getSingleUserQuery(), params, ClassUtil.<List<Integer>>castClass(List.class));
    if (assignmentCounts != null && !assignmentCounts.isEmpty()) {
        load.setCalculatedLoad(new Double(assignmentCounts.get(0)));
    } else {
        load.setCalculatedLoad(new Double(0));
    }
    return load;
}
Also used : TaskContext(org.kie.api.task.TaskContext) HashMap(java.util.HashMap) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) UserTaskLoad(org.jbpm.services.task.assignment.UserTaskLoad) ArrayList(java.util.ArrayList) List(java.util.List)

Example 45 with TaskPersistenceContext

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

the class UserGroupCallbackTaskCommand method persistIfNotExists.

protected void persistIfNotExists(final OrganizationalEntity entity, TaskContext context) {
    TaskPersistenceContext tpc = context.getPersistenceContext();
    OrganizationalEntity orgEntity = tpc.findOrgEntity(entity.getId());
    if (orgEntity == null || (orgEntity instanceof Group && entity instanceof User) || (orgEntity instanceof User && entity instanceof Group)) {
        tpc.persistOrgEntity(entity);
    }
}
Also used : Group(org.kie.api.task.model.Group) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext)

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