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;
}
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);
}
}
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));
}
}
Aggregations