List of usage examples for org.springframework.data.domain Page nextPageable
Pageable nextPageable();
From source file:org.obiba.mica.person.search.PersonIndexer.java
@Async @Subscribe//from w ww .j a v a 2 s. c o m public void reIndexContacts(IndexContactsEvent event) { log.info("Reindexing all persons"); if (indexer.hasIndex(Indexer.PERSON_INDEX)) indexer.dropIndex(Indexer.PERSON_INDEX); Pageable pageRequest = new PageRequest(0, 100); Page<Person> persons; do { persons = personRepository.findAll(pageRequest); indexer.indexAll(Indexer.PERSON_INDEX, persons); } while ((pageRequest = persons.nextPageable()) != null); }
From source file:de.rahn.finances.services.securities.SecuritiesServiceImplTest.java
/** * Test method for {@link SecuritiesServiceImpl#getSecurities(Pageable)}. *///ww w. ja v a 2 s .c om @Test public void testGetSecuritiesPageable() { Page<Security> page = classUnderTests.getSecurities(null); assertThat(page, notNullValue()); assertThat(page.getNumberOfElements(), is(1)); assertThat(page.getContent(), notNullValue()); assertThat(page.getContent().size(), is(1)); assertThat(page.getContent(), contains(testSecurity)); Pageable pageable = page.nextPageable(); assertThat(pageable, notNullValue()); page = classUnderTests.getSecurities(pageable); assertThat(page, notNullValue()); assertThat(page.getNumberOfElements(), is(0)); assertThat(page.getContent(), empty()); page = classUnderTests.getSecurities(zeroPage); assertThat(page, notNullValue()); assertThat(page.getNumberOfElements(), is(0)); assertThat(page.getContent(), empty()); page = classUnderTests.getSecurities(new PageRequest(10, 10)); assertThat(page, notNullValue()); assertThat(page.getNumberOfElements(), is(0)); assertThat(page.getContent(), empty()); page = classUnderTests.getSecurities(false, stock, null); assertThat(page, notNullValue()); assertThat(page.getNumberOfElements(), is(1)); assertThat(page.getContent(), notNullValue()); assertThat(page.getContent().size(), is(1)); assertThat(page.getContent(), contains(testSecurity)); }
From source file:org.obiba.mica.file.search.FileIndexer.java
@Async @Subscribe/* ww w. j a va 2s .c om*/ public void reIndexAll(IndexFilesEvent event) { if (indexer.hasIndex(Indexer.ATTACHMENT_DRAFT_INDEX)) indexer.dropIndex(Indexer.ATTACHMENT_DRAFT_INDEX); if (indexer.hasIndex(Indexer.ATTACHMENT_PUBLISHED_INDEX)) indexer.dropIndex(Indexer.ATTACHMENT_PUBLISHED_INDEX); Pageable pageRequest = new PageRequest(0, 100); Page<AttachmentState> attachments; do { attachments = attachmentStateRepository.findAll(pageRequest); attachments.forEach(a -> { if (FileUtils.isDirectory(a)) return; indexer.index(Indexer.ATTACHMENT_DRAFT_INDEX, a); if (a.getPublishedAttachment() != null) { indexer.index(Indexer.ATTACHMENT_PUBLISHED_INDEX, a); } }); } while ((pageRequest = attachments.nextPageable()) != null); }