use of org.springframework.data.domain.Pageable in project spring-data-mongodb by spring-projects.
the class AbstractMongoQueryUnitTests method slicedExecutionShouldRetainSort.
// DATAMONGO-1057
@Test
void slicedExecutionShouldRetainSort() {
MongoQueryFake query = createQueryForMethod("findByLastname", String.class, Pageable.class);
Pageable page1 = PageRequest.of(0, 10, Sort.Direction.DESC, "bar");
Pageable page2 = page1.next();
query.execute(new Object[] { "fake", page1 });
query.execute(new Object[] { "fake", page2 });
ArgumentCaptor<Query> captor = ArgumentCaptor.forClass(Query.class);
verify(executableFind, times(2)).as(Person.class);
verify(withQueryMock, times(2)).matching(captor.capture());
Document expectedSortObject = new Document().append("bar", -1);
assertThat(captor.getAllValues().get(0).getSortObject()).isEqualTo(expectedSortObject);
assertThat(captor.getAllValues().get(1).getSortObject()).isEqualTo(expectedSortObject);
}
use of org.springframework.data.domain.Pageable in project oc-explorer by devgateway.
the class OcdsController method ocdsReleasesCount.
/**
* Returns a list of OCDS Releases, order by Id, using pagination
*
* @return the release data
*/
@ApiOperation(value = "Counts releases, filter by given criteria")
@RequestMapping(value = "/api/ocds/release/count", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
@Cacheable
public Long ocdsReleasesCount(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
Pageable pageRequest = new PageRequest(releaseRequest.getPageNumber(), releaseRequest.getPageSize(), Direction.ASC, "id");
Query query = query(getYearDefaultFilterCriteria(releaseRequest, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)).with(pageRequest);
return mongoTemplate.count(query, Release.class);
}
use of org.springframework.data.domain.Pageable in project summer by foxsugar.
the class GameUserService method getRebateDetails1.
public int getRebateDetails1(KafkaMsgKey msgKey, long userId, String date, int index) {
// sendMsg(msgKey, new ResponseVo("userService", "getRebateDetails", rebateDetailService.rebateDetailDao.findAllByAgentId(userId)));
// LocalDate localDate = LocalDate.now();
// String date = localDate.minusDays(7).toString();
String d1 = date + " 00:00:00";
String d2 = date + " 23:59:59";
Date date1 = DateUtil.convert2DateTime(d1);
Date date2 = DateUtil.convert2DateTime(d2);
// 创建时间降序排序
Sort sort = new Sort(Sort.Direction.DESC, "date");
Pageable pageable = new PageRequest(index, 30, sort);
sendMsg(msgKey, new ResponseVo("userService", "getRebateDetails1", rebateDetailService.rebateDetailDao.findAllByAgentIdAndDateAfterAndDateBefore(userId, date1, date2, pageable)));
return 0;
}
use of org.springframework.data.domain.Pageable in project Saturn by vipshop.
the class JobOverviewController method getJobOverviewByStatusAndPage.
private JobOverviewVo getJobOverviewByStatusAndPage(String namespace, JobStatus jobStatus, Map<String, Object> condition, int page, int size) throws SaturnJobConsoleException {
JobOverviewVo jobOverviewVo = new JobOverviewVo();
try {
preHandleStatusAndCondition(condition, jobStatus);
List<JobConfig4DB> unSystemJobs = jobService.getUnSystemJobsWithCondition(namespace, condition, page, size);
if (unSystemJobs == null || unSystemJobs.isEmpty()) {
jobOverviewVo.setJobs(Lists.<JobOverviewJobVo>newArrayList());
jobOverviewVo.setTotalNumber(0);
return jobOverviewVo;
}
Pageable pageable = PageableUtil.generatePageble(page, size);
// 当 jobStatus 为null时,底层取数据已经做了分页,此处无需再次分页
List<JobConfig4DB> targetJobs = jobStatus == null ? unSystemJobs : getJobSubListByPage(unSystemJobs, pageable);
List<JobOverviewJobVo> jobOverviewList = updateJobOverviewDetail(namespace, targetJobs, jobStatus);
jobOverviewVo.setJobs(jobOverviewList);
jobOverviewVo.setTotalNumber(jobService.countUnSystemJobsWithCondition(namespace, condition));
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleException(e);
}
return jobOverviewVo;
}
use of org.springframework.data.domain.Pageable in project kylo by Teradata.
the class OpsManagerFeedRepositoryTest method findAll_TwoPages.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin", "user" })
@Test
public void findAll_TwoPages() throws Exception {
JpaOpsManagerFeed feed1 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed1-name");
repo.save(feed1);
BaseFeed.FeedId feed1Id = new BaseFeed.FeedId(feed1.getId().getUuid());
JpaFeedOpsAclEntry acl1 = new JpaFeedOpsAclEntry(feed1Id, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl1);
JpaOpsManagerFeed feed2 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed2-name");
repo.save(feed2);
BaseFeed.FeedId feed2Id = new BaseFeed.FeedId(feed2.getId().getUuid());
JpaFeedOpsAclEntry acl2 = new JpaFeedOpsAclEntry(feed2Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl2);
JpaOpsManagerFeed feed3 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed3-name");
repo.save(feed3);
BaseFeed.FeedId feed3Id = new BaseFeed.FeedId(feed3.getId().getUuid());
JpaFeedOpsAclEntry acl3 = new JpaFeedOpsAclEntry(feed3Id, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl3);
JpaOpsManagerFeed feed4 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed4-name");
repo.save(feed4);
BaseFeed.FeedId feed4Id = new BaseFeed.FeedId(feed4.getId().getUuid());
JpaFeedOpsAclEntry acl4 = new JpaFeedOpsAclEntry(feed4Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl4);
JpaOpsManagerFeed feed5 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed5-name");
repo.save(feed5);
BaseFeed.FeedId feed5Id = new BaseFeed.FeedId(feed5.getId().getUuid());
JpaFeedOpsAclEntry acl5 = new JpaFeedOpsAclEntry(feed5Id, "NON_MATCHING", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl5);
JpaOpsManagerFeed feed6 = new JpaOpsManagerFeed(OpsManagerFeedId.create(), "feed6-name");
repo.save(feed6);
BaseFeed.FeedId feed6Id = new BaseFeed.FeedId(feed6.getId().getUuid());
JpaFeedOpsAclEntry acl6 = new JpaFeedOpsAclEntry(feed6Id, "user", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclRepo.save(acl6);
Pageable page1Request = new PageRequest(0, 2);
Page<JpaOpsManagerFeed> page1 = repo.findAll(page1Request);
Assert.assertEquals(0, page1.getNumber());
Assert.assertEquals(2, page1.getNumberOfElements());
Assert.assertEquals(2, page1.getTotalPages());
Assert.assertEquals(4, page1.getTotalElements());
Pageable page2Request = new PageRequest(1, 2);
Page<JpaOpsManagerFeed> page2 = repo.findAll(page2Request);
Assert.assertEquals(1, page2.getNumber());
Assert.assertEquals(2, page2.getNumberOfElements());
Assert.assertEquals(2, page2.getTotalPages());
Assert.assertEquals(4, page2.getTotalElements());
}
Aggregations