Search in sources :

Example 6 with CaseInstanceList

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

the class CaseManagementRuntimeDataServiceBase method getCaseInstancesByCaseFileData.

public CaseInstanceList getCaseInstancesByCaseFileData(String dataItemName, String dataItemValue, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    List<CaseStatus> caseStatus = safeCaseStatus(status);
    sort = safeCaseInstanceSort(sort);
    Collection<org.jbpm.casemgmt.api.model.instance.CaseInstance> caseInstanceDescs = null;
    if (dataItemValue != null && !dataItemValue.isEmpty()) {
        caseInstanceDescs = caseRuntimeDataService.getCaseInstancesByDataItemAndValue(dataItemName, dataItemValue, caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    } else {
        caseInstanceDescs = caseRuntimeDataService.getCaseInstancesByDataItem(dataItemName, caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    }
    List<CaseInstance> caseInstances = ConvertUtils.transformCaseInstances(caseInstanceDescs);
    CaseInstanceList caseInstancesList = new CaseInstanceList(caseInstances);
    return caseInstancesList;
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus)

Example 7 with CaseInstanceList

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

the class CaseManagementRuntimeDataServiceBase method getCaseInstancesByDefinition.

public CaseInstanceList getCaseInstancesByDefinition(String containerId, String caseDefinitionId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    List<CaseStatus> caseStatus = safeCaseStatus(status);
    sort = safeCaseInstanceSort(sort);
    Collection<org.jbpm.casemgmt.api.model.instance.CaseInstance> caseInstanceDescs = caseRuntimeDataService.getCaseInstancesByDefinition(caseDefinitionId, caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    List<CaseInstance> caseInstances = ConvertUtils.transformCaseInstances(caseInstanceDescs);
    CaseInstanceList caseInstancesList = new CaseInstanceList(caseInstances);
    return caseInstancesList;
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus)

Example 8 with CaseInstanceList

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

the class CaseManagementRuntimeDataServiceBase method getCaseInstancesByContainer.

public CaseInstanceList getCaseInstancesByContainer(String containerId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    List<CaseStatus> caseStatus = safeCaseStatus(status);
    sort = safeCaseInstanceSort(sort);
    Collection<org.jbpm.casemgmt.api.model.instance.CaseInstance> caseInstanceDescs = caseRuntimeDataService.getCaseInstancesByDeployment(containerId, caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    List<CaseInstance> caseInstances = ConvertUtils.transformCaseInstances(caseInstanceDescs);
    CaseInstanceList caseInstancesList = new CaseInstanceList(caseInstances);
    return caseInstancesList;
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus)

Example 9 with CaseInstanceList

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

the class CaseServicesClientImpl method getCaseInstancesByDefinition.

@Override
public List<CaseInstance> getCaseInstancesByDefinition(String containerId, String caseDefinitionId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    CaseInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_DEF_ID, caseDefinitionId);
        String queryString = getPagingQueryString("", page, pageSize);
        queryString = getAdditionalParams(queryString, "status", status);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        queryString = getAdditionalParams(queryString, "withData", Collections.singletonList(withData));
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_INSTANCES_BY_DEF_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstancesByDefinition", new Object[] { containerId, caseDefinitionId, safeList(status), page, pageSize, sort, sortOrder, withData })));
        ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        list = response.getResult();
    }
    if (list != null) {
        return list.getItems();
    }
    return Collections.emptyList();
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 10 with CaseInstanceList

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

the class CaseServicesClientImpl method getCaseInstancesOwnedBy.

@Override
public List<CaseInstance> getCaseInstancesOwnedBy(String owner, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    CaseInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getPagingQueryString("?owner=" + owner, page, pageSize);
        queryString = getAdditionalParams(queryString, "status", status);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        queryString = getAdditionalParams(queryString, "withData", Collections.singletonList(withData));
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_ALL_INSTANCES_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstancesOwnedBy", new Object[] { owner, safeList(status), page, pageSize, sort, sortOrder, withData })));
        ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        list = response.getResult();
    }
    if (list != null) {
        return list.getItems();
    }
    return Collections.emptyList();
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Aggregations

CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)20 CaseInstance (org.kie.server.api.model.cases.CaseInstance)9 CaseStatus (org.jbpm.casemgmt.api.model.CaseStatus)7 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 Variant (javax.ws.rs.core.Variant)6 CommandScript (org.kie.server.api.commands.CommandScript)6 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)6 KieServerCommand (org.kie.server.api.model.KieServerCommand)6 ServiceResponse (org.kie.server.api.model.ServiceResponse)6 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 Header (org.kie.server.remote.rest.common.Header)5 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)5 ArrayList (java.util.ArrayList)2 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)2 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)2 Consumes (javax.ws.rs.Consumes)1