Search in sources :

Example 16 with PageRequest

use of org.springframework.data.domain.PageRequest in project ocvn by devgateway.

the class AbstractSpringDataRestControllerTest method setUp.

@Before
public void setUp() {
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
    this.persistentEntityResourceAssembler = mock(PersistentEntityResourceAssembler.class);
    this.pageRequest = new PageRequest(0, GenericPagingRequest.DEFAULT_PAGE_SIZE);
    mockHttpServletRequestForResouceAssemblerSupport();
}
Also used : PersistentEntityResourceAssembler(org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) PageRequest(org.springframework.data.domain.PageRequest) Before(org.junit.Before)

Example 17 with PageRequest

use of org.springframework.data.domain.PageRequest in project goci by EBISPOT.

the class SolrIndexer method mapEfo.

Integer mapEfo() {
    Sort sort = new Sort(new Sort.Order("id"));
    Pageable pager = new PageRequest(0, pageSize, sort);
    Page<EfoTrait> efoTraitPage = efoTraitRepository.findAll(pager);
    efoMapper.map(efoTraitPage.getContent());
    while (efoTraitPage.hasNext()) {
        if (maxPages != -1 && efoTraitPage.getNumber() >= maxPages - 1) {
            break;
        }
        pager = pager.next();
        efoTraitPage = efoTraitRepository.findAll(pager);
        efoMapper.map(efoTraitPage.getContent());
        if (sysOutLogging) {
            System.out.print(".");
        }
    }
    return (int) efoTraitPage.getTotalElements();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) EfoTrait(uk.ac.ebi.spot.goci.model.EfoTrait)

Example 18 with PageRequest

use of org.springframework.data.domain.PageRequest in project goci by EBISPOT.

the class SolrIndexer method mapTraits.

Integer mapTraits() {
    Sort sort = new Sort(new Sort.Order("trait"));
    Pageable pager = new PageRequest(0, pageSize, sort);
    Page<DiseaseTrait> diseaseTraitPage = diseaseTraitRepository.findAll(pager);
    traitMapper.map(diseaseTraitPage.getContent());
    while (diseaseTraitPage.hasNext()) {
        if (maxPages != -1 && diseaseTraitPage.getNumber() >= maxPages - 1) {
            break;
        }
        pager = pager.next();
        diseaseTraitPage = diseaseTraitRepository.findAll(pager);
        traitMapper.map(diseaseTraitPage.getContent());
        if (sysOutLogging) {
            System.out.print(".");
        }
    }
    return (int) diseaseTraitPage.getTotalElements();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) Sort(org.springframework.data.domain.Sort)

Example 19 with PageRequest

use of org.springframework.data.domain.PageRequest in project goci by EBISPOT.

the class JsonBuilder method getJsons.

public Collection<String> getJsons(String snp2geneMappingFilePath) throws IOException {
    Collection<String> jsons = new ArrayList<>();
    SnpToGeneMapper snpToGeneMapper = new SnpToGeneMapper(snp2geneMappingFilePath);
    Sort sort = new Sort(new Sort.Order("id"));
    int setNumber = 0;
    Pageable pager = new PageRequest(setNumber, 200, sort);
    Page<Association> associationPage = associationService.findPublishedAssociations(pager);
    Iterator<Association> assoIterator = associationPage.iterator();
    while (assoIterator.hasNext()) {
        jsons.addAll(processAssociation(assoIterator.next(), snpToGeneMapper));
    }
    while (associationPage.hasNext()) {
        pager = associationPage.nextPageable();
        associationPage = associationService.findPublishedAssociations(pager);
        assoIterator = associationPage.iterator();
        while (assoIterator.hasNext()) {
            jsons.addAll(processAssociation(assoIterator.next(), snpToGeneMapper));
        }
    }
    return jsons;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort)

Example 20 with PageRequest

use of org.springframework.data.domain.PageRequest in project ignite by apache.

the class SpringDataExample method queryRepository.

/**
     * Execute advanced queries over the repository.
     */
private static void queryRepository() {
    System.out.println("\n>>> Persons with name 'John':");
    List<Person> persons = repo.findByFirstName("John");
    for (Person person : persons) System.out.println("   >>>   " + person);
    Cache.Entry<Long, Person> topPerson = repo.findTopByLastNameLike("Smith");
    System.out.println("\n>>> Top Person with surname 'Smith': " + topPerson.getValue());
    List<Long> ids = repo.selectId(1000L, new PageRequest(0, 4));
    System.out.println("\n>>> Persons working for organization with ID > 1000: ");
    for (Long id : ids) System.out.println("   >>>   [id=" + id + "]");
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Person(org.apache.ignite.examples.model.Person) Cache(javax.cache.Cache)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)28 Pageable (org.springframework.data.domain.Pageable)7 Sort (org.springframework.data.domain.Sort)7 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Person (org.apache.ignite.springdata.misc.Person)3 List (java.util.List)2 Cache (javax.cache.Cache)2 Release (org.devgateway.ocds.persistence.mongo.Release)2 Query (org.springframework.data.mongodb.core.query.Query)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Book (org.springside.examples.bootapi.domain.Book)2 City (sample.data.jpa.domain.City)2 City (sample.data.rest.domain.City)2 JsonView (com.fasterxml.jackson.annotation.JsonView)1 UserEntity (com.myspringboot.entity.UserEntity)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1