Search in sources :

Example 1 with TaskSummaryList

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

the class CaseQueryResource method getCaseInstanceTasksAsPotentialOwner.

/*
     * Case tasks
     */
@ApiOperation(value = "Returns tasks for potential owners 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_POT_OWNER_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceTasksAsPotentialOwner(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case instance identifier that tasks should belong to", required = true, example = "CASE-00000000011") @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 potential owner {}", caseId, status, user);
        TaskSummaryList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseTasks(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 2 with TaskSummaryList

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

the class UserTaskServicesClientImpl method findTasksAssignedAsPotentialOwner.

@Override
public List<TaskSummary> findTasksAssignedAsPotentialOwner(String userId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList taskSummaryList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String userQuery = getUserQueryStr(userId);
        String statusQuery = getAdditionalParams(userQuery, "status", status);
        String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_POT_OWNERS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsPotentialOwner", new Object[] { safeList(status), new ArrayList(), userId, page, pageSize, sort, sortOrder })));
        ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        taskSummaryList = response.getResult();
    }
    if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
        return Arrays.asList(taskSummaryList.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandScript(org.kie.server.api.commands.CommandScript) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 3 with TaskSummaryList

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

the class UserTaskServicesClientImpl method findTasksByVariable.

@Override
public List<TaskSummary> findTasksByVariable(String userId, String variableName, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(VAR_NAME, variableName);
        String userQuery = getUserQueryStr(userId);
        String statusQuery = getAdditionalParams(userQuery, "status", status);
        String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_BY_VAR_NAME_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksByVariables", new Object[] { userId, variableName, "", safeList(status), page, pageSize, sort, sortOrder })));
        ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getTasks() != null) {
        return Arrays.asList(result.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 4 with TaskSummaryList

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

the class UserTaskServicesClientImpl method findTasksAssignedAsBusinessAdministrator.

@Override
public List<TaskSummary> findTasksAssignedAsBusinessAdministrator(String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList taskSummaryList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getUserAndPagingQueryString(userId, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_BUSINESS_ADMINS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsBusinessAdministratorByStatus", new Object[] { new ArrayList(), userId, page, pageSize, sort, sortOrder })));
        ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        taskSummaryList = response.getResult();
    }
    if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
        return Arrays.asList(taskSummaryList.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandScript(org.kie.server.api.commands.CommandScript) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 5 with TaskSummaryList

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

the class UserTaskServicesClientImpl method findTasksOwned.

@Override
public List<TaskSummary> findTasksOwned(String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList taskSummaryList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getUserAndPagingQueryString(userId, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_OWNED_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksOwnedByStatus", new Object[] { new ArrayList(), userId, page, pageSize, sort, sortOrder })));
        ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        taskSummaryList = response.getResult();
    }
    if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
        return Arrays.asList(taskSummaryList.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandScript(org.kie.server.api.commands.CommandScript) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

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