use of org.springframework.data.domain.PageRequest in project goci by EBISPOT.
the class SolrIndexer method mapAssociations.
Integer mapAssociations() {
Sort sort = new Sort(new Sort.Order("id"));
Pageable pager = new PageRequest(0, pageSize, sort);
Page<Association> associationPage = associationService.findPublishedAssociations(pager);
associationMapper.map(associationPage.getContent());
while (associationPage.hasNext()) {
if (maxPages != -1 && associationPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
associationPage = associationService.findPublishedAssociations(pager);
associationMapper.map(associationPage.getContent());
if (sysOutLogging) {
System.out.print(".");
}
}
return (int) associationPage.getTotalElements();
}
use of org.springframework.data.domain.PageRequest in project goci by EBISPOT.
the class SolrIndexer method mapStudies.
Integer mapStudies() {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "publicationDate"));
Pageable pager = new PageRequest(0, pageSize, sort);
Page<Study> studyPage = studyService.findPublishedStudies(pager);
studyMapper.map(studyPage.getContent());
while (studyPage.hasNext()) {
if (maxPages != -1 && studyPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
studyPage = studyService.findPublishedStudies(pager);
studyMapper.map(studyPage.getContent());
if (sysOutLogging) {
System.out.print(".");
}
}
return (int) studyPage.getTotalElements();
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class CityRepositoryIntegrationTests method findsFirstPageOfCities.
@Test
public void findsFirstPageOfCities() {
Page<City> cities = this.repository.findAll(new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isGreaterThan(20L);
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class HotelRepositoryIntegrationTests method executesQueryMethodsCorrectly.
@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);
assertThat(counts.get(0).getRating()).isEqualTo(Rating.AVERAGE);
assertThat(counts.get(0).getCount()).isGreaterThan(1L);
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class CityRepositoryIntegrationTests method findContaining.
@Test
public void findContaining() {
Page<City> cities = this.repository.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK", new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isEqualTo(3L);
}
Aggregations