Search in sources :

Example 1 with ProcessInstanceUserTaskWithVariablesList

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

the class RuntimeDataResource method queryUserTasksByVariables.

@ApiOperation(value = "Queries process tasks by variables", response = ProcessInstanceUserTaskWithVariablesList.class)
@POST
@Path(RestURI.VARIABLES_TASKS_PROCESSES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryUserTasksByVariables(@Context HttpHeaders headers, String payload, @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", required = false) @QueryParam("orderBy") String orderBy, @ApiParam(value = "optional sort direction - true ascending, false descending", required = false) @QueryParam("asc") @DefaultValue("true") boolean asc) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        ProcessInstanceUserTaskWithVariablesList taskVariableSummaryList = runtimeDataServiceBase.queryUserTasksByVariables(payload, type, new QueryContext(page * pageSize, pageSize, orderBy, asc));
        logger.debug("Returning result of process tasks search: {}", taskVariableSummaryList);
        return createCorrectVariant(taskVariableSummaryList, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) Variant(javax.ws.rs.core.Variant) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) Path(javax.ws.rs.Path) KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with ProcessInstanceUserTaskWithVariablesList

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

the class ConvertUtils method convertToUserTaskWithVariablesList.

public static ProcessInstanceUserTaskWithVariablesList convertToUserTaskWithVariablesList(List<UserTaskInstanceWithPotOwnerDesc> queryUserTasksByVariables) {
    List<ProcessInstanceUserTaskWithVariables> data = new ArrayList<>();
    for (UserTaskInstanceWithPotOwnerDesc desc : queryUserTasksByVariables) {
        ProcessInstanceUserTaskWithVariables var = new ProcessInstanceUserTaskWithVariables();
        var.setId(desc.getTaskId());
        var.setName(desc.getName());
        var.setDescription(desc.getDescription());
        var.setCorrelationKey(desc.getCorrelationKey());
        var.setActualOwner(desc.getActualOwner());
        var.setProcessDefinitionId(desc.getProcessId());
        var.setPotentialOwners(desc.getPotentialOwners());
        var.setProcessInstanceId(desc.getProcessInstanceId());
        var.setProcessVariables(desc.getProcessVariables());
        var.setInputVariables(desc.getInputdata());
        var.setStatus(desc.getStatus());
        data.add(var);
    }
    ProcessInstanceUserTaskWithVariablesList result = new ProcessInstanceUserTaskWithVariablesList();
    result.setUserTaskWithVariables(data.parallelStream().toArray(ProcessInstanceUserTaskWithVariables[]::new));
    return result;
}
Also used : UserTaskInstanceWithPotOwnerDesc(org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) ArrayList(java.util.ArrayList) ProcessInstanceUserTaskWithVariables(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables)

Aggregations

ProcessInstanceUserTaskWithVariablesList (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)1 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)1 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)1 UserTaskInstanceWithPotOwnerDesc (org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc)1 QueryContext (org.kie.api.runtime.query.QueryContext)1 ProcessInstanceUserTaskWithVariables (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables)1 Header (org.kie.server.remote.rest.common.Header)1 KieServerEndpoint (org.kie.server.remote.rest.common.marker.KieServerEndpoint)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)1 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)1