use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class WorkflowTaskService method getTasks.
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTasks() {
// Create a Task query request
TaskQueryRequest request = new TaskQueryRequest();
Map<String, String> requestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
requestParams.put(property, value);
}
}
// Populate filter-parameters
if (requestParams.containsKey("name")) {
request.setName(requestParams.get("name"));
}
if (requestParams.containsKey("nameLike")) {
request.setNameLike(requestParams.get("nameLike"));
}
if (requestParams.containsKey("description")) {
request.setDescription(requestParams.get("description"));
}
if (requestParams.containsKey("descriptionLike")) {
request.setDescriptionLike(requestParams.get("descriptionLike"));
}
if (requestParams.containsKey("priority")) {
request.setPriority(Integer.valueOf(requestParams.get("priority")));
}
if (requestParams.containsKey("minimumPriority")) {
request.setMinimumPriority(Integer.valueOf(requestParams.get("minimumPriority")));
}
if (requestParams.containsKey("maximumPriority")) {
request.setMaximumPriority(Integer.valueOf(requestParams.get("maximumPriority")));
}
if (requestParams.containsKey("assignee")) {
request.setAssignee(requestParams.get("assignee"));
}
if (requestParams.containsKey("owner")) {
request.setOwner(requestParams.get("owner"));
}
if (requestParams.containsKey("unassigned")) {
request.setUnassigned(Boolean.valueOf(requestParams.get("unassigned")));
}
if (requestParams.containsKey("delegationState")) {
request.setDelegationState(requestParams.get("delegationState"));
}
if (requestParams.containsKey("candidateUser")) {
request.setCandidateUser(requestParams.get("candidateUser"));
}
if (requestParams.containsKey("involvedUser")) {
request.setInvolvedUser(requestParams.get("involvedUser"));
}
if (requestParams.containsKey("candidateGroup")) {
request.setCandidateGroup(requestParams.get("candidateGroup"));
}
if (requestParams.containsKey("candidateGroups")) {
String[] candidateGroups = requestParams.get("candidateGroups").split(",");
List<String> groups = new ArrayList<String>(candidateGroups.length);
for (String candidateGroup : candidateGroups) {
groups.add(candidateGroup);
}
request.setCandidateGroupIn(groups);
}
if (requestParams.containsKey("processDefinitionKey")) {
request.setProcessDefinitionKey(requestParams.get("processDefinitionKey"));
}
if (requestParams.containsKey("processDefinitionKeyLike")) {
request.setProcessDefinitionKeyLike(requestParams.get("processDefinitionKeyLike"));
}
if (requestParams.containsKey("processDefinitionName")) {
request.setProcessDefinitionName(requestParams.get("processDefinitionName"));
}
if (requestParams.containsKey("processDefinitionNameLike")) {
request.setProcessDefinitionNameLike(requestParams.get("processDefinitionNameLike"));
}
if (requestParams.containsKey("processInstanceId")) {
request.setProcessInstanceId(requestParams.get("processInstanceId"));
}
if (requestParams.containsKey("processInstanceBusinessKey")) {
request.setProcessInstanceBusinessKey(requestParams.get("processInstanceBusinessKey"));
}
if (requestParams.containsKey("executionId")) {
request.setExecutionId(requestParams.get("executionId"));
}
if (requestParams.containsKey("createdOn")) {
request.setCreatedOn(RequestUtil.getDate(requestParams, "createdOn"));
}
if (requestParams.containsKey("createdBefore")) {
request.setCreatedBefore(RequestUtil.getDate(requestParams, "createdBefore"));
}
if (requestParams.containsKey("createdAfter")) {
request.setCreatedAfter(RequestUtil.getDate(requestParams, "createdAfter"));
}
if (requestParams.containsKey("excludeSubTasks")) {
request.setExcludeSubTasks(Boolean.valueOf(requestParams.get("excludeSubTasks")));
}
if (requestParams.containsKey("taskDefinitionKey")) {
request.setTaskDefinitionKey(requestParams.get("taskDefinitionKey"));
}
if (requestParams.containsKey("taskDefinitionKeyLike")) {
request.setTaskDefinitionKeyLike(requestParams.get("taskDefinitionKeyLike"));
}
if (requestParams.containsKey("dueDate")) {
request.setDueDate(RequestUtil.getDate(requestParams, "dueDate"));
}
if (requestParams.containsKey("dueBefore")) {
request.setDueBefore(RequestUtil.getDate(requestParams, "dueBefore"));
}
if (requestParams.containsKey("dueAfter")) {
request.setDueAfter(RequestUtil.getDate(requestParams, "dueAfter"));
}
if (requestParams.containsKey("active")) {
request.setActive(Boolean.valueOf(requestParams.get("active")));
}
if (requestParams.containsKey("includeTaskLocalVariables")) {
request.setIncludeTaskLocalVariables(Boolean.valueOf(requestParams.get("includeTaskLocalVariables")));
}
if (requestParams.containsKey("includeProcessVariables")) {
request.setIncludeProcessVariables(Boolean.valueOf(requestParams.get("includeProcessVariables")));
}
if (requestParams.containsKey("tenantId")) {
request.setTenantId(requestParams.get("tenantId"));
}
if (requestParams.containsKey("tenantIdLike")) {
request.setTenantIdLike(requestParams.get("tenantIdLike"));
}
if (requestParams.containsKey("withoutTenantId") && Boolean.valueOf(requestParams.get("withoutTenantId"))) {
request.setWithoutTenantId(Boolean.TRUE);
}
if (requestParams.containsKey("candidateOrAssigned")) {
request.setCandidateOrAssigned(requestParams.get("candidateOrAssigned"));
}
DataResponse dataResponse = getTasksFromQueryRequest(request, uriInfo, requestParams);
return Response.ok().entity(dataResponse).build();
// return getTasksFromQueryRequest(request, requestParams);
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class QueryExecutionService method queryProcessInstances.
@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryProcessInstances(ExecutionQueryRequest queryRequest, @Context UriInfo uriInfo) {
Map<String, String> allRequestParams = new HashMap<>();
for (String property : allPropertiesList) {
String value = uriInfo.getQueryParameters().getFirst(property);
if (value != null) {
allRequestParams.put(property, value);
}
}
DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, uriInfo);
return Response.ok().entity(dataResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse 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();
}
use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.
the class AbstractPaginateList method paginateList.
public DataResponse paginateList(Map<String, String> requestParams, PaginateRequest paginateRequest, Query query, String defaultSort, Map<String, QueryProperty> properties) {
if (paginateRequest == null) {
paginateRequest = new PaginateRequest();
}
// In case pagination request is incomplete, fill with values found in URL if possible
if (paginateRequest.getStart() == null) {
paginateRequest.setStart(RequestUtil.getInteger(requestParams, "start", 0));
}
if (paginateRequest.getSize() == null) {
paginateRequest.setSize(RequestUtil.getInteger(requestParams, "size", 10));
}
if (paginateRequest.getOrder() == null) {
paginateRequest.setOrder(requestParams.get("order"));
}
if (paginateRequest.getSort() == null) {
paginateRequest.setSort(requestParams.get("sort"));
}
// Use defaults for paging, if not set in the PaginationRequest, nor in the URL
Integer start = paginateRequest.getStart();
if (start == null || start < 0) {
start = 0;
}
Integer size = paginateRequest.getSize();
if (size == null || size < 0) {
size = 10;
}
String sort = paginateRequest.getSort();
if (sort == null) {
// id
sort = defaultSort;
}
String order = paginateRequest.getOrder();
if (order == null) {
order = "asc";
}
// Sort order
if (sort != null && !properties.isEmpty()) {
QueryProperty qp = properties.get(sort);
if (qp == null) {
throw new ActivitiIllegalArgumentException("Value for param 'sort' is not valid, '" + sort + "' is not a valid property");
}
((AbstractQuery) query).orderBy(qp);
if (order.equals("asc")) {
query.asc();
} else if (order.equals("desc")) {
query.desc();
} else {
throw new ActivitiIllegalArgumentException("Value for param 'order' is not valid : '" + order + "', must be 'asc' or 'desc'");
}
}
// Get result and set pagination parameters
List list = processList(query.listPage(start, size));
DataResponse response = new DataResponse();
response.setStart(start);
response.setSize(list.size());
response.setSort(sort);
response.setOrder(order);
response.setTotal(query.count());
response.setData(list);
return response;
}
Aggregations