Search in sources :

Example 21 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getTasksByVariables.

public TaskSummaryList getTasksByVariables(String userId, String variableName, String variableValue, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    userId = getUser(userId);
    List<Status> taskStatuses = buildTaskStatuses(status);
    if (taskStatuses == null) {
        taskStatuses = new ArrayList<Status>();
        taskStatuses.add(Status.Ready);
        taskStatuses.add(Status.Reserved);
        taskStatuses.add(Status.InProgress);
    }
    List<TaskSummary> instances = null;
    if (variableValue != null && !variableValue.isEmpty()) {
        logger.debug("About to search for tasks that has variable '{}' with value '{}' with page {} and page size {}", variableName, variableValue, page, pageSize);
        instances = runtimeDataService.getTasksByVariableAndValue(userId, variableName, variableValue, taskStatuses, buildQueryContext(page, pageSize, sort, sortOrder));
        logger.debug("Found {} tasks with variable {} and variable value {}", instances.size(), variableName, variableValue);
    } else {
        logger.debug("About to search for tasks that has variable '{}' with page {} and page size {}", variableName, page, pageSize);
        instances = runtimeDataService.getTasksByVariable(userId, variableName, taskStatuses, buildQueryContext(page, pageSize, sort, sortOrder));
        logger.debug("Found {} tasks with variable {} ", instances.size(), variableName);
    }
    TaskSummaryList taskSummaryList = convertToTaskSummaryList(instances);
    logger.debug("Returning result of task by variable search: {}", taskSummaryList);
    return taskSummaryList;
}
Also used : Status(org.kie.api.task.model.Status) TaskSummary(org.kie.api.task.model.TaskSummary) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 22 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getTasksAssignedAsPotentialOwner.

public TaskSummaryList getTasksAssignedAsPotentialOwner(List<String> status, List<String> groupIds, String userId, Integer page, Integer pageSize, String sort, boolean sortOrder, String filter) {
    List<Status> taskStatuses = buildTaskStatuses(status);
    userId = getUser(userId);
    logger.debug("About to search for task assigned as potential owner for user '{}'", userId);
    List<TaskSummary> tasks;
    QueryFilter queryFilter = buildTaskByNameQueryFilter(page, pageSize, sort, sortOrder, filter);
    if (groupIds != null && !groupIds.isEmpty()) {
        if (taskStatuses == null) {
            tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, groupIds, queryFilter);
        } else {
            tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, groupIds, taskStatuses, queryFilter);
        }
    } else if (taskStatuses != null) {
        tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus(userId, taskStatuses, queryFilter);
    } else {
        tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, queryFilter);
    }
    logger.debug("Found {} tasks for user '{}' assigned as potential owner", tasks.size(), userId);
    TaskSummaryList result = convertToTaskSummaryList(tasks);
    return result;
}
Also used : Status(org.kie.api.task.model.Status) ConvertUtils.buildQueryFilter(org.kie.server.services.jbpm.ConvertUtils.buildQueryFilter) QueryFilter(org.kie.internal.query.QueryFilter) ConvertUtils.buildTaskByNameQueryFilter(org.kie.server.services.jbpm.ConvertUtils.buildTaskByNameQueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 23 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToTaskSummaryList.

public static TaskSummaryList convertToTaskSummaryList(Collection<TaskSummary> tasks) {
    if (tasks == null) {
        return new TaskSummaryList(new org.kie.server.api.model.instance.TaskSummary[0]);
    }
    org.kie.server.api.model.instance.TaskSummary[] instances = new org.kie.server.api.model.instance.TaskSummary[tasks.size()];
    int counter = 0;
    for (TaskSummary taskSummary : tasks) {
        instances[counter] = convertToTaskSummary(taskSummary);
        counter++;
    }
    return new TaskSummaryList(instances);
}
Also used : TaskSummary(org.kie.api.task.model.TaskSummary) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 24 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method getCaseInstanceTasksAsAdmin.

@ApiOperation(value = "Returns tasks for business administrators in a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = TaskSummaryList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_SUMMARY_RESPONSE_JSON) })) })
@GET
@Path(CASE_TASKS_AS_ADMIN_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceTasksAsAdmin(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case instance identifier that tasks should belong to", required = true, example = "CASE-00000000001") @PathParam(CASE_ID) String caseId, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String user, @ApiParam(value = "optional task status (Created, Ready, Reserved, InProgress, Suspended, Completed, Failed, Error, Exited, Obsolete)", required = false, allowableValues = "Created, Ready, Reserved,InProgress,Suspended,Completed,Failed,Error,Exited,Obsolete") @QueryParam("status") List<String> status, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
    return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
        logger.debug("About to look for case instance {} tasks with status {} assigned to business admin {}", caseId, status, user);
        TaskSummaryList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseTasksAsBusinessAdmin(caseId, user, status, page, pageSize, sort, sortOrder);
        logger.debug("Returning OK response with content '{}'", responseObject);
        return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
    });
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 25 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method getCaseInstanceTasksAsStakeholder.

@ApiOperation(value = "Returns tasks for stakeholders in a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = TaskSummaryList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_SUMMARY_RESPONSE_JSON) })) })
@GET
@Path(CASE_TASKS_AS_STAKEHOLDER_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceTasksAsStakeholder(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case instance identifier that tasks should belong to", required = true, example = "CASE-0000000001") @PathParam(CASE_ID) String caseId, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String user, @ApiParam(value = "optional task status (Created, Ready, Reserved, InProgress, Suspended, Completed, Failed, Error, Exited, Obsolete)", required = false, allowableValues = "Created, Ready, Reserved,InProgress,Suspended,Completed,Failed,Error,Exited,Obsolete") @QueryParam("status") List<String> status, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
    return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
        logger.debug("About to look for case instance {} tasks with status {} assigned to stakeholder {}", caseId, status, user);
        TaskSummaryList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseTasksAsStakeholder(caseId, user, status, page, pageSize, sort, sortOrder);
        logger.debug("Returning OK response with content '{}'", responseObject);
        return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
    });
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)37 HashMap (java.util.HashMap)14 ServiceResponse (org.kie.server.api.model.ServiceResponse)14 CommandScript (org.kie.server.api.commands.CommandScript)13 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)13 KieServerCommand (org.kie.server.api.model.KieServerCommand)13 TaskSummary (org.kie.api.task.model.TaskSummary)12 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 GET (javax.ws.rs.GET)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 Variant (javax.ws.rs.core.Variant)9 Header (org.kie.server.remote.rest.common.Header)9 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)9 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)9 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)9 Status (org.kie.api.task.model.Status)8 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)6 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)6