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();
}
Aggregations