Example usage for org.springframework.data.domain Pageable getPageNumber

List of usage examples for org.springframework.data.domain Pageable getPageNumber

Introduction

In this page you can find the example usage for org.springframework.data.domain Pageable getPageNumber.

Prototype

int getPageNumber();

Source Link

Document

Returns the page to be returned.

Usage

From source file:org.oncoblocks.centromere.web.controller.RequestUtils.java

/**
 * Uses annotated {@link Model} class definitions to remap any request attribute names in a 
 *   {@link Pageable} so that they match repository attribute names.
 *
 * @param pageable {@link Pageable}/*from  w w  w . j  a  va2  s .  co  m*/
 * @return
 */
public static Pageable remapPageable(Pageable pageable, Class<? extends Model<?>> model) {
    logger.debug("Attempting to remap Pageable parameter names.");
    Sort sort = null;
    if (pageable.getSort() != null) {
        List<Sort.Order> orders = new ArrayList<>();
        for (Sort.Order order : pageable.getSort()) {
            orders.add(new Sort.Order(order.getDirection(), remapParameterName(order.getProperty(), model)));
        }
        sort = new Sort(orders);
    }
    return new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), sort);
}

From source file:io.kahu.hawaii.util.call.sql.QueryEnhancer.java

default void addPaging(Map<String, Object> params, Pageable pageable) {
    params.put("start_index", pageable.getPageNumber() * pageable.getPageSize() + 1);
    params.put("end_index", (pageable.getPageNumber() + 1) * pageable.getPageSize());
}

From source file:com.pamarin.income.lazyload.TagLazy.java

@Override
public Page<Tag> loadPage(Pageable page) {
    PageRequest request = new PageRequest(page.getPageNumber(), page.getPageSize(), Sort.Direction.ASC, "name");

    return service.findByOwner(SecurityUtils.getUser(), request);
}

From source file:it.f2informatica.webapp.controller.NavBarController.java

@RequestMapping(value = { "/consultant", "/consultants" }, method = RequestMethod.GET)
public String consultantManagementPage(ModelMap model, Pageable pageable) {
    Pageable pageRequest = new PageRequest(pageable.getPageNumber(), 5, Sort.Direction.DESC,
            "registrationDate");
    model.addAttribute("page", consultantService.paginateConsultants(pageRequest));
    model.addAttribute("searchCriteria", new ConsultantSearchCriteria());
    model.addAttribute(SessionAttribute.NAVBAR_ITEM_ACTIVE, 2);
    return "consultant/consultants";
}

From source file:com.feedeo.shopify.service.web.product.ProductWebServiceImpl.java

@Override
public Page<Product> getAll(final Pageable page) {
    checkNotNull(page);//w  w  w  .ja v  a2  s . c om
    return _getAll(page.getPageNumber(), page.getPageSize(), null);
}

From source file:com.github.fauu.natrank.web.controller.MatchController.java

private PageRequest createPageRequest(Pageable pageable, Sort.Direction direction) {
    return new PageRequest(pageable.getPageNumber(), RECORDS_PER_PAGE, direction, "id");
}

From source file:com.feedeo.shopify.service.web.product.ProductWebServiceImpl.java

@Override
public Page<Product> getAll(final Pageable page, final String[] select) {
    checkNotNull(page);/*from  w  w w .j a  va  2s  .co  m*/
    return _getAll(page.getPageNumber(), page.getPageSize(), select);
}

From source file:com.pos.web.ArInvController.java

@RequestMapping(value = "/ar-inv", method = RequestMethod.GET)
@ResponseBody/*from   ww  w.  j a v a 2 s . c  om*/
public Page<ArInv> listAll(@RequestParam(required = false) String search, Pageable pageable,
        HttpServletResponse response) {
    PageRequest pr = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.ASC,
            "nama");
    logger.debug("pageNumber [{}], pageSize: [{}]", pageable.getPageNumber(), pageable.getPageSize());
    return dao.findAll(pr);
}

From source file:com.pos.web.MasterKotaCtrl.java

@RequestMapping(value = "/kota", method = RequestMethod.GET)
@ResponseBody/*  w w  w .  ja v a2 s.c o  m*/
public Page<Kota> listAll(@RequestParam(required = false) String search, Pageable pageable,
        HttpServletResponse response) {
    PageRequest pr = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.ASC,
            "nama");
    logger.debug("pageNumber [{}], pageSize: [{}]", pageable.getPageNumber(), pageable.getPageSize());
    return kotaDao.findAll(pr);
}

From source file:com.trenako.services.BrandsServiceImpl.java

@Override
public Page<Brand> findAll(Pageable pageable) {
    if (pageable.getSort() == null) {
        pageable = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), NAME_SORT);
    }// w  ww .j ava 2s .c o  m
    return repo.findAll(pageable);
}