use of org.displaytag.pagination.PaginatedList in project Asqatasun by Asqatasun.
the class AbstractAuditDataHandlerController method preparePageListStatsByHttpStatusCode.
/**
*
* @param audit
* @param model
* @param httpStatusCode
* @param request
* @param returnRedirectView
* @return
* @throws ServletRequestBindingException
*/
protected String preparePageListStatsByHttpStatusCode(Audit audit, Model model, HttpStatusCodeFamily httpStatusCode, HttpServletRequest request, boolean returnRedirectView) throws ServletRequestBindingException {
String invalidTest = ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.INVALID_TEST_PARAM);
if (invalidTest != null && !this.invalidTestValueCheckerPattern.matcher(invalidTest).matches()) {
throw new ForbiddenPageException();
}
PaginatedList paginatedList = TgolPaginatedListFactory.getInstance().getPaginatedList(httpStatusCode, ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.PAGE_SIZE_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_DIRECTION_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_CRITERION_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.PAGE_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_CONTAINING_URL_PARAM), invalidTest, authorizedPageSize, authorizedSortCriterion, audit.getId());
model.addAttribute(TgolKeyStore.PAGE_LIST_KEY, paginatedList);
model.addAttribute(TgolKeyStore.AUTHORIZED_PAGE_SIZE_KEY, authorizedPageSize);
model.addAttribute(TgolKeyStore.AUTHORIZED_SORT_CRITERION_KEY, authorizedSortCriterion);
setFromToValues(paginatedList, model);
// addAuditStatisticsToModel(audit, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE);
return (returnRedirectView) ? TgolKeyStore.PAGE_LIST_XXX_VIEW_REDIRECT_NAME : TgolKeyStore.PAGE_LIST_XXX_VIEW_NAME;
}
use of org.displaytag.pagination.PaginatedList in project Asqatasun by Asqatasun.
the class TgolPaginatedListFactory method initialisePaginatedListParameters.
/**
* This methods checks the parameters passed to the page that deals with the
* pagination.
* The sort value can be set to 1 or 2. If out of bound, set 1 (default)
* The page size value can be set to 1 or 2. If out of bound, set 1 (default)
* @param paginatedList
* @param request
*/
private PaginatedList initialisePaginatedListParameters(HttpStatusCodeFamily httpStatusCode, int totalNumberOfElements, String pageSize, String sortDirection, String sortCriterion, String pageNumber, Collection<Integer> authorizedPageSize, Collection<String> authorizedSortCriterion) {
TgolPaginatedListImpl paginatedList;
// different : Mark for the 2xx and HttpStatusCode for the others
if (httpStatusCode.equals(HttpStatusCodeFamily.f2xx)) {
paginatedList = new TgolPaginatedListImpl(default2xxSortCriterion);
} else {
paginatedList = new TgolPaginatedListImpl(default3xxSortCriterion);
}
// populate the paginatedList object with default values (the sortCriterion
// is already populated at this moment.
paginatedList.setObjectsPerPage(defaultPageSize);
paginatedList.setPageNumber(defaultPageNumber);
paginatedList.setSortDirection(SortOrderEnum.ASCENDING);
setObjectsPerPage(paginatedList, totalNumberOfElements, pageSize, authorizedPageSize);
setSortDirection(paginatedList, sortDirection);
setSortCriterion(paginatedList, sortCriterion, authorizedSortCriterion);
setPageNumber(paginatedList, totalNumberOfElements, pageNumber);
paginatedList.setFullListSize(totalNumberOfElements);
return (PaginatedList) paginatedList;
}
use of org.displaytag.pagination.PaginatedList in project Asqatasun by Asqatasun.
the class TgolPaginatedListFactory method getPaginatedList.
/**
*
* @param httpStatusCode
* @param pageSize
* @param sortDirection
* @param sortCriterion
* @param pageNumber
* @param containingValue
* @param invalidTestLabel
* @param authorizedPageSize
* @param authorizedSortCriterion
* @param idAudit
* @return
*/
public PaginatedList getPaginatedList(HttpStatusCodeFamily httpStatusCode, String pageSize, String sortDirection, String sortCriterion, String pageNumber, String containingValue, String invalidTestLabel, Collection<Integer> authorizedPageSize, Collection<String> authorizedSortCriterion, long idAudit) {
// get the total number of pages for a given httpStatusCode family and
// an url filter
int totalNumberOfElements = statisticsDataService.getWebResourceCountByAuditAndHttpStatusCode(idAudit, httpStatusCode, invalidTestLabel, containingValue).intValue();
// we check the parameters of the request and populate the pageResultList object
PaginatedList paginatedList = initialisePaginatedListParameters(httpStatusCode, totalNumberOfElements, pageSize, sortDirection, sortCriterion, pageNumber, authorizedPageSize, authorizedSortCriterion);
// sql request with the given parameters
int startElement = (paginatedList.getPageNumber() - 1) * paginatedList.getObjectsPerPage();
((TgolPaginatedListImpl) paginatedList).addAllElements(statisticsDataService.getPageListByAuditAndHttpStatusCode(idAudit, httpStatusCode, invalidTestLabel, startElement, paginatedList.getObjectsPerPage(), paginatedList.getSortDirection(), paginatedList.getSortCriterion(), containingValue));
return paginatedList;
}
Aggregations