Search in sources :

Example 1 with DataResponse

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;
}
Also used : TablePage(org.activiti.engine.management.TablePage) DataResponse(org.activiti.rest.common.api.DataResponse) TablePageQuery(org.activiti.engine.management.TablePageQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DataResponse

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;
}
Also used : DeploymentQuery(org.activiti.engine.repository.DeploymentQuery) DataResponse(org.activiti.rest.common.api.DataResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataResponse (org.activiti.rest.common.api.DataResponse)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 TablePage (org.activiti.engine.management.TablePage)1 TablePageQuery (org.activiti.engine.management.TablePageQuery)1 DeploymentQuery (org.activiti.engine.repository.DeploymentQuery)1