List of usage examples for org.springframework.data.domain Page getContent
List<T> getContent();
From source file:com.jee.shiro.web.task.TaskController.java
@RequestMapping(method = RequestMethod.GET) public String list(@RequestParam(value = "page", defaultValue = "1") int pageNumber, @RequestParam(value = "page.size", defaultValue = PAGE_SIZE) int pageSize, @RequestParam(value = "sortType", defaultValue = "auto") String sortType, Model model, ServletRequest request) {//from ww w . j a v a 2s.c o m Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_"); Long userId = getCurrentUserId(); Page<Task> tasks = taskService.getUserTask(userId, searchParams, pageNumber, pageSize, sortType); model.addAttribute("tasks", tasks); model.addAttribute("content", tasks.getContent()); model.addAttribute("sortType", sortType); model.addAttribute("sortTypes", sortTypes); // ?????URL model.addAttribute("searchParams", Servlets.encodeParameterStringWithPrefix(searchParams, "search_")); return "task/taskList"; }
From source file:com.restfiddle.controller.rest.ConversationController.java
@RequestMapping(value = "/api/conversations", method = RequestMethod.GET) public @ResponseBody PaginatedResponse<ConversationDTO> findAll( @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "limit", required = false) Integer limit) { logger.debug("Finding all items"); int pageNo = 0; if (page != null && page > 0) { pageNo = page;/*from w w w.ja v a 2 s . com*/ } int numberOfRecords = 10; if (limit != null && limit > 0) { numberOfRecords = limit; } Sort sort = new Sort(Direction.DESC, "lastModifiedDate"); Pageable topRecords = new PageRequest(pageNo, numberOfRecords, sort); Page<Conversation> result = itemRepository.findAll(topRecords); List<Conversation> content = result.getContent(); List<ConversationDTO> responseContent = new ArrayList<ConversationDTO>(); for (Conversation item : content) { responseContent.add(EntityToDTO.toDTO(item)); } PaginatedResponse<ConversationDTO> response = new PaginatedResponse<ConversationDTO>(); response.setData(responseContent); response.setLimit(numberOfRecords); response.setPage(pageNo); response.setTotalElements(result.getTotalElements()); response.setTotalPages(result.getTotalPages()); for (Conversation item : content) { RfRequest rfRequest = item.getRfRequest(); logger.debug(rfRequest.getApiUrl()); } return response; }
From source file:com.bill99.yn.webmgmt.repository.TransactionSummaryDaoTest.java
@Test public void testFindAllByCustomerId() throws Exception { Date startDateTime = Utils.parseDateTime("2014-02-17 23:57:00"); Date endDateTime = Utils.parseDateTime("2014-02-18 23:57:10"); PageRequest pageRequest = new PageRequest(0, 10); Page<TransactionSummary> transactionSummarys = transactionSummaryDao .findByCustomerNameAndSummaryDateBetween("", startDateTime, endDateTime, pageRequest); for (TransactionSummary t : transactionSummarys.getContent()) { System.out.println(t);//from www. ja v a2 s . c o m } }
From source file:de.rahn.finances.services.securities.SecuritiesServiceMetricsAspectTest.java
/** * Test method for {@link SecuritiesService#getSecurities(Pageable)}. *///from www .j a v a 2 s. com @Test public void testGetSecuritiesPageable() { Page<Security> page = serviceProxy.getSecurities(new PageRequest(0, 10)); assertThat(page, notNullValue()); assertThat(page.getContent(), notNullValue()); assertThat(page.getContent().size(), is(1)); assertThat(page.getContent(), contains(testSecurity)); assertThat(gauges.size(), is(1)); assertThat(gauges.get(0), CoreMatchers.startsWith(PREFIX_METRICNAME_TIMER)); }
From source file:com.github.vineey.rql.querydsl.test.mongo.dao.MongoDaoTest.java
@Test @UsingDataSet(locations = { "/testData.json" }, loadStrategy = LoadStrategyEnum.CLEAN_INSERT) public void rqlMongo() { String rqlFilter = "contact.name == 'A*'"; String limit = "limit(0, 10)"; String sort = "sort(+contact.id)"; RqlInput rqlInput = new RqlInput().setFilter(rqlFilter).setLimit(limit).setSort(sort); QuerydslRqlParser querydslRqlParser = new DefaultQuerydslRqlParser(); QuerydslMappingResult querydslMappingResult = querydslRqlParser.parse(rqlInput, new QuerydslMappingParam().setRootPath(user).setPathMapping(ContactMongoDao.PATH_MAP)); QueryModifiers page = querydslMappingResult.getPage(); List<OrderSpecifier> orderSpecifiers = querydslMappingResult.getOrderSpecifiers(); Page<Contact> contactPage = contactMongoDao.findAll(querydslMappingResult.getPredicate(), SpringUtil.toPageable(orderSpecifiers, page)); List<Contact> contactList = contactPage.getContent(); assertNotNull(contactList);//from www. ja va 2 s . c o m assertEquals(1, contactList.size()); assertEquals(1L, contactList.get(0).getId().longValue()); }
From source file:com.epam.ta.reportportal.database.dao.ShareableRepositoryTest.java
@Test public void testfindAllByFilter() { Set<FilterCondition> conditions = Sets.newHashSet(); Filter filter = new Filter(Dashboard.class, conditions); Page<Dashboard> dashboards = dashboardRepository.findAllByFilter(filter, new PageRequest(0, 10), "default_project", "default1"); Assert.assertNotNull(dashboards);//from w ww .j a v a 2s . com Assert.assertEquals(3, dashboards.getContent().size()); List<String> expectedIds = Lists.newArrayList("520e1f3818127ca383339f39", "520e1f3818127cad83339f40", "520e1f3818127ca383339341"); for (Dashboard dashboard : dashboards) { Assert.assertTrue(expectedIds.contains(dashboard.getId())); } }
From source file:com.searchbox.framework.service.CollectionService.java
public List<CollectionEntity<?>> findAll(int pageIndex) { LOGGER.debug("Listing all collections for page: " + pageIndex); Page<CollectionEntity<?>> requestedPage = repository.findAll(constructPageSpecification(pageIndex)); for (CollectionEntity<?> collection : requestedPage.getContent()) { setJobStatus(collection);/*from w ww. j a va 2 s . c om*/ } return requestedPage.getContent(); }
From source file:com.dickthedeployer.dick.web.service.BuildService.java
public BuildModel findLastBuild(Project project) { Page<Build> builds = buildDao.findByProject(project, new PageRequest(0, 1, Sort.Direction.DESC, "creationDate")); return builds.getContent().isEmpty() ? null : BuildMapper.mapBuild(builds.getContent().get(0)); }
From source file:org.jblogcms.core.post.service.PostServiceImpl.java
@Override @Transactional(readOnly = true)// w w w .j av a 2s. c o m public Page<Post> findBlogPosts(Long blogId, Pageable pageable, Long currentAccountId) { Page<Post> posts = postRepository.findBlogPosts(blogId, pageable); if (!posts.getContent().isEmpty()) { List<Long> postIds = new ArrayList<>(posts.getContent().size()); for (Post post : posts) { postIds.add(post.getId()); } List<Post> postList = postRepository.findPostsByPostIds(postIds); posts = new PageImpl<Post>(postList, pageable, postList.size()); posts = postToolService.addItemRatesToItemPage(posts, currentAccountId); posts = postToolService.addItemRelationsToItemPage(posts, currentAccountId); } return posts; }
From source file:app.service.CollectionService.java
private List<Collection> getFromPage(Page<Collection> colPage, boolean withUser) { List<Collection> collections = new ArrayList<>(colPage.getContent().size()); // set user field null, because what we find is just for one user // otherwise, when we need to change the data but not want to apply to the database, do like follow colPage.forEach(item -> {//from www . j a v a 2 s .c o m Collection col = new Collection(null, item.getLink(), item.getDescription(), item.getImage()); if (withUser) { col.setUser(item.getUser().cloneProfile()); } col.setId(item.getId()); col.setCreateDate(item.getCreateDate()); col.setUpdateDate(item.getUpdateDate()); collections.add(col); }); return collections; }