List of usage examples for org.springframework.data.domain Page getContent
List<T> getContent();
From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java
@Override public List<Message> listByApp(User user, String applicationName, int nbMessages) throws ServiceException { try {//from w w w. j a v a 2s .c om Pageable pageable = new PageRequest(0, nbMessages, sortByLastNameAsc()); Page<Message> requestedPage = messageDAO.listByApp(user, applicationName, cuInstanceName, pageable); return requestedPage.getContent(); } catch (PersistenceException e) { throw new ServiceException(e.getLocalizedMessage(), e); } }
From source file:org.wallride.web.support.Articles.java
public List<Article> search(Condition condition) { Page<Article> result = articleUtils.search(condition.buildArticleSearchRequest(), condition.size); return new ArrayList<>(result.getContent()); }
From source file:com.lixiaocong.controller.BlogController.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView blog(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int size) { ModelAndView ret = new ModelAndView("blog/list"); //?,?10/*from w ww . ja va2 s.c o m*/ Page<Article> articles = articleService.get(page - 1, size); ret.addObject("articles", articles.getContent()); //? int pageNumber = articles.getTotalPages(); if (pageNumber == 0) pageNumber++; int pageMin = page - 5 > 1 ? page - 5 : 1; int pageMax = page + 5 > pageNumber ? pageNumber : page + 5; ret.addObject("pageCurr", page); ret.addObject("pageMin", pageMin); ret.addObject("pageMax", pageMax); return ret; }
From source file:me.doshou.admin.maintain.notification.service.NotificationApiImpl.java
@Override public List<Map<String, Object>> topFiveNotification(final Long userId) { List<Map<String, Object>> dataList = Lists.newArrayList(); Searchable searchable = Searchable.newSearchable(); searchable.addSearchFilter("userId", SearchOperator.eq, userId); // searchable.addSearchFilter("read", SearchOperator.eq, Boolean.FALSE); searchable.addSort(Sort.Direction.DESC, "id"); searchable.setPage(0, 5);//w ww . j a v a 2 s . c om Page<NotificationData> page = notificationDataService.findAll(searchable); for (NotificationData data : page.getContent()) { Map<String, Object> map = Maps.newHashMap(); map.put("id", data.getId()); map.put("title", data.getTitle()); map.put("content", data.getContent()); map.put("read", data.getRead()); map.put("date", PrettyTimeUtils.prettyTime(data.getDate())); dataList.add(map); } return dataList; }
From source file:com.davidmogar.alsa.services.schedule.internal.ScheduleManagerServiceImpl.java
@Override public Page<ScheduleDto> findAll(int pageIndex) { Pageable pageable = createPageable(pageIndex); Page<Schedule> page = scheduleDataService.findAll(pageable); List<ScheduleDto> users = page.getContent().stream().map(ScheduleDto::new).collect(Collectors.toList()); return new PageImpl<>(users, pageable, page.getTotalElements()); }
From source file:example.springdata.rest.stores.StoreRepositoryIntegrationTests.java
@Test public void findsStoresByLocation() { Point location = new Point(-73.995146, 40.740337); Store store = new Store("Foo", new Address("street", "city", "zip", location)); store = repository.save(store);/*from w ww. j av a 2 s . co m*/ Page<Store> stores = repository.findByAddressLocationNear(location, new Distance(1.0, Metrics.KILOMETERS), new PageRequest(0, 10)); assertThat(stores.getContent(), hasSize(1)); assertThat(stores.getContent(), hasItem(store)); }
From source file:uiak.exper.gisamt.jpa.service.HotelRepositoryIntegrationTests.java
@Test public void executesQueryMethodsCorrectly() { City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0); assertThat(city.getName()).isEqualTo("Atlanta"); Page<HotelSummary> hotels = this.repository.findByCity(city, new PageRequest(0, 10, Direction.ASC, "name")); Hotel hotel = this.repository.findByCityAndName(city, hotels.getContent().get(0).getName()); assertThat(hotel.getName()).isEqualTo("Doubletree"); List<RatingCount> counts = this.repository.findRatingCounts(hotel); assertThat(counts).hasSize(1);// w w w . j av a 2 s .c o m assertThat(counts.get(0).getRating()).isEqualTo(Rating.AVERAGE); assertThat(counts.get(0).getCount()).isGreaterThan(1L); }
From source file:com.buaa.lzy.data.jpa.service.HotelRepositoryIntegrationTests.java
@Test public void executesQueryMethodsCorrectly() { City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0); assertThat(city.getName(), is("Atlanta")); Page<HotelSummary> hotels = this.repository.findByCity(city, new PageRequest(0, 10, Direction.ASC, "name")); Hotel hotel = this.repository.findByCityAndName(city, hotels.getContent().get(0).getName()); assertThat(hotel.getName(), is("Doubletree")); List<RatingCount> counts = this.repository.findRatingCounts(hotel); assertThat(counts, hasSize(1));// www . ja v a2s .c o m assertThat(counts.get(0).getRating(), is(Rating.AVERAGE)); assertThat(counts.get(0).getCount(), is(greaterThan(1L))); }
From source file:com.fycoder.ll.repository.TlsDaoTest.java
@Test public void findTasksByUserId() throws Exception { //Page<Tls> tls = tlsDao.findByTableNameid(2L, new PageRequest(0, 100, Direction.ASC, "id")); //Page<Tls> tls = tlsDao.findByTableNameid(); List<Long> s = new ArrayList<Long>(); s.add(0L);/*w w w . j av a 2s . c om*/ //s.add(2L); Page<Tls> tls = tlsDao.findByIdIn(s, new PageRequest(0, 100, Direction.ASC, "id")); System.out.println("111"); //assertThat(tls.size()).isEqualTo(0); assertThat(tls.getContent()).hasSize(1); //assertThat(tls.getContent().get(0).getId()).isEqualTo(1); // tls = tlsDao.findByUserId(99999L, new PageRequest(0, 100, Direction.ASC, "id")); // assertThat(tls.getContent()).isEmpty(); // assertThat(tls.getContent()).isEmpty(); }
From source file:com.oreilly.springdata.neo4j.core.ProductRepositoryIntegrationTest.java
@Test @SuppressWarnings("unchecked") public void lookupProductsByDescription() { Pageable pageable = new PageRequest(0, 1, Direction.DESC, "product.name"); // TODO JIRA Page<Product> page = repository.findByDescriptionLike("Apple", pageable); // TODO JIRA findByDescriptionContaining assertThat(page.getContent(), hasSize(1)); assertThat(page, Matchers.<Product>hasItems(named("iPad"))); assertThat(page.isFirstPage(), is(true)); //assertThat(page.isLastPage(), is(false)); // TODO JIRA //assertThat(page.hasNextPage(), is(true)); }