Search in sources :

Example 1 with CaseInstanceCustomVarsList

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

the class ConvertUtils method convertToCaseInstanceCustomVarsList.

public static CaseInstanceCustomVarsList convertToCaseInstanceCustomVarsList(List<ProcessInstanceWithVarsDesc> queryCaseByVariables) {
    List<CaseInstanceCustomVars> processInstances = new ArrayList<>();
    for (ProcessInstanceWithVarsDesc proc : queryCaseByVariables) {
        CaseInstanceCustomVars tmp = new CaseInstanceCustomVars();
        tmp.setProcessInstanceId(proc.getId());
        tmp.setProcessName(proc.getProcessName());
        tmp.setProcessVersion(proc.getProcessVersion());
        tmp.setCaseId(proc.getCorrelationKey());
        tmp.setCaseDefinitionId(proc.getProcessId());
        tmp.setCorrelationKey(proc.getCorrelationKey());
        tmp.setProcessVariables(proc.getVariables());
        tmp.setCaseVariables(proc.getExtraData());
        tmp.setInitiator(proc.getInitiator());
        tmp.setState(proc.getState());
        tmp.setContainerId(proc.getDeploymentId());
        processInstances.add(tmp);
    }
    CaseInstanceCustomVarsList result = new CaseInstanceCustomVarsList();
    result.setCaseInstances(processInstances.stream().toArray(CaseInstanceCustomVars[]::new));
    return result;
}
Also used : ProcessInstanceWithVarsDesc(org.jbpm.services.api.model.ProcessInstanceWithVarsDesc) ArrayList(java.util.ArrayList) CaseInstanceCustomVars(org.kie.server.api.model.cases.CaseInstanceCustomVars) CaseInstanceCustomVarsList(org.kie.server.api.model.cases.CaseInstanceCustomVarsList)

Example 2 with CaseInstanceCustomVarsList

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

the class CaseQueryResource method queryCaseByVariables.

@ApiOperation(value = "Queries cases by variables and tasks", response = CaseInstanceCustomVarsList.class)
@POST
@Path(RestURI.VARIABLES_CASES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryCaseByVariables(@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);
        CaseInstanceCustomVarsList processVariableSummaryList = caseManagementRuntimeDataServiceBase.queryCasesByVariables(payload, type, new QueryContext(page * pageSize, pageSize));
        logger.debug("Returning result of case instance search: {}", processVariableSummaryList);
        return createCorrectVariant(processVariableSummaryList, 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) QueryContext(org.kie.api.runtime.query.QueryContext) CaseInstanceCustomVarsList(org.kie.server.api.model.cases.CaseInstanceCustomVarsList) 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 3 with CaseInstanceCustomVarsList

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

the class CaseManagementRuntimeDataServiceBase method queryCasesByVariables.

public CaseInstanceCustomVarsList queryCasesByVariables(String payload, String payloadType, QueryContext queryContext) {
    SearchQueryFilterSpec filter = new SearchQueryFilterSpec();
    if (payload != null) {
        filter = marshallerHelper.unmarshal(payload, payloadType, SearchQueryFilterSpec.class);
    }
    List<String> params = filter.getAttributesQueryParams().stream().map(e -> e.getColumn()).collect(toList());
    params.removeAll(asList(TASK_ATTR_NAME, TASK_ATTR_OWNER, TASK_ATTR_STATUS));
    if (params.size() == filter.getAttributesQueryParams().size() && filter.getTaskVariablesQueryParams().isEmpty()) {
        return convertToCaseInstanceCustomVarsList(advanceCaseRuntimeDataService.queryCaseByVariables(convertToServiceApiQueryParam(filter.getAttributesQueryParams()), convertToServiceApiQueryParam(filter.getCaseVariablesQueryParams()), queryContext));
    } else {
        return convertToCaseInstanceCustomVarsList(advanceCaseRuntimeDataService.queryCaseByVariablesAndTask(convertToServiceApiQueryParam(filter.getAttributesQueryParams()), convertToServiceApiQueryParam(filter.getTaskVariablesQueryParams()), convertToServiceApiQueryParam(filter.getCaseVariablesQueryParams()), filter.getOwners(), queryContext));
    }
}
Also used : CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) TaskSummary(org.kie.api.task.model.TaskSummary) CaseInstanceCustomVarsList(org.kie.server.api.model.cases.CaseInstanceCustomVarsList) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) KieServerConstants(org.kie.server.api.KieServerConstants) CaseStage(org.kie.server.api.model.cases.CaseStage) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) MarshallerHelper(org.kie.server.services.impl.marshal.MarshallerHelper) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) ConvertUtils.convertToServiceApiQueryParam(org.kie.server.services.casemgmt.ConvertUtils.convertToServiceApiQueryParam) CaseInstance(org.kie.server.api.model.cases.CaseInstance) ArrayList(java.util.ArrayList) CaseRuntimeDataService(org.jbpm.casemgmt.api.CaseRuntimeDataService) TASK_ATTR_OWNER(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_OWNER) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) Arrays.asList(java.util.Arrays.asList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) CaseStageList(org.kie.server.api.model.cases.CaseStageList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) CaseMilestoneInstance(org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance) TASK_ATTR_NAME(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_NAME) IdentityProvider(org.kie.internal.identity.IdentityProvider) CaseMilestone(org.kie.server.api.model.cases.CaseMilestone) ConvertUtils.convertToCaseInstanceCustomVarsList(org.kie.server.services.casemgmt.ConvertUtils.convertToCaseInstanceCustomVarsList) CaseMilestoneList(org.kie.server.api.model.cases.CaseMilestoneList) NodeInstance(org.kie.server.api.model.instance.NodeInstance) TASK_ATTR_STATUS(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_STATUS) Collection(java.util.Collection) QueryContext(org.kie.api.runtime.query.QueryContext) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) AdvanceCaseRuntimeDataService(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem) List(java.util.List) CaseAdHocFragmentList(org.kie.server.api.model.cases.CaseAdHocFragmentList) Collectors.toList(java.util.stream.Collectors.toList) CaseAdHocFragment(org.kie.server.api.model.cases.CaseAdHocFragment) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) Status(org.kie.api.task.model.Status) ContainerLocatorProvider(org.kie.server.services.impl.locator.ContainerLocatorProvider) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec)

Aggregations

CaseInstanceCustomVarsList (org.kie.server.api.model.cases.CaseInstanceCustomVarsList)3 ArrayList (java.util.ArrayList)2 QueryContext (org.kie.api.runtime.query.QueryContext)2 ApiOperation (io.swagger.annotations.ApiOperation)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)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 AdvanceCaseRuntimeDataService (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService)1 TASK_ATTR_NAME (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_NAME)1 TASK_ATTR_OWNER (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_OWNER)1 TASK_ATTR_STATUS (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_STATUS)1 CaseRuntimeDataService (org.jbpm.casemgmt.api.CaseRuntimeDataService)1 AdHocFragment (org.jbpm.casemgmt.api.model.AdHocFragment)1 CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)1