Search in sources :

Example 1 with ProcessDefinitionsPaginateList

use of org.wso2.carbon.bpmn.rest.model.repository.ProcessDefinitionsPaginateList in project carbon-business-process by wso2.

the class ProcessDefinitionService method getProcessDefinitions.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessDefinitions() {
    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
    // Populate filter-parameters
    if (allRequestParams.containsKey("category")) {
        processDefinitionQuery.processDefinitionCategory(allRequestParams.get("category"));
    }
    if (allRequestParams.containsKey("categoryLike")) {
        processDefinitionQuery.processDefinitionCategoryLike(allRequestParams.get("categoryLike"));
    }
    if (allRequestParams.containsKey("categoryNotEquals")) {
        processDefinitionQuery.processDefinitionCategoryNotEquals(allRequestParams.get("categoryNotEquals"));
    }
    if (allRequestParams.containsKey("key")) {
        processDefinitionQuery.processDefinitionKey(allRequestParams.get("key"));
    }
    if (allRequestParams.containsKey("keyLike")) {
        processDefinitionQuery.processDefinitionKeyLike(allRequestParams.get("keyLike"));
    }
    if (allRequestParams.containsKey("name")) {
        processDefinitionQuery.processDefinitionName(allRequestParams.get("name"));
    }
    if (allRequestParams.containsKey("nameLike")) {
        processDefinitionQuery.processDefinitionNameLike(allRequestParams.get("nameLike"));
    }
    if (allRequestParams.containsKey("resourceName")) {
        processDefinitionQuery.processDefinitionResourceName(allRequestParams.get("resourceName"));
    }
    if (allRequestParams.containsKey("resourceNameLike")) {
        processDefinitionQuery.processDefinitionResourceNameLike(allRequestParams.get("resourceNameLike"));
    }
    if (allRequestParams.containsKey("version")) {
        processDefinitionQuery.processDefinitionVersion(Integer.valueOf(allRequestParams.get("version")));
    }
    if (allRequestParams.containsKey("suspended")) {
        Boolean suspended = Boolean.valueOf(allRequestParams.get("suspended"));
        if (suspended != null) {
            if (suspended) {
                processDefinitionQuery.suspended();
            } else {
                processDefinitionQuery.active();
            }
        }
    }
    if (allRequestParams.containsKey("latest")) {
        Boolean latest = Boolean.valueOf(allRequestParams.get("latest"));
        if (latest != null && latest) {
            processDefinitionQuery.latestVersion();
        }
    }
    if (allRequestParams.containsKey("deploymentId")) {
        processDefinitionQuery.deploymentId(allRequestParams.get("deploymentId"));
    }
    if (allRequestParams.containsKey("startableByUser")) {
        processDefinitionQuery.startableByUser(allRequestParams.get("startableByUser"));
    }
    if (allRequestParams.containsKey("tenantId")) {
        processDefinitionQuery.processDefinitionTenantId(allRequestParams.get("tenantId"));
    }
    if (allRequestParams.containsKey("tenantIdLike")) {
        processDefinitionQuery.processDefinitionTenantIdLike(allRequestParams.get("tenantIdLike"));
    }
    DataResponse response = new ProcessDefinitionsPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, processDefinitionQuery, "name", properties);
    return Response.ok().entity(response).build();
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinitionsPaginateList(org.wso2.carbon.bpmn.rest.model.repository.ProcessDefinitionsPaginateList) RepositoryService(org.activiti.engine.RepositoryService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RepositoryService (org.activiti.engine.RepositoryService)1 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)1 ProcessDefinitionsPaginateList (org.wso2.carbon.bpmn.rest.model.repository.ProcessDefinitionsPaginateList)1