Here are the examples of the java api org.springframework.data.domain.PageRequest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
399 Examples
19
View Source File : NotificationReadingService.java
License : Apache License 2.0
Project Creator : zhcet-amu
License : Apache License 2.0
Project Creator : zhcet-amu
public Page<NotificationRecipient> getNotifications(int page) {
String userId = Auditor.getLoggedInUsername();
PageRequest pageRequest = PageRequest.of(page - 1, PAGE_SIZE, Sort.Direction.DESC, "notification.sentTime");
return notificationRecipientRepository.findByRecipientUserId(userId, pageRequest);
}
19
View Source File : ExchangeCoinService.java
License : Apache License 2.0
Project Creator : xunibidev
License : Apache License 2.0
Project Creator : xunibidev
public Page<ExchangeCoin> pageQuery(int pageNo, Integer pageSize) {
Sort orders = Criteria.sortStatic("sort");
PageRequest pageRequest = new PageRequest(pageNo - 1, pageSize, orders);
return coinRepository.findAll(pageRequest);
}
19
View Source File : InitPlateService.java
License : Apache License 2.0
Project Creator : xunibidev
License : Apache License 2.0
Project Creator : xunibidev
public Page<InitPlate> findAllByPage(Criteria<InitPlate> specification, PageRequest pageRequest) {
return initPlateDao.findAll(specification, pageRequest);
}
19
View Source File : CertificationFixture.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
/*
Service 테스트에서는 Repository를 Mocking하기 때문에 컨텐츠는 하나지만 총 4개인 것 처럼 만들었습니다.
(Mocking하면 첫 페이지에 1개만 보여달라해도 4개의 컨텐츠를 모두 보여주기 떄문에)
*/
public static Page<Certification> createMockPagedCertifications(final PageRequest request) {
final List<Certification> mockCertifications = Arrays.asList(createCertificationWithId());
return new PageImpl<>(mockCertifications, request, 4);
}
19
View Source File : RoleServiceImpl.java
License : Apache License 2.0
Project Creator : tomsun28
License : Apache License 2.0
Project Creator : tomsun28
@Override
public Page<AuthRoleDO> getPageRole(Integer currentPage, Integer pageSize) {
PageRequest pageRequest = PageRequest.of(currentPage, pageSize);
return authRoleDao.findAll(pageRequest);
}
19
View Source File : RoleServiceImpl.java
License : Apache License 2.0
Project Creator : tomsun28
License : Apache License 2.0
Project Creator : tomsun28
@Override
public Page<AuthResourceDO> getPageResourceOwnRole(Long roleId, Integer currentPage, Integer pageSize) {
PageRequest pageRequest = PageRequest.of(currentPage, pageSize, Sort.Direction.ASC, "id");
return authResourceDao.findRoleOwnResource(roleId, pageRequest);
}
19
View Source File : ResourceServiceImpl.java
License : Apache License 2.0
Project Creator : tomsun28
License : Apache License 2.0
Project Creator : tomsun28
@Override
public Page<AuthResourceDO> getPageResource(Integer currentPage, Integer pageSize) {
PageRequest pageRequest = PageRequest.of(currentPage, pageSize);
return authResourceDao.findAll(pageRequest);
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : sunyl-git
License : Apache License 2.0
Project Creator : sunyl-git
@Override
public Page<User> findUserByPage(Integer starPage, Integer itemNumber) {
PageRequest pageRequest = new PageRequest(starPage, itemNumber);
return userRepository.findAll(pageRequest);
}
19
View Source File : UserServiceImpl.java
License : Apache License 2.0
Project Creator : sunyl-git
License : Apache License 2.0
Project Creator : sunyl-git
@Override
public Page<User> findUserByPageAndOrder(Integer starPage, Integer itemNumber) {
List<Sort.Order> orders = new ArrayList<>();
// orders.add(new Sort.Order(Sort.Direction.DESC,"name"));
orders.add(new Sort.Order(Sort.Direction.DESC, "id"));
// orders.add(new Sort.Order(Sort.Direction.ASC,"parentId"));
PageRequest pageRequest = new PageRequest(starPage, itemNumber, new Sort(orders));
return userRepository.findAll(pageRequest);
}
19
View Source File : MessagesBroadcastController.java
License : GNU Affero General Public License v3.0
Project Creator : retro-game
License : GNU Affero General Public License v3.0
Project Creator : retro-game
@GetMapping("/messages/broadcast")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String messages(@RequestParam(name = "body") long bodyId, @RequestParam(required = false, defaultValue = "1") @Min(1) int page, @RequestParam(required = false, defaultValue = "10") @Range(min = 1, max = 1000) int size, Model model) {
PageRequest pageRequest = PageRequest.of(page - 1, size);
List<BroadcastMessageDto> messages = broadcastMessageService.getMessages(bodyId, pageRequest);
model.addAttribute("bodyId", bodyId);
model.addAttribute("summary", messagesSummaryService.get(bodyId));
model.addAttribute("page", page);
model.addAttribute("size", size);
model.addAttribute("messages", messages);
return "messages-broadcast";
}
19
View Source File : MessagesAllianceController.java
License : GNU Affero General Public License v3.0
Project Creator : retro-game
License : GNU Affero General Public License v3.0
Project Creator : retro-game
@GetMapping("/messages/alliance")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String messages(@RequestParam(name = "body") long bodyId, @RequestParam(required = false, defaultValue = "1") @Min(1) int page, @RequestParam(required = false, defaultValue = "10") @Range(min = 1, max = 1000) int size, Model model) {
PageRequest pageRequest = PageRequest.of(page - 1, size);
List<AllianceMessageDto> messages = allianceMessagesService.getCurrentUserAllianceMessages(bodyId, pageRequest);
model.addAttribute("bodyId", bodyId);
model.addAttribute("summary", messagesSummaryService.get(bodyId));
model.addAttribute("page", page);
model.addAttribute("size", size);
model.addAttribute("messages", messages);
return "messages-alliance";
}
19
View Source File : RpiWeatherApiController.java
License : Apache License 2.0
Project Creator : pjq
License : Apache License 2.0
Project Creator : pjq
@Override
public ResponseEnreplacedy<ServerStatus> serverStatus() {
final PageRequest page1 = new PageRequest(0, 1, Sort.Direction.DESC, "id");
List<RpiWeatherItem> rpiWeatherItems = rpiWeatherRepository.findAll(page1).getContent();
RpiWeatherItem rpiWeatherItem = null;
if (rpiWeatherItems.size() == 1) {
rpiWeatherItem = rpiWeatherItems.get(0);
}
ServerStatus serverStatus = new ServerStatus();
return new ResponseEnreplacedy<ServerStatus>(serverStatus, HttpStatus.OK);
}
19
View Source File : RpiWeatherApiController.java
License : Apache License 2.0
Project Creator : pjq
License : Apache License 2.0
Project Creator : pjq
public ResponseEnreplacedy<List<RpiWeatherItem>> findWeatherItems(@ApiParam(value = "Page Number") @RequestParam(value = "page", required = true) final Integer page, @ApiParam(value = "Page Size") @RequestParam(value = "size", required = true) final Integer size) {
final PageRequest page1 = new PageRequest(page, size, Sort.Direction.DESC, "id");
return new ResponseEnreplacedy<List<RpiWeatherItem>>(rpiWeatherRepository.findAll(page1).getContent(), HttpStatus.OK);
}
19
View Source File : TransactionalEventServiceTest.java
License : Apache License 2.0
Project Creator : OSGP
License : Apache License 2.0
Project Creator : OSGP
@Test
public void serviceReturnsOneEvent() {
final Slice<Event> mockSlice = this.mockSliceOfEvents(1);
final PageRequest pageRequest = PageRequest.of(0, 10, Sort.Direction.ASC, "id");
Mockito.when(this.eventRepository.findByDateTimeBefore(this.now, pageRequest)).thenReturn(mockSlice);
final List<Event> events = this.transactionalEventService.getEventsBeforeDate(this.now, 10);
replacedertThat(events.size()).isEqualTo(1);
}
19
View Source File : TransactionalEventServiceTest.java
License : Apache License 2.0
Project Creator : OSGP
License : Apache License 2.0
Project Creator : OSGP
@Test
public void serviceReturnsTenEvents() {
final Slice<Event> mockSlice = this.mockSliceOfEvents(10);
final PageRequest pageRequest = PageRequest.of(0, 10, Sort.Direction.ASC, "id");
Mockito.when(this.eventRepository.findByDateTimeBefore(this.now, pageRequest)).thenReturn(mockSlice);
final List<Event> events = this.transactionalEventService.getEventsBeforeDate(this.now, 10);
replacedertThat(events.size()).isEqualTo(10);
}
19
View Source File : FileService.java
License : Apache License 2.0
Project Creator : mose-x
License : Apache License 2.0
Project Creator : mose-x
public Page<FileListDTO> getFileListByPage(com.web.wps.base.Page page) {
PageRequest pages = new PageRequest(page.getPage() - 1, page.getSize());
return this.getRepository().getAllFileByPage(pages);
}
19
View Source File : PostServiceImpl.java
License : GNU General Public License v3.0
Project Creator : mintster
License : GNU General Public License v3.0
Project Creator : mintster
// endregion
// region Get Posts
@Transactional(readOnly = true)
@Override
public Page<Post> getPosts(Integer pageNumber, Integer pageSize) {
PageRequest pageRequest = new PageRequest(pageNumber, pageSize, sortByPostDateDesc());
return postRepository.findAll(pageRequest);
}
19
View Source File : PostServiceImpl.java
License : GNU General Public License v3.0
Project Creator : mintster
License : GNU General Public License v3.0
Project Creator : mintster
@Transactional(readOnly = true)
@Override
public Page<Post> getPublishedPostsByTagId(long tagId, int pageNumber, int pageSize) {
PageRequest pageRequest = new PageRequest(pageNumber, pageSize, sortByPostDateDesc());
return postRepository.findPagedPublishedByTagId(tagId, pageRequest);
}
19
View Source File : PostServiceImpl.java
License : GNU General Public License v3.0
Project Creator : mintster
License : GNU General Public License v3.0
Project Creator : mintster
@Transactional(readOnly = true)
@Override
public Page<Post> getPagedPostsByPostType(PostType postType, int pageNumber, int pageSize) {
PageRequest pageRequest = new PageRequest(pageNumber, pageSize, sortByPostDateDesc());
return postRepository.findPublishedByPostTypePaged(postType, pageRequest);
}
19
View Source File : PostServiceImpl.java
License : GNU General Public License v3.0
Project Creator : mintster
License : GNU General Public License v3.0
Project Creator : mintster
@Transactional(readOnly = true)
@Override
@Cacheable(cacheNames = "pagedPosts", key = "#pageNumber.toString().concat('-').concat(#pageSize.toString())")
public Page<Post> getPublishedPosts(Integer pageNumber, Integer pageSize) {
PageRequest pageRequest = new PageRequest(pageNumber, pageSize, sortByPostDateDesc());
return postRepository.findByIsPublishedTrue(pageRequest);
}
19
View Source File : NewsRepositoryImpl.java
License : Apache License 2.0
Project Creator : melthaw
License : Apache License 2.0
Project Creator : melthaw
@Override
public Page<News> queryPage(NewsQueryRequest queryRequest) {
int start = queryRequest.getStart();
int limit = queryRequest.getLimit();
Query query = buildQuery(queryRequest);
PageRequest pageable = new PageRequest(start, limit, new Sort(Sort.Direction.DESC, "createdAt"));
query.with(pageable);
long count = mongoTemplate.count(query, News.clreplaced);
List<News> list = mongoTemplate.find(query, News.clreplaced);
return new PageImpl<>(list, pageable, count);
}
19
View Source File : AttachmentRepositoryImpl.java
License : Apache License 2.0
Project Creator : melthaw
License : Apache License 2.0
Project Creator : melthaw
@Override
public Page<Attachment> queryPage(AttachmentQueryRequest queryRequest) {
int start = queryRequest.getStart();
int limit = queryRequest.getLimit();
Query query = buildQuery(queryRequest);
PageRequest pageable = new PageRequest(start, limit, new Sort(Sort.Direction.DESC, "createdAt"));
query.with(pageable);
long count = mongoTemplate.count(query, Attachment.clreplaced);
List<Attachment> list = mongoTemplate.find(query, Attachment.clreplaced);
return new PageImpl<>(list, pageable, count);
}
19
View Source File : AuditEventRepositoryImpl.java
License : Apache License 2.0
Project Creator : melthaw
License : Apache License 2.0
Project Creator : melthaw
@Override
public Page<AuditEvent> queryPage(AuditEventQueryRequest queryRequest) {
int start = queryRequest.getStart();
int limit = queryRequest.getLimit();
Query query = buildQuery(queryRequest);
PageRequest pageable = new PageRequest(start, limit, new Sort(Sort.Direction.DESC, "requestedAt"));
query.with(pageable);
long count = mongoTemplate.count(query, AuditEvent.clreplaced);
List<AuditEvent> list = mongoTemplate.find(query, AuditEvent.clreplaced);
return new PageImpl<>(list, pageable, count);
}
19
View Source File : LancamentoServiceImpl.java
License : MIT License
Project Creator : m4rciosouza
License : MIT License
Project Creator : m4rciosouza
public Page<Lancamento> buscarPorFuncionarioId(Long funcionarioId, PageRequest pageRequest) {
log.info("Buscando lançamentos para o funcionário ID {}", funcionarioId);
return this.lancamentoRepository.findByFuncionarioId(funcionarioId, pageRequest);
}
19
View Source File : ReplyServiceImpl.java
License : Apache License 2.0
Project Creator : JiongZhu
License : Apache License 2.0
Project Creator : JiongZhu
@Override
public Page<Reply> getReplyByPage(Integer postsId, int pageNo, int length) {
Sort.Order order = new Sort.Order(Sort.Direction.ASC, "id");
Sort sort = new Sort(order);
PageRequest pageable = new PageRequest(pageNo, length, sort);
Specification<Reply> specification = new Specification<Reply>() {
@Override
public Predicate toPredicate(Root<Reply> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Path<Integer> $posts = root.get("posts");
Predicate predicate = criteriaBuilder.and(criteriaBuilder.equal($posts, postsId));
return predicate;
}
};
Page<Reply> page = repository.findAll(specification, pageable);
return page;
}
19
View Source File : PostsServiceImpl.java
License : Apache License 2.0
Project Creator : JiongZhu
License : Apache License 2.0
Project Creator : JiongZhu
@Override
public Page<Posts> getPostsByPage(String type, String search, int pageNo, int length) {
List<Sort.Order> orders = new ArrayList<>();
orders.add(new Sort.Order(Sort.Direction.DESC, "top"));
orders.add(new Sort.Order(Sort.Direction.DESC, "id"));
Sort sort = new Sort(orders);
PageRequest pageable = new PageRequest(pageNo, length, sort);
Specification<Posts> specification = new Specification<Posts>() {
@Override
public Predicate toPredicate(Root<Posts> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Path<Boolean> $top = root.get("top");
Path<Boolean> $good = root.get("good");
Path<String> $replacedle = root.get("replacedle");
ArrayList<Predicate> list = new ArrayList<>();
if (type != null && type.equals("good"))
list.add(criteriaBuilder.equal($good, true));
if (type != null && type.equals("top"))
list.add(criteriaBuilder.equal($top, true));
if (search != null && search != "")
list.add(criteriaBuilder.like($replacedle, "%" + search + "%"));
Predicate predicate = criteriaBuilder.and(list.toArray(new Predicate[list.size()]));
return predicate;
}
};
Page<Posts> page = repository.findAll(specification, pageable);
return page;
}
19
View Source File : RoleServiceImpl.java
License : Apache License 2.0
Project Creator : JiongZhu
License : Apache License 2.0
Project Creator : JiongZhu
@Override
public Page<Role> findByPage(int pageNo, int length) {
PageRequest pageRequest = new PageRequest(pageNo, length);
Page<Role> page = repository.findAll(pageRequest);
return page;
}
19
View Source File : PermissionServiceImpl.java
License : Apache License 2.0
Project Creator : JiongZhu
License : Apache License 2.0
Project Creator : JiongZhu
@Override
public Page<Permission> findByPage(int pageNo, int length) {
Sort.Order order = new Sort.Order(Sort.Direction.ASC, "sort");
Sort sort = new Sort(order);
PageRequest pageRequest = new PageRequest(pageNo, length, sort);
Page<Permission> page = repository.findAll(pageRequest);
return page;
}
19
View Source File : InMemoryStreamPaymentManagerTest.java
License : Apache License 2.0
Project Creator : interledger4j
License : Apache License 2.0
Project Creator : interledger4j
public clreplaced InMemoryStreamPaymentManagerTest {
public static final PageRequest DEFAULT_PAGE = PageRequest.of(0, 100);
private InMemoryStreamPaymentManager paymentTransactionManager;
@Before
public void setUp() {
paymentTransactionManager = new InMemoryStreamPaymentManager();
}
@Test
public void findByAccountIdPagination() {
AccountId accountId = AccountId.of(generateUuid());
int transactionCount = 125;
for (int i = 0; i < transactionCount; i++) {
paymentTransactionManager.merge(newTransaction(accountId, generateUuid(), 10));
}
List<StreamPayment> trx1to50 = paymentTransactionManager.findByAccountId(accountId, PageRequest.of(0, 50));
replacedertThat(trx1to50).hreplacedize(50);
List<StreamPayment> trx51To100 = paymentTransactionManager.findByAccountId(accountId, PageRequest.of(1, 50));
replacedertThat(trx51To100).hreplacedize(50);
List<StreamPayment> trx101To125 = paymentTransactionManager.findByAccountId(accountId, PageRequest.of(2, 50));
replacedertThat(trx101To125).hreplacedize(25);
replacedertThat(ImmutableSet.builder().addAll(trx1to50).addAll(trx51To100).addAll(trx101To125).build()).hreplacedize(transactionCount);
}
@Test
public void merge() {
AccountId accountId = AccountId.of(generateUuid());
String streamPaymentId = generateUuid();
String streamPaymentId2 = generateUuid();
final StreamPayment enreplacedy1 = newTransaction(accountId, streamPaymentId, 10);
paymentTransactionManager.merge(enreplacedy1);
final StreamPayment loadedAccessTokenEnreplacedy = paymentTransactionManager.findByAccountIdAndStreamPaymentId(accountId, streamPaymentId).get();
replacedertEqual(loadedAccessTokenEnreplacedy, enreplacedy1);
final StreamPayment enreplacedy2 = newTransaction(accountId, streamPaymentId, 20);
paymentTransactionManager.merge(enreplacedy2);
replacedertThat(paymentTransactionManager.findByAccountId(accountId, DEFAULT_PAGE)).hreplacedize(1);
Optional<StreamPayment> transaction1 = paymentTransactionManager.findByAccountIdAndStreamPaymentId(accountId, streamPaymentId);
replacedertThat(transaction1).isPresent();
replacedertThat(transaction1.get().packetCount()).isEqualTo(2);
replacedertThat(transaction1.get().amount()).isEqualTo(BigInteger.valueOf(30));
paymentTransactionManager.merge(newTransaction(accountId, streamPaymentId2, 33));
replacedertThat(paymentTransactionManager.findByAccountId(accountId, DEFAULT_PAGE)).hreplacedize(2);
Optional<StreamPayment> transaction1Again = paymentTransactionManager.findByAccountIdAndStreamPaymentId(accountId, streamPaymentId);
Optional<StreamPayment> transaction2 = paymentTransactionManager.findByAccountIdAndStreamPaymentId(accountId, streamPaymentId2);
replacedertEqual(transaction1Again.get(), transaction1.get());
replacedertThat(transaction2).isPresent();
replacedertThat(transaction2.get().amount()).isEqualTo(BigInteger.valueOf(33));
replacedertThat(transaction2.get().packetCount()).isEqualTo(1);
}
@Test
public void mergeAndUpdateDeliveredDetails() {
String replacedetCode = "XRP";
short replacedetScale = 9;
UnsignedLong deliveredAmount = UnsignedLong.valueOf(100);
AccountId accountId = AccountId.of(generateUuid());
String streamPaymentId = generateUuid();
StreamPayment payment = StreamPayment.builder().from(newTransaction(accountId, streamPaymentId, 10)).deliveredreplacedetCode(replacedetCode).deliveredreplacedetScale(replacedetScale).deliveredAmount(deliveredAmount).build();
paymentTransactionManager.merge(payment);
Optional<StreamPayment> merged = paymentTransactionManager.findByAccountIdAndStreamPaymentId(accountId, streamPaymentId);
replacedertThat(merged).isPresent();
replacedertThat(merged.get().deliveredreplacedetCode()).hasValue(replacedetCode);
replacedertThat(merged.get().deliveredreplacedetScale()).hasValue(replacedetScale);
replacedertThat(merged.get().deliveredAmount()).isEqualTo(deliveredAmount);
}
private void replacedertEqual(StreamPayment loadedAccessTokenEnreplacedy, StreamPayment enreplacedy1) {
replacedertThat(loadedAccessTokenEnreplacedy).isEqualTo(enreplacedy1);
}
private StreamPayment newTransaction(AccountId accountId, String streamPaymentId, long amount) {
return StreamPayment.builder().accountId(accountId).sourceAddress(InterledgerAddress.of("test.foo.bar")).destinationAddress(InterledgerAddress.of("test.foo").with(streamPaymentId)).packetCount(1).streamPaymentId(streamPaymentId).amount(BigInteger.valueOf(amount)).expectedAmount(BigInteger.valueOf(amount)).deliveredAmount(UnsignedLong.valueOf(amount)).replacedetScale((short) 9).replacedetCode("XRP").status(StreamPaymentStatus.PENDING).type(StreamPaymentType.PAYMENT_RECEIVED).createdAt(Instant.now()).modifiedAt(Instant.now()).build();
}
private String generateUuid() {
return UUID.randomUUID().toString();
}
}
19
View Source File : DesignTacoController.java
License : Apache License 2.0
Project Creator : habuma
License : Apache License 2.0
Project Creator : habuma
@GetMapping("/recent")
public Iterable<Taco> recentTacos() {
// <3>
PageRequest page = PageRequest.of(0, 12, Sort.by("createdAt").descending());
return tacoRepo.findAll(page).getContent();
}
19
View Source File : JobServiceImpl.java
License : Apache License 2.0
Project Creator : gy2006
License : Apache License 2.0
Project Creator : gy2006
@Override
public Page<JobItem> list(Flow flow, int page, int size) {
PageRequest pageable = PageRequest.of(page, size, SortByBuildNumber);
return jobItemDao.findAllByFlowId(flow.getId(), pageable);
}
19
View Source File : ReleaseService.java
License : Apache License 2.0
Project Creator : garyxiong123
License : Apache License 2.0
Project Creator : garyxiong123
@Transactional
public Release rollback(long releaseId, String operator) {
Release release = findOne(releaseId);
if (release == null) {
throw new NotFoundException("release not found");
}
if (release.isAbandoned()) {
throw new BadRequestException("release is not active");
}
String appId = release.getAppId();
String clusterName = release.getClusterName();
String namespaceName = release.getNamespaceName();
PageRequest page = new PageRequest(0, 2);
List<Release> twoLatestActiveReleases = findActiveReleases(appId, clusterName, namespaceName, page);
if (twoLatestActiveReleases == null || twoLatestActiveReleases.size() < 2) {
throw new BadRequestException(String.format("Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release", appId, clusterName, namespaceName));
}
release.setAbandoned(true);
release.setDataChangeLastModifiedBy(operator);
releaseRepository.save(release);
releaseHistoryService.createReleaseHistory(appId, clusterName, namespaceName, clusterName, twoLatestActiveReleases.get(1).getId(), release.getId(), ReleaseOperation.ROLLBACK, null, operator, release.getEnv());
// publish child namespace if namespace has child
rollbackChildNamespace(appId, release.getEnv(), clusterName, namespaceName, twoLatestActiveReleases, operator);
return release;
}
19
View Source File : NamespaceService.java
License : Apache License 2.0
Project Creator : garyxiong123
License : Apache License 2.0
Project Creator : garyxiong123
public List<Namespace> getPublicAppNamespaceAllNamespaces(Env env, String publicNamespaceName, int page, int size) {
PageRequest page1 = PageRequest.of(page, size);
return namespaceRepository.findByNamespaceName(publicNamespaceName, page1);
}
19
View Source File : CrawlerApiService.java
License : GNU General Public License v3.0
Project Creator : fooock
License : GNU General Public License v3.0
Project Creator : fooock
/**
* Find all elements from database using paginated results. If the given page is < than 0, then
* page by default always is 0. Also, size param can't be < than 5 or > than 100.
*
* @param page Page number
* @param size Number of results per page
* @return Paginated results
*/
public Page<Entry> findAllPageable(int page, int size) {
if (page < 0)
page = 0;
if (size < 5)
size = 5;
if (size > 100)
size = 100;
PageRequest pageRequest = PageRequest.of(page, size);
Page<Entry> entries = robotsRepository.findAll(pageRequest);
log.info("Found {} entries for page {} and page size {}", entries.getTotalElements(), page, size);
return entries;
}
19
View Source File : SearchRecordKeyWordMappingService.java
License : Apache License 2.0
Project Creator : etrace-io
License : Apache License 2.0
Project Creator : etrace-io
public List<SearchRecordKeyWordMapping> findAll(String status, int pageNum, int pageSize) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize);
return searchRecordKeyWordMappingMapper.findByRecordIdAndKeywordIdInAndStatus(null, null, status, pageRequest);
}
19
View Source File : JobService.java
License : Apache License 2.0
Project Creator : DSC-SPIDAL
License : Apache License 2.0
Project Creator : DSC-SPIDAL
public Page<Job> searchJobs(List<JobState> states, String keyword, int page) {
PageRequest pageRequest = PageRequest.of(page, 25);
return this.jobRepository.findAllByStateInAndJobNameContainingOrderByCreatedTimeDesc(states, keyword, pageRequest);
}
19
View Source File : MySpecification.java
License : Apache License 2.0
Project Creator : dounine
License : Apache License 2.0
Project Creator : dounine
/**
* 分页及排序
*
* @param dto
* @return
*/
public PageRequest getPageRequest(BD dto) {
PageRequest pageRequest = null;
if (dto.getSorts() != null && dto.getSorts().size() > 0) {
Sort.Direction dct = Sort.Direction.ASC;
if (dto.getOrder().equals("desc")) {
dct = Sort.Direction.DESC;
}
// 分页带排序
pageRequest = new PageRequest(dto.getPage(), dto.getLimit(), new Sort(dct, dto.getSorts()));
} else {
// 分页不带排序
pageRequest = new PageRequest(dto.getPage(), dto.getLimit());
}
return pageRequest;
}
19
View Source File : RelatedContentService.java
License : Apache License 2.0
Project Creator : dingziyang
License : Apache License 2.0
Project Creator : dingziyang
public Page<RelatedContent> getAllFieldContentForProcessInstance(String processInstanceId, int pageSize, int page) {
PageRequest paging = new PageRequest(page, pageSize);
return contentRepository.findAllFieldBasedContentByProcessInstanceId(processInstanceId, paging);
}
19
View Source File : RelatedContentService.java
License : Apache License 2.0
Project Creator : dingziyang
License : Apache License 2.0
Project Creator : dingziyang
public Page<RelatedContent> getRelatedContentForProcessInstance(String processInstanceId, int pageSize, int page) {
PageRequest paging = new PageRequest(page, pageSize);
return contentRepository.findAllRelatedByProcessInstanceId(processInstanceId, paging);
}
19
View Source File : RelatedContentService.java
License : Apache License 2.0
Project Creator : dingziyang
License : Apache License 2.0
Project Creator : dingziyang
public Page<RelatedContent> getFieldContentForTask(String taskId, int pageSize, int page) {
PageRequest paging = new PageRequest(page, pageSize);
return contentRepository.findAllFieldBasedContentByTaskId(taskId, paging);
}
19
View Source File : RelatedContentService.java
License : Apache License 2.0
Project Creator : dingziyang
License : Apache License 2.0
Project Creator : dingziyang
public Page<RelatedContent> getRelatedContentForTask(String taskId, int pageSize, int page) {
PageRequest paging = new PageRequest(page, pageSize);
return contentRepository.findAllRelatedByTaskId(taskId, paging);
}
19
View Source File : RelatedContentService.java
License : Apache License 2.0
Project Creator : dingziyang
License : Apache License 2.0
Project Creator : dingziyang
public Page<RelatedContent> getAllFieldContentForTask(String taskId, String field, int pageSize, int page) {
PageRequest paging = new PageRequest(page, pageSize);
return contentRepository.findAllByTaskIdAndField(taskId, field, paging);
}
19
View Source File : ArticleController.java
License : Apache License 2.0
Project Creator : csj4032
License : Apache License 2.0
Project Creator : csj4032
@PrimaveraLogging(type = "ArticleController")
@GetMapping(value = "/articles")
public String articles(Model model, PageRequest pageRequest) {
model.addAttribute("page", writeArticleService.findForPageable(pageRequest));
return "article/list";
}
19
View Source File : WriteArticleServiceImpl.java
License : Apache License 2.0
Project Creator : csj4032
License : Apache License 2.0
Project Creator : csj4032
@Override
public Page<ArticleDto.ListArticle> findForPageable(PageRequest pageRequest) {
return null;
}
19
View Source File : MahutaRepositoryImpl.java
License : Apache License 2.0
Project Creator : ConsenSys
License : Apache License 2.0
Project Creator : ConsenSys
@Override
public Iterable<E> findAll() {
PageRequest pageable = PageRequest.of(DEFAULT_PAGE_NO, DEFAULT_PAGE_SIZE);
return this.findAll(pageable);
}
19
View Source File : MahutaRepositoryImpl.java
License : Apache License 2.0
Project Creator : ConsenSys
License : Apache License 2.0
Project Creator : ConsenSys
@Override
public Iterable<E> findAll(Sort sort) {
PageRequest pageable = PageRequest.of(DEFAULT_PAGE_NO, DEFAULT_PAGE_SIZE, sort);
return this.findAll(pageable);
}
19
View Source File : RoleServiceImpl.java
License : MIT License
Project Creator : auntvt
License : MIT License
Project Creator : auntvt
/**
* 获取分页列表数据
* @param example 查询实例
* @return 返回分页数据
*/
@Override
public Page<Role> getPageList(Example<Role> example) {
// 创建分页对象
PageRequest page = PageSort.pageRequest(Sort.Direction.ASC);
return roleRepository.findAll(example, page);
}
19
View Source File : TestStepService.java
License : Apache License 2.0
Project Creator : ATLANTBH
License : Apache License 2.0
Project Creator : ATLANTBH
/**
* Returns paginated list of test steps for given test run id and test group name.
*
* @param testRunId Id of test run.
* @param testGroup Test group name.
* @param page Spring pageable object.
* @return Paginated list of test steps.
* @throws ServiceException If test run is not found.
*/
public Page<TestStep> getTestSteps(Long testRunId, String testGroup, Pageable page) throws ServiceException {
final TestRun testRun = testRunService.get(testRunId);
final PageRequest pageRequest = createPageRequest(page, CREATED_AT_ASC_SORT);
return testStepRepository.findByTestRunAndGroup(testRun, testGroup, pageRequest);
}
19
View Source File : TestRunService.java
License : Apache License 2.0
Project Creator : ATLANTBH
License : Apache License 2.0
Project Creator : ATLANTBH
/**
* Returns paginated list of all test runs for given filter and pageable object.
*
* @param filter TestRunFilter filter.
* @param page Spring pageable object.
* @return Paginated list of all test runs.
*/
public Page<TestRun> getAllTestRuns(TestRunFilter filter, Pageable page) {
final PageRequest pageRequest = createPageRequest(page, CREATED_AT_DESC_SORT);
return testRunRepository.findAll(new TestRunFilterSpecification(filter), pageRequest);
}
19
View Source File : SpringTxEventRepository.java
License : Apache License 2.0
Project Creator : apache
License : Apache License 2.0
Project Creator : apache
clreplaced SpringTxEventRepository implements TxEventRepository {
private static final PageRequest SINGLE_TX_EVENT_REQUEST = PageRequest.of(0, 1);
private final TxEventEnvelopeRepository eventRepo;
SpringTxEventRepository(TxEventEnvelopeRepository eventRepo) {
this.eventRepo = eventRepo;
}
@Override
public void save(TxEvent event) {
eventRepo.save(event);
}
@Override
public Optional<List<TxEvent>> findFirstAbortedGlobalTransaction() {
return eventRepo.findFirstAbortedGlobalTxByType();
}
@Override
public List<TxEvent> findTimeoutEvents() {
return eventRepo.findTimeoutEvents(SINGLE_TX_EVENT_REQUEST);
}
@Override
public Optional<TxEvent> findTxStartedEvent(String globalTxId, String localTxId) {
return eventRepo.findFirstStartedEventByGlobalTxIdAndLocalTxId(globalTxId, localTxId);
}
@Override
public List<TxEvent> findTransactions(String globalTxId, String type) {
return eventRepo.findByEventGlobalTxIdAndEventType(globalTxId, type);
}
@Override
public List<TxEvent> findFirstUncompensatedEventByIdGreaterThan(long id, String type) {
return eventRepo.findFirstByTypeAndSurrogateIdGreaterThan(type, id, SINGLE_TX_EVENT_REQUEST);
}
@Override
public Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id) {
return eventRepo.findFirstByTypeAndSurrogateIdGreaterThan(TxCompensatedEvent.name(), id);
}
@Override
public void deleteDuplicateEvents(String type) {
eventRepo.findDuplicateEventsByType(type).forEach((txEvent) -> eventRepo.deleteBySurrogateId(txEvent.id()));
}
}
See More Examples