Search in sources :

Example 1 with ProcessInstanceCustomVarsList

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);
    }
}
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) 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) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) 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 ProcessInstanceCustomVarsList

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);
}
Also used : ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) ArrayList(java.util.ArrayList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) ProcessInstanceCustomDesc(org.jbpm.services.api.model.ProcessInstanceCustomDesc)

Example 3 with ProcessInstanceCustomVarsList

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;
}
Also used : ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) ProcessInstanceWithVarsDesc(org.jbpm.services.api.model.ProcessInstanceWithVarsDesc) ArrayList(java.util.ArrayList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList)

Example 4 with ProcessInstanceCustomVarsList

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));
}
Also used : ConvertUtils.buildQueryFilter(org.kie.server.services.jbpm.ConvertUtils.buildQueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Arrays(java.util.Arrays) KieServerConstants(org.kie.server.api.KieServerConstants) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) LoggerFactory(org.slf4j.LoggerFactory) ConvertUtils.convertToServiceApiQueryParam(org.kie.server.services.jbpm.ConvertUtils.convertToServiceApiQueryParam) ConvertUtils.convertToVariablesList(org.kie.server.services.jbpm.ConvertUtils.convertToVariablesList) QueryParam(org.jbpm.services.api.query.model.QueryParam) ConvertUtils.convertToProcessInstance(org.kie.server.services.jbpm.ConvertUtils.convertToProcessInstance) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KieInternalServices(org.kie.internal.KieInternalServices) TaskEvent(org.kie.internal.task.api.model.TaskEvent) CountDefinition(org.kie.server.api.model.definition.CountDefinition) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) ConvertUtils.convertToProcessInstanceCustomVarsList(org.kie.server.services.jbpm.ConvertUtils.convertToProcessInstanceCustomVarsList) QueryParam.all(org.jbpm.services.api.query.model.QueryParam.all) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Collection(java.util.Collection) ConvertUtils.buildTaskStatuses(org.kie.server.services.jbpm.ConvertUtils.buildTaskStatuses) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) QueryContext(org.kie.api.runtime.query.QueryContext) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) AuditTask(org.kie.internal.task.api.AuditTask) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) List(java.util.List) ConvertUtils.buildQueryContext(org.kie.server.services.jbpm.ConvertUtils.buildQueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) ConvertUtils.convertToProcess(org.kie.server.services.jbpm.ConvertUtils.convertToProcess) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) TaskEventInstance(org.kie.server.api.model.instance.TaskEventInstance) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) CorrelationKeyFactory(org.kie.internal.process.CorrelationKeyFactory) Status(org.kie.api.task.model.Status) TaskEventInstanceList(org.kie.server.api.model.instance.TaskEventInstanceList) TASK_ATTR_NAME(org.jbpm.services.api.AdvanceRuntimeDataService.TASK_ATTR_NAME) ConvertUtils.convertToTask(org.kie.server.services.jbpm.ConvertUtils.convertToTask) ConvertUtils.convertToNodeInstanceList(org.kie.server.services.jbpm.ConvertUtils.convertToNodeInstanceList) EntryType(org.jbpm.services.api.RuntimeDataService.EntryType) ConvertUtils.convertToProcessInstanceList(org.kie.server.services.jbpm.ConvertUtils.convertToProcessInstanceList) MarshallerHelper(org.kie.server.services.impl.marshal.MarshallerHelper) HashMap(java.util.HashMap) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) TASK_ATTR_OWNER(org.jbpm.services.api.AdvanceRuntimeDataService.TASK_ATTR_OWNER) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) TASK_ATTR_STATUS(org.jbpm.services.api.AdvanceRuntimeDataService.TASK_ATTR_STATUS) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) IdentityProvider(org.kie.internal.identity.IdentityProvider) ConvertUtils.convertToNodeInstance(org.kie.server.services.jbpm.ConvertUtils.convertToNodeInstance) ConvertUtils.convertToProcessList(org.kie.server.services.jbpm.ConvertUtils.convertToProcessList) Logger(org.slf4j.Logger) ConvertUtils.buildTaskByNameQueryFilter(org.kie.server.services.jbpm.ConvertUtils.buildTaskByNameQueryFilter) VariableDesc(org.jbpm.services.api.model.VariableDesc) CorrelationKey(org.kie.internal.process.CorrelationKey) TaskInstance(org.kie.server.api.model.instance.TaskInstance) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) ConvertUtils.nullEmpty(org.kie.server.services.jbpm.ConvertUtils.nullEmpty) Collectors.toList(java.util.stream.Collectors.toList) AdvanceRuntimeDataService(org.jbpm.services.api.AdvanceRuntimeDataService) RuntimeDataService(org.jbpm.services.api.RuntimeDataService) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) ConvertUtils.convertToUserTaskWithVariablesList(org.kie.server.services.jbpm.ConvertUtils.convertToUserTaskWithVariablesList) ContainerLocatorProvider(org.kie.server.services.impl.locator.ContainerLocatorProvider) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec)

Aggregations

ProcessInstanceCustomVarsList (org.kie.server.api.model.instance.ProcessInstanceCustomVarsList)4 ArrayList (java.util.ArrayList)3 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)2 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)2 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)2 QueryContext (org.kie.api.runtime.query.QueryContext)2 ProcessInstanceCustomVars (org.kie.server.api.model.instance.ProcessInstanceCustomVars)2 ApiOperation (io.swagger.annotations.ApiOperation)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)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