Search in sources :

Example 1 with CaseUserTaskWithVariablesList

use of org.kie.server.api.model.cases.CaseUserTaskWithVariablesList in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method queryCaseUserTasksByVariables.

@ApiOperation(value = "Queries cases tasks by variables", response = CaseUserTaskWithVariablesList.class)
@POST
@Path(RestURI.VARIABLES_TASKS_CASES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryCaseUserTasksByVariables(@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) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        CaseUserTaskWithVariablesList taskVariableSummaryList = caseManagementRuntimeDataServiceBase.queryUserTasksByVariables(payload, type, new QueryContext((page * pageSize), pageSize));
        logger.debug("Returning result of case instance user task 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.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) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) QueryContext(org.kie.api.runtime.query.QueryContext) 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 CaseUserTaskWithVariablesList

use of org.kie.server.api.model.cases.CaseUserTaskWithVariablesList in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToCaseUserTaskWithVariablesList.

public static CaseUserTaskWithVariablesList convertToCaseUserTaskWithVariablesList(List<UserTaskInstanceWithPotOwnerDesc> queryUserTasksByVariables) {
    List<CaseUserTaskWithVariables> data = new ArrayList<>();
    for (UserTaskInstanceWithPotOwnerDesc desc : queryUserTasksByVariables) {
        CaseUserTaskWithVariables var = new CaseUserTaskWithVariables();
        var.setId(desc.getTaskId());
        var.setName(desc.getName());
        var.setDescription(desc.getDescription());
        var.setProcessInstanceId(desc.getProcessInstanceId());
        var.setCorrelationKey(desc.getCorrelationKey());
        var.setActualOwner(desc.getActualOwner());
        var.setCaseDefinitionId(desc.getProcessId());
        var.setPotentialOwners(desc.getPotentialOwners());
        var.setCaseId(desc.getCorrelationKey());
        var.setProcessVariables(desc.getProcessVariables());
        var.setInputVariables(desc.getInputdata());
        var.setCaseVariables(desc.getExtraData());
        var.setStatus(desc.getStatus());
        data.add(var);
    }
    CaseUserTaskWithVariablesList result = new CaseUserTaskWithVariablesList();
    result.setCaseUserTaskWithVariables(data.stream().toArray(CaseUserTaskWithVariables[]::new));
    return result;
}
Also used : UserTaskInstanceWithPotOwnerDesc(org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) ArrayList(java.util.ArrayList) CaseUserTaskWithVariables(org.kie.server.api.model.cases.CaseUserTaskWithVariables)

Aggregations

CaseUserTaskWithVariablesList (org.kie.server.api.model.cases.CaseUserTaskWithVariablesList)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 UserTaskInstanceWithPotOwnerDesc (org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc)1 QueryContext (org.kie.api.runtime.query.QueryContext)1 CaseUserTaskWithVariables (org.kie.server.api.model.cases.CaseUserTaskWithVariables)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