use of org.activiti.rest.common.api.DataResponse in project Activiti by Activiti.
the class TableDataResource method getTableData.
@RequestMapping(value = "/management/tables/{tableName}/data", method = RequestMethod.GET, produces = "application/json")
public DataResponse getTableData(@PathVariable String tableName, @RequestParam Map<String, String> allRequestParams) {
// Check if table exists before continuing
if (managementService.getTableMetaData(tableName) == null) {
throw new ActivitiObjectNotFoundException("Could not find a table with name '" + tableName + "'.", String.class);
}
String orderAsc = allRequestParams.get("orderAscendingColumn");
String orderDesc = allRequestParams.get("orderDescendingColumn");
if (orderAsc != null && orderDesc != null) {
throw new ActivitiIllegalArgumentException("Only one of 'orderAscendingColumn' or 'orderDescendingColumn' can be supplied.");
}
Integer start = null;
if (allRequestParams.containsKey("start")) {
start = Integer.valueOf(allRequestParams.get("start"));
}
if (start == null) {
start = 0;
}
Integer size = null;
if (allRequestParams.containsKey("size")) {
size = Integer.valueOf(allRequestParams.get("size"));
}
if (size == null) {
size = DEFAULT_RESULT_SIZE;
}
DataResponse response = new DataResponse();
TablePageQuery tablePageQuery = managementService.createTablePageQuery().tableName(tableName);
if (orderAsc != null) {
tablePageQuery.orderAsc(orderAsc);
response.setOrder("asc");
response.setSort(orderAsc);
}
if (orderDesc != null) {
tablePageQuery.orderDesc(orderDesc);
response.setOrder("desc");
response.setSort(orderDesc);
}
TablePage listPage = tablePageQuery.listPage(start, size);
response.setSize(((Long) listPage.getSize()).intValue());
response.setStart(((Long) listPage.getFirstResult()).intValue());
response.setTotal(listPage.getTotal());
response.setData(listPage.getRows());
return response;
}
use of org.activiti.rest.common.api.DataResponse in project Activiti by Activiti.
the class DeploymentCollectionResource method getDeployments.
@RequestMapping(value = "/repository/deployments", method = RequestMethod.GET, produces = "application/json")
public DataResponse getDeployments(@RequestParam Map<String, String> allRequestParams, HttpServletRequest request) {
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
// Apply filters
if (allRequestParams.containsKey("name")) {
deploymentQuery.deploymentName(allRequestParams.get("name"));
}
if (allRequestParams.containsKey("nameLike")) {
deploymentQuery.deploymentNameLike(allRequestParams.get("nameLike"));
}
if (allRequestParams.containsKey("category")) {
deploymentQuery.deploymentCategory(allRequestParams.get("category"));
}
if (allRequestParams.containsKey("categoryNotEquals")) {
deploymentQuery.deploymentCategoryNotEquals(allRequestParams.get("categoryNotEquals"));
}
if (allRequestParams.containsKey("tenantId")) {
deploymentQuery.deploymentTenantId(allRequestParams.get("tenantId"));
}
if (allRequestParams.containsKey("tenantIdLike")) {
deploymentQuery.deploymentTenantIdLike(allRequestParams.get("tenantIdLike"));
}
if (allRequestParams.containsKey("withoutTenantId")) {
Boolean withoutTenantId = Boolean.valueOf(allRequestParams.get("withoutTenantId"));
if (withoutTenantId) {
deploymentQuery.deploymentWithoutTenantId();
}
}
DataResponse response = new DeploymentsPaginateList(restResponseFactory).paginateList(allRequestParams, deploymentQuery, "id", allowedSortProperties);
return response;
}
Aggregations