Search in sources :

Example 6 with CaseDefinitionList

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

the class CaseServicesClientImpl method getCaseDefinitionsByContainer.

@Override
public List<CaseDefinition> getCaseDefinitionsByContainer(String containerId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    CaseDefinitionList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        String queryString = getPagingQueryString("", page, pageSize);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_ALL_DEFINITIONS_GET_URI, valuesMap) + queryString, CaseDefinitionList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseDefinitionsByContainer", new Object[] { containerId, page, pageSize, sort, sortOrder })));
        ServiceResponse<CaseDefinitionList> response = (ServiceResponse<CaseDefinitionList>) 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 : 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) CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 7 with CaseDefinitionList

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

the class CaseManagementRuntimeDataServiceBase method getCaseDefinitionsByContainer.

public CaseDefinitionList getCaseDefinitionsByContainer(String containerId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    sort = safeCaseDefinitionSort(sort);
    try {
        containerId = context.getContainerId(containerId, ContainerLocatorProvider.get().getLocator());
        Collection<CaseDefinition> caseDescs = caseRuntimeDataService.getCasesByDeployment(containerId, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
        List<org.kie.server.api.model.cases.CaseDefinition> cases = ConvertUtils.transformCases(caseDescs);
        CaseDefinitionList caseList = new CaseDefinitionList(cases);
        return caseList;
    } catch (IllegalArgumentException e) {
        // container was not found by locator
        return new CaseDefinitionList();
    }
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList)

Aggregations

CaseDefinitionList (org.kie.server.api.model.cases.CaseDefinitionList)7 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashMap (java.util.HashMap)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Variant (javax.ws.rs.core.Variant)2 CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)2 CommandScript (org.kie.server.api.commands.CommandScript)2 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)2 KieServerCommand (org.kie.server.api.model.KieServerCommand)2 ServiceResponse (org.kie.server.api.model.ServiceResponse)2 Header (org.kie.server.remote.rest.common.Header)2 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)2 Path (javax.ws.rs.Path)1 Test (org.junit.Test)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)1