Package org.springframework.data.domain

Examples of org.springframework.data.domain.PageImpl


    Pageable page = new PageRequest(0, 10);

    // search
    userController.getAll(model, null, page, "NewUserName");
    PageImpl userList = (PageImpl<User>) model.get("users");
    assertThat(userList.getContent().size(), is(3));

    // test to delete one
    model.clear();
    userController.delete(testUser, "NewUserId1", model);
    model.clear();
    userController.getAll(model, Role.USER, page, "NewUserName");
    userList = (PageImpl<User>) model.get("users");
    assertThat(userList.getContent().size(), is(2));

    // test to delete more
    model.clear();
    userController.delete(testUser, "NewUserId2,NewUserId3", model);
    model.clear();
    userController.getAll(model, Role.USER, page, "NewUserName");
    userList = (PageImpl<User>) model.get("users");
    assertThat(userList.getContent().size(), is(0));
  }
View Full Code Here


     * @return
     */
    public Page<User> findAllByDefault(final Searchable searchable) {
        long total = countAllByDefault(searchable);
        List<User> contentList = repositoryHelper.findAll(findAllQL, searchable, SearchCallback.DEFAULT);
        return new PageImpl(contentList, searchable.getPage(), total);
    }
View Full Code Here

     * @return
     */
    public Page<User> findAllByCustom(final Searchable searchable) {
        long total = countAllByCustom(searchable);
        List<User> contentList = repositoryHelper.findAll(findAllQL, searchable, customSearchCallback);
        return new PageImpl(contentList, searchable.getPage(), total);
    }
View Full Code Here

                        Query countQuery = em.createNativeQuery(countSQL);
                        Query findQuery = em.createNativeQuery(findSQL);
                        findQuery.setFirstResult(pageable.getOffset());
                        findQuery.setMaxResults(pageable.getPageSize());

                        Page page = new PageImpl(
                                findQuery.getResultList(),
                                pageable,
                                ((BigInteger) countQuery.getSingleResult()).longValue());

                        model.addAttribute("resultPage", page);
View Full Code Here

                    Query countQuery = em.createQuery(countQL);
                    Query findQuery = em.createQuery(findQL);
                    findQuery.setFirstResult(pageable.getOffset());
                    findQuery.setMaxResults(pageable.getPageSize());

                    Page page = new PageImpl(
                            findQuery.getResultList(),
                            pageable,
                            (Long) countQuery.getSingleResult());

                    model.addAttribute("resultPage", page);
View Full Code Here

    }
   
    @Test
    public void search() {
        List<Person> expected = new ArrayList<Person>();
        Page expectedPage = new PageImpl(expected);
        when(personRepositoryMock.findAll(any(Specification.class), any(Pageable.class))).thenReturn(expectedPage);
       
        List<Person> actual = personService.search(SEARCH_TERM, PAGE_INDEX);

        ArgumentCaptor<Pageable> pageArgument = ArgumentCaptor.forClass(Pageable.class);
View Full Code Here

        }

        @SuppressWarnings({"unchecked"})
        protected Object createPage(Iterable<?> result, Pageable pageable) {
            final List resultList = IteratorUtil.addToCollection(result, new ArrayList());
            if (pageable==null) return new PageImpl(resultList);
            final int currentTotal = pageable.getOffset() + pageable.getPageSize();
            return new PageImpl(resultList, pageable, currentTotal);
        }
View Full Code Here

        return executeFind(query.setPageRequest(new SolrPageRequest(0, getLimit()))).getContent();
      }

      if (getLimit() > 0) {
        if (pageable.getOffset() > getLimit()) {
          return new PageImpl(java.util.Collections.emptyList(), pageable, getLimit());
        }
        if (pageable.getOffset() + pageable.getPageSize() > getLimit()) {
          query.setPageRequest(getLimitingPageable(pageable, getLimit() - pageable.getOffset()));
        }
      }
View Full Code Here

          pageToUse = new SolrPageRequest(0, limit);
        }

        if (limit > 0) {
          if (pageToUse.getOffset() > limit) {
            return new PageImpl(java.util.Collections.emptyList(), pageToUse, limit);
          }
          if (pageToUse.getOffset() + pageToUse.getPageSize() > limit) {
            pageToUse = getLimitingPageable(pageToUse, limit - pageToUse.getOffset());
          }
        }
View Full Code Here

      if (overallLimit != 0 && pageable.getOffset() + pageable.getPageSize() > overallLimit) {
        query.limit(overallLimit - pageable.getOffset());
      }

      List<?> result = operations.find(query, metadata.getJavaType(), metadata.getCollectionName());
      return new PageImpl(result, pageable, count);
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.PageImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.