use of org.kie.server.api.model.instance.ProcessInstanceCustomVarsList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method queryProcessesByVariables.
@ApiOperation(value = "Queries processes by variables and tasks", response = ProcessInstanceCustomVarsList.class)
@POST
@Path(RestURI.VARIABLES_PROCESSES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryProcessesByVariables(@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);
ProcessInstanceCustomVarsList processVariableSummaryList = runtimeDataServiceBase.queryProcessesByVariables(payload, type, new QueryContext(page * pageSize, pageSize, orderBy, asc));
logger.debug("Returning result of process 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.instance.ProcessInstanceCustomVarsList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToProcessInstanceCustomVarsList.
public static ProcessInstanceCustomVarsList convertToProcessInstanceCustomVarsList(Collection<ProcessInstanceCustomDesc> instances) {
if (instances == null) {
return new ProcessInstanceCustomVarsList(new org.kie.server.api.model.instance.ProcessInstanceCustomVars[0]);
}
List<ProcessInstanceCustomVars> processInstances = new ArrayList<ProcessInstanceCustomVars>(instances.size());
for (ProcessInstanceCustomDesc pi : instances) {
org.kie.server.api.model.instance.ProcessInstanceCustomVars instance = convertToProcessInstanceCustomVars(pi);
processInstances.add(instance);
}
return new ProcessInstanceCustomVarsList(processInstances);
}
use of org.kie.server.api.model.instance.ProcessInstanceCustomVarsList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToProcessInstanceCustomVarsList.
public static ProcessInstanceCustomVarsList convertToProcessInstanceCustomVarsList(List<ProcessInstanceWithVarsDesc> data) {
List<ProcessInstanceCustomVars> processInstances = new ArrayList<>();
for (ProcessInstanceWithVarsDesc proc : data) {
ProcessInstanceCustomVars tmp = new ProcessInstanceCustomVars();
tmp.setId(proc.getId());
tmp.setVariables(proc.getVariables());
tmp.setProcessId(proc.getProcessId());
tmp.setCorrelationKey(proc.getCorrelationKey());
tmp.setContainerId(proc.getDeploymentId());
tmp.setProcessName(proc.getProcessName());
tmp.setProcessVersion(proc.getProcessVersion());
tmp.setDate(proc.getDataTimeStamp());
tmp.setInitiator(proc.getInitiator());
tmp.setState(proc.getState());
processInstances.add(tmp);
}
ProcessInstanceCustomVarsList result = new ProcessInstanceCustomVarsList();
result.setProcessInstances(processInstances.stream().toArray(ProcessInstanceCustomVars[]::new));
return result;
}
use of org.kie.server.api.model.instance.ProcessInstanceCustomVarsList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataServiceBase method queryProcessesByVariables.
public ProcessInstanceCustomVarsList queryProcessesByVariables(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 convertToProcessInstanceCustomVarsList(advanceRuntimeDataService.queryProcessByVariables(convertToServiceApiQueryParam(filter.getAttributesQueryParams()), convertToServiceApiQueryParam(filter.getProcessVariablesQueryParams()), queryContext));
}
return convertToProcessInstanceCustomVarsList(advanceRuntimeDataService.queryProcessByVariablesAndTask(convertToServiceApiQueryParam(filter.getAttributesQueryParams()), convertToServiceApiQueryParam(filter.getProcessVariablesQueryParams()), convertToServiceApiQueryParam(filter.getTaskVariablesQueryParams()), getOwnersQueryParam(filter), queryContext));
}
Aggregations