Search in sources :

Example 1 with PageRequest

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();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Association(uk.ac.ebi.spot.goci.model.Association) Sort(org.springframework.data.domain.Sort)

Example 2 with PageRequest

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();
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort)

Example 3 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) City(sample.data.jpa.domain.City) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 4 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) RatingCount(sample.data.jpa.domain.RatingCount) HotelSummary(sample.data.jpa.domain.HotelSummary) City(sample.data.jpa.domain.City) Hotel(sample.data.jpa.domain.Hotel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) City(sample.data.rest.domain.City) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)371 Test (org.junit.Test)119 Sort (org.springframework.data.domain.Sort)100 Pageable (org.springframework.data.domain.Pageable)96 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)37 PageImpl (org.springframework.data.domain.PageImpl)31 ArrayList (java.util.ArrayList)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)27 Test (org.junit.jupiter.api.Test)23 Transactional (org.springframework.transaction.annotation.Transactional)23 GetMapping (org.springframework.web.bind.annotation.GetMapping)17 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)16 Date (java.util.Date)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)15 User (ca.corefacility.bioinformatics.irida.model.user.User)14 UUID (java.util.UUID)14 Page (org.springframework.data.domain.Page)14 Order (org.springframework.data.domain.Sort.Order)14 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 Project (ca.corefacility.bioinformatics.irida.model.project.Project)10