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

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

Introduction

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

Prototype

int getPageSize();

Source Link

Document

Returns the number of items to be returned.

Usage

From source file:org.yukung.daguerreo.domain.repository.BasicJooqRepository.java

private SelectQuery<R> getQuery(Pageable pageable) {
    SelectQuery<R> query = getQuery(pageable.getSort());
    query.addLimit(pageable.getOffset(), pageable.getPageSize());
    return query;
}

From source file:com.frank.search.solr.core.query.SimpleQuery.java

/**
 * @param criteria//from   w w  w .ja  v  a2s.c o  m
 * @param pageable
 */
public SimpleQuery(Criteria criteria, Pageable pageable) {
    super(criteria);

    if (pageable != null) {
        this.offset = pageable.getOffset();
        this.rows = pageable.getPageSize();
        this.addSort(pageable.getSort());
    }
}

From source file:org.socialsignin.spring.data.dynamodb.repository.support.SimpleDynamoDBPagingAndSortingRepository.java

@Override
public Page<T> findAll(Pageable pageable) {

    if (pageable.getSort() != null) {
        throw new UnsupportedOperationException("Sorting not supported for find all scan operations");
    }/*from ww w  .ja v  a 2 s  .c o m*/

    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
    // Scan to the end of the page after the requested page
    int scanTo = pageable.getOffset() + (2 * pageable.getPageSize());
    scanExpression.setLimit(scanTo);
    PaginatedScanList<T> paginatedScanList = dynamoDBOperations.scan(domainType, scanExpression);
    Iterator<T> iterator = paginatedScanList.iterator();
    int processedCount = 0;
    if (pageable.getOffset() > 0) {
        processedCount = scanThroughResults(iterator, pageable.getOffset());
        if (processedCount < pageable.getOffset())
            return new PageImpl<T>(new ArrayList<T>());
    }
    // Scan ahead to retrieve the next page count
    List<T> results = readPageOfResults(iterator, pageable.getPageSize());

    assertScanEnabled(enableScanPermissions.isFindAllPaginatedScanEnabled(), "findAll(Pageable pageable)");
    assertScanCountEnabled(enableScanPermissions.isFindAllUnpaginatedScanCountEnabled(),
            "findAll(Pageable pageable)");

    int totalCount = dynamoDBOperations.count(domainType, scanExpression);

    return new PageImpl<T>(results, pageable, totalCount);

}

From source file:de.appsolve.padelcampus.db.dao.generic.BaseEntityDAO.java

private Criteria getPageableCriteria(Pageable pageable) {
    Criteria criteria = getCriteria();/*from  ww  w. java2s .c  o m*/
    addOrderBy(criteria, pageable);
    criteria.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
    criteria.setMaxResults(pageable.getPageSize());
    return criteria;
}

From source file:cz.jirutka.spring.data.jdbc.sql.DefaultSqlGenerator.java

public String selectAll(TableDescription table, Pageable page) {
    Sort sort = page.getSort() != null ? page.getSort() : sortById(table);

    return format(
            "SELECT t2__.* FROM ( " + "SELECT row_number() OVER (ORDER BY %s) AS rn__, t1__.* FROM ( %s ) t1__ "
                    + ") t2__ WHERE t2__.rn__ BETWEEN %s AND %s",
            orderByExpression(sort), selectAll(table), page.getOffset() + 1,
            page.getOffset() + page.getPageSize());
}

From source file:com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider.java

protected void appendOffset(StringBuilder bldr, Pageable pageable) {
    bldr.append(" LIMIT ").append(pageable.getPageSize()).append(" OFFSET ").append(pageable.getOffset());
}

From source file:com.sishuok.es.common.repository.support.SimpleBaseRepository.java

/**
 * Reads the given {@link javax.persistence.TypedQuery} into a {@link org.springframework.data.domain.Page} applying the given {@link org.springframework.data.domain.Pageable} and
 * {@link org.springframework.data.jpa.domain.Specification}.
 *
 * @param query    must not be {@literal null}.
 * @param spec     can be {@literal null}.
 * @param pageable can be {@literal null}.
 * @return/*from   w  w w.j  ava2 s.  c  o  m*/
 */
private Page<M> readPage(TypedQuery<M> query, Pageable pageable, Specification<M> spec) {

    query.setFirstResult(pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());

    Long total = QueryUtils.executeCountQuery(getCountQuery(spec));
    List<M> content = total > pageable.getOffset() ? query.getResultList() : Collections.<M>emptyList();

    return new PageImpl<M>(content, pageable, total);
}

From source file:com.luna.common.repository.support.SimpleBaseRepository.java

/**
 * Reads the given {@link javax.persistence.TypedQuery} into a {@link org.springframework.data.domain.Page} applying the given {@link org.springframework.data.domain.Pageable} and
 * {@link org.springframework.data.jpa.domain.Specification}.
 *
 * @param query    must not be {@literal null}.
 * @param spec     can be {@literal null}.
 * @param pageable can be {@literal null}.
 * @return/*  w ww.ja v  a2  s .  c om*/
 */
protected Page<M> readPage(TypedQuery<M> query, Pageable pageable, Specification<M> spec) {

    query.setFirstResult(pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());

    Long total = QueryUtils.executeCountQuery(getCountQuery(spec));
    List<M> content = total > pageable.getOffset() ? query.getResultList() : Collections.<M>emptyList();

    return new PageImpl<M>(content, pageable, total);
}

From source file:org.ngrinder.user.controller.UserController.java

/**
 * Get user list on the given role.//from w  ww .  ja  v  a2 s. c  o m
 *
 * @param model    model
 * @param role     role
 * @param pageable page info
 * @param keywords search keyword.
 * @return user/userList
 */
@PreAuthorize("hasAnyRole('A')")
@RequestMapping({ "", "/" })
public String getAll(ModelMap model, @RequestParam(required = false) Role role,
        @PageableDefaults Pageable pageable, @RequestParam(required = false) String keywords) {

    pageable = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(),
            defaultIfNull(pageable.getSort(), new Sort(Direction.ASC, "userName")));
    Page<User> pagedUser;
    if (StringUtils.isEmpty(keywords)) {
        pagedUser = userService.getPagedAll(role, pageable);
    } else {
        pagedUser = userService.getPagedAll(keywords, pageable);
        model.put("keywords", keywords);
    }
    model.addAttribute("users", pagedUser);
    EnumSet<Role> roleSet = EnumSet.allOf(Role.class);
    model.addAttribute("roleSet", roleSet);
    model.addAttribute("role", role);
    putPageIntoModelMap(model, pageable);
    return "user/list";
}

From source file:cn.guoyukun.spring.jpa.repository.support.SimpleBaseRepository.java

/**
 * Reads the given {@link javax.persistence.TypedQuery} into a {@link org.springframework.data.domain.Page} applying the given {@link org.springframework.data.domain.Pageable} and
 * {@link org.springframework.data.jpa.domain.Specification}.
 *
 * @param query    must not be {@literal null}.
 * @param spec     can be {@literal null}.
 * @param pageable can be {@literal null}.
 * @return// w ww  .j a  v a  2 s .  co m
 */
@Override
protected Page<M> readPage(TypedQuery<M> query, Pageable pageable, Specification<M> spec) {

    query.setFirstResult(pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());

    Long total = QueryUtils.executeCountQuery(getCountQuery(spec));
    List<M> content = total > pageable.getOffset() ? query.getResultList() : Collections.<M>emptyList();

    return new PageImpl4jqgrid<M>(content, pageable, total);
}