Search in sources :

Example 1 with ItemList

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

the class QueryServicesClientImpl method query.

@Override
public <T> List<T> query(String queryName, String mapper, QueryFilterSpec filterSpec, Integer page, Integer pageSize, Class<T> resultType) {
    Object result = null;
    Class<?> resultTypeList = getResultTypeList(resultType);
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(QUERY_NAME, queryName);
        String queryString = getPagingQueryString("?mapper=" + mapper, page, pageSize);
        result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, filterSpec, resultTypeList);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFiltered", serialize(filterSpec), marshaller.getFormat().getType(), new Object[] { queryName, mapper, page, pageSize })));
        ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null) {
        if (result instanceof ItemList) {
            return ((ItemList<T>) result).getItems();
        } else if (result instanceof List) {
            return (List) result;
        } else if (result instanceof Wrapped) {
            return (List) ((Wrapped) result).unwrap();
        }
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ServiceResponse(org.kie.server.api.model.ServiceResponse) ItemList(org.kie.server.api.model.ItemList) Wrapped(org.kie.server.api.model.Wrapped) ExecutionErrorInstanceList(org.kie.server.api.model.admin.ExecutionErrorInstanceList) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) TaskWithProcessDescriptionList(org.kie.server.api.model.instance.TaskWithProcessDescriptionList) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) List(java.util.List) QueryDefinitionList(org.kie.server.api.model.definition.QueryDefinitionList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ArrayList(java.util.ArrayList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) TaskInstanceList(org.kie.server.api.model.instance.TaskInstanceList) ItemList(org.kie.server.api.model.ItemList)

Example 2 with ItemList

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

the class QueryServicesClientImpl method query.

@Override
public <T> List<T> query(String queryName, String mapper, String builder, Map<String, Object> parameters, Integer page, Integer pageSize, Class<T> resultType) {
    Object result = null;
    Class<?> resultTypeList = getResultTypeList(resultType);
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(QUERY_NAME, queryName);
        String queryString = getPagingQueryString("?mapper=" + mapper + "&builder=" + builder, page, pageSize);
        result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, parameters, resultTypeList);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFilteredWithBuilder", serialize(safeMap(parameters)), marshaller.getFormat().getType(), new Object[] { queryName, mapper, builder, page, pageSize })));
        ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null) {
        if (result instanceof ItemList) {
            return ((ItemList<T>) result).getItems();
        } else if (result instanceof List) {
            return (List) result;
        } else if (result instanceof Wrapped) {
            return (List) ((Wrapped) result).unwrap();
        }
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ServiceResponse(org.kie.server.api.model.ServiceResponse) ItemList(org.kie.server.api.model.ItemList) Wrapped(org.kie.server.api.model.Wrapped) ExecutionErrorInstanceList(org.kie.server.api.model.admin.ExecutionErrorInstanceList) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) TaskWithProcessDescriptionList(org.kie.server.api.model.instance.TaskWithProcessDescriptionList) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) List(java.util.List) QueryDefinitionList(org.kie.server.api.model.definition.QueryDefinitionList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ArrayList(java.util.ArrayList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) TaskInstanceList(org.kie.server.api.model.instance.TaskInstanceList) ItemList(org.kie.server.api.model.ItemList)

Example 3 with ItemList

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

the class QueryServicesClientImpl method query.

@Override
public <T> List<T> query(String queryName, String mapper, String orderBy, Integer page, Integer pageSize, Class<T> resultType) {
    Object result = null;
    Class<?> resultTypeList = getResultTypeList(resultType);
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(QUERY_NAME, queryName);
        String queryString = getPagingQueryString("?mapper=" + mapper + "&orderBy=" + orderBy, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_QUERY_DEF_GET_URI, valuesMap) + queryString, resultTypeList);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "query", new Object[] { queryName, mapper, orderBy, page, pageSize })));
        ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null) {
        if (result instanceof ItemList) {
            return ((ItemList<T>) result).getItems();
        } else if (result instanceof List) {
            return (List) result;
        } else if (result instanceof Wrapped) {
            return (List) ((Wrapped) result).unwrap();
        }
    }
    return null;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ServiceResponse(org.kie.server.api.model.ServiceResponse) ItemList(org.kie.server.api.model.ItemList) Wrapped(org.kie.server.api.model.Wrapped) ExecutionErrorInstanceList(org.kie.server.api.model.admin.ExecutionErrorInstanceList) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) TaskWithProcessDescriptionList(org.kie.server.api.model.instance.TaskWithProcessDescriptionList) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) List(java.util.List) QueryDefinitionList(org.kie.server.api.model.definition.QueryDefinitionList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ArrayList(java.util.ArrayList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) TaskInstanceList(org.kie.server.api.model.instance.TaskInstanceList) ItemList(org.kie.server.api.model.ItemList)

Aggregations

ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 CommandScript (org.kie.server.api.commands.CommandScript)3 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)3 ItemList (org.kie.server.api.model.ItemList)3 KieServerCommand (org.kie.server.api.model.KieServerCommand)3 ServiceResponse (org.kie.server.api.model.ServiceResponse)3 Wrapped (org.kie.server.api.model.Wrapped)3 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)3 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)3 QueryDefinitionList (org.kie.server.api.model.definition.QueryDefinitionList)3 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)3 ProcessInstanceCustomVarsList (org.kie.server.api.model.instance.ProcessInstanceCustomVarsList)3 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)3 ProcessInstanceUserTaskWithVariablesList (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList)3 TaskInstanceList (org.kie.server.api.model.instance.TaskInstanceList)3 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)3 TaskWithProcessDescriptionList (org.kie.server.api.model.instance.TaskWithProcessDescriptionList)3 VariableInstanceList (org.kie.server.api.model.instance.VariableInstanceList)3