Example usage for org.springframework.data.domain Page getContent

List of usage examples for org.springframework.data.domain Page getContent

Introduction

In this page you can find the example usage for org.springframework.data.domain Page getContent.

Prototype

List<T> getContent();

Source Link

Document

Returns the page content as List .

Usage

From source file:jp.xet.uncommons.wicket.spring.AbstractSpringDataProvider.java

@Override
public Iterator<? extends T> iterator(int first, int count) {
    Pageable request = newPageable(first, count);
    Page<T> page = find(request);
    List<T> content = page.getContent();
    if (content.size() > count) {
        content = content.subList(0, count);
    }//from  w  ww .j a  v a 2s. com
    return content.iterator();
}

From source file:org.unidle.service.QuestionServiceImplTest.java

@Test
public void testFindAll() throws Exception {
    final Page<Question> result = subject.findAll(new PageRequest(0, 10));

    assertThat(result.getContent()).containsOnly(question);
}

From source file:org.wallride.web.controller.guest.FeedController.java

@RequestMapping("rss.xml")
public String indexRss(BlogLanguage blogLanguage, Model model) {
    ArticleSearchRequest request = new ArticleSearchRequest().withStatus(Post.Status.PUBLISHED)
            .withLanguage(blogLanguage.getLanguage());
    Page<Article> articles = articleService.getArticles(request, DEFAULT_PAGE_REQUEST);
    model.addAttribute("articles", new TreeSet<>(articles.getContent()));
    return "rssFeedView";
}

From source file:am.ik.categolj2.api.file.FileRestController.java

@RequestMapping(method = RequestMethod.GET, headers = Categolj2Headers.X_ADMIN)
public Page<FileResource> getFiles(@PageableDefault Pageable pageable) {
    Page<UploadFileSummary> summaries = uploadFileService.findPage(pageable);
    List<FileResource> resources = summaries.getContent().stream()
            .map(file -> beanMapper.map(file, FileResource.class)).collect(Collectors.toList());
    return new PageImpl<>(resources, pageable, summaries.getTotalElements());
}

From source file:com.mtt.myapp.user.controller.UserControllerTest.java

@SuppressWarnings("unchecked")
@Test/*from   ww  w  .  j  av  a  2s  .  co m*/
public void testDelete() {
    // save new user for test
    saveTestUser("NewUserId1", "NewUserName1");
    saveTestUser("NewUserId2", "NewUserName2");
    saveTestUser("NewUserId3", "NewUserName3");

    Pageable page = new PageRequest(0, 10);
    Model model = new ExtendedModelMap();

    // search
    UserSearchForm form = new UserSearchForm();
    form.setName("NewUserName");
    userController.search(form, page, model);
    Page userList = (Page<User>) model.asMap().get("users");
    assertThat(userList.getContent().size()).isSameAs(3);

    // test to delete one
    userController.delete("NewUserId1");
    model = new ExtendedModelMap();
    userController.search(form, page, model);
    userList = (Page<User>) model.asMap().get("users");
    assertThat(userList.getContent().size()).isSameAs(2);

    // test to delete more
    model = new ExtendedModelMap();
    userController.delete("NewUserId2,NewUserId3");
    userController.search(form, page, model);
    userList = (Page<User>) model.asMap().get("users");
    assertThat(userList.getContent().size()).isSameAs(0);
}

From source file:org.wallride.web.controller.guest.FeedController.java

@RequestMapping("category/{categoryCode}/rss.xml")
public String categoryRss(@PathVariable String categoryCode, BlogLanguage blogLanguage, Model model) {
    Category category = categoryService.getCategoryByCode(categoryCode, blogLanguage.getLanguage());
    List<Long> categoryIds = new ArrayList<>();
    categoryIds.add(category.getId());/*from w ww . jav a  2  s. c om*/

    ArticleSearchRequest request = new ArticleSearchRequest().withStatus(Post.Status.PUBLISHED)
            .withLanguage(blogLanguage.getLanguage()).withCategoryIds(categoryIds);

    Page<Article> articles = articleService.getArticles(request, DEFAULT_PAGE_REQUEST);
    model.addAttribute("articles", new TreeSet<>(articles.getContent()));
    return "rssFeedView";
}

From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java

@Override
public List<Message> listByUser(User user, int nbRows) throws ServiceException {
    try {/*  www  . ja  v a  2 s  .co  m*/
        Pageable pageable = new PageRequest(0, nbRows, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByUserAndCuInstance(user, cuInstanceName, pageable);
        return requestedPage.getContent();
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java

@Override
public List<Message> listByUserNoLimitRows(User user) throws ServiceException {
    try {//from  w w w .jav  a2  s .c om
        Pageable pageable = new PageRequest(0, 500, sortByLastNameAsc());
        Page<Message> requestedPage = messageDAO.listByUserAndCuInstance(user, cuInstanceName, pageable);
        return requestedPage.getContent();
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:org.javaweb.elasticsearch.core.ElasticsearchTemplate.java

/**
 * /* ww  w. java 2s  .c  om*/
 *
 * @param searchRequest
 * @param clazz
 * @return
 */
@Override
public <T> List<T> queryForList(SearchRequest searchRequest, Class<T> clazz) {
    Page<T> pages = queryForPage(searchRequest, clazz);
    if (pages != null) {
        return pages.getContent();
    }
    return new ArrayList<T>();
}

From source file:org.openlmis.fulfillment.repository.ShipmentDraftRepositoryIntegrationTest.java

@Test
public void shouldFindShipmentDraftPageByOrder() {
    ShipmentDraft save = shipmentDraftRepository.save(generateInstance());

    Page<ShipmentDraft> page = shipmentDraftRepository.findByOrder(order, createPageable(10, 0));

    assertEquals(1, page.getContent().size());
    assertEquals(save.getId(), page.getContent().get(0).getId());

    assertEquals(10, page.getSize());//from  w ww.j a  v a 2s .c o  m
    assertEquals(0, page.getNumber());
    assertEquals(1, page.getNumberOfElements());
    assertEquals(1, page.getTotalElements());
    assertEquals(1, page.getTotalPages());
}