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