Search in sources :

Example 1 with TablePage

use of org.activiti.engine.management.TablePage in project Activiti by Activiti.

the class TableDataManager method getTablePage.

@SuppressWarnings("unchecked")
public TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults) {
    TablePage tablePage = new TablePage();
    @SuppressWarnings("rawtypes") List tableData = getDbSqlSession().getSqlSession().selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults));
    tablePage.setTableName(tablePageQuery.getTableName());
    tablePage.setTotal(getTableCount(tablePageQuery.getTableName()));
    tablePage.setRows((List<Map<String, Object>>) tableData);
    tablePage.setFirstResult(firstResult);
    return tablePage;
}
Also used : TablePage(org.activiti.engine.management.TablePage) RowBounds(org.apache.ibatis.session.RowBounds) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with TablePage

use of org.activiti.engine.management.TablePage 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 3 with TablePage

use of org.activiti.engine.management.TablePage in project carbon-business-process by wso2.

the class ManagementService method getTableData.

@GET
@Path("/tables/{tableName}/data")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DataResponse getTableData(@PathParam("tableName") String tableName) {
    Map<String, String> allRequestParams = new HashMap<>();
    // 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 = uriInfo.getQueryParameters().getFirst("orderAscendingColumn");
    String orderDesc = uriInfo.getQueryParameters().getFirst("orderDescendingColumn");
    if (orderAsc != null && orderDesc != null) {
        throw new ActivitiIllegalArgumentException("Only one of 'orderAscendingColumn' or 'orderDescendingColumn' can be supplied.");
    }
    allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
    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) {
        allRequestParams.put("orderAscendingColumn", orderAsc);
        tablePageQuery.orderAsc(orderAsc);
        response.setOrder("asc");
        response.setSort(orderAsc);
    }
    if (orderDesc != null) {
        allRequestParams.put("orderDescendingColumn", orderDesc);
        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((List) listPage.getRows());
    return response;
}
Also used : TablePage(org.activiti.engine.management.TablePage) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) TablePageQuery(org.activiti.engine.management.TablePageQuery)

Example 4 with TablePage

use of org.activiti.engine.management.TablePage in project Activiti by Activiti.

the class TablePageQueryTest method testGetTablePage.

public void testGetTablePage() {
    String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix();
    List<String> taskIds = generateDummyTasks(20);
    TablePage tablePage = managementService.createTablePageQuery().tableName(tablePrefix + "ACT_RU_TASK").listPage(0, 5);
    assertThat(tablePage.getFirstResult()).isEqualTo(0);
    assertThat(tablePage.getSize()).isEqualTo(5);
    assertThat(tablePage.getRows()).hasSize(5);
    assertThat(tablePage.getTotal()).isEqualTo(20);
    tablePage = managementService.createTablePageQuery().tableName(tablePrefix + "ACT_RU_TASK").listPage(14, 10);
    assertThat(tablePage.getFirstResult()).isEqualTo(14);
    assertThat(tablePage.getSize()).isEqualTo(6);
    assertThat(tablePage.getRows()).hasSize(6);
    assertThat(tablePage.getTotal()).isEqualTo(20);
    taskService.deleteTasks(taskIds, true);
}
Also used : TablePage(org.activiti.engine.management.TablePage)

Example 5 with TablePage

use of org.activiti.engine.management.TablePage in project Activiti by Activiti.

the class TableDataManagerImpl method getTablePage.

@Override
@SuppressWarnings("unchecked")
public TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults) {
    TablePage tablePage = new TablePage();
    @SuppressWarnings("rawtypes") List tableData = getDbSqlSession().getSqlSession().selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults));
    tablePage.setTableName(tablePageQuery.getTableName());
    tablePage.setTotal(getTableCount(tablePageQuery.getTableName()));
    tablePage.setRows((List<Map<String, Object>>) tableData);
    tablePage.setFirstResult(firstResult);
    return tablePage;
}
Also used : TablePage(org.activiti.engine.management.TablePage) RowBounds(org.apache.ibatis.session.RowBounds) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap)

Aggregations

TablePage (org.activiti.engine.management.TablePage)6 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 TablePageQuery (org.activiti.engine.management.TablePageQuery)2 RowBounds (org.apache.ibatis.session.RowBounds)2 Collections.singletonMap (java.util.Collections.singletonMap)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 DataResponse (org.activiti.rest.common.api.DataResponse)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)1