Search in sources :

Example 56 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 57 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 58 with PageRequest

use of org.springframework.data.domain.PageRequest in project sic by belluccifranco.

the class ProductoController method buscarProductos.

@GetMapping("/productos/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public Page buscarProductos(@RequestParam long idEmpresa, @RequestParam(required = false) String codigo, @RequestParam(required = false) String descripcion, @RequestParam(required = false) Long idRubro, @RequestParam(required = false) Long idProveedor, @RequestParam(required = false) boolean soloFantantes, @RequestParam(required = false) Integer pagina, @RequestParam(required = false) Integer tamanio) {
    Rubro rubro = null;
    if (idRubro != null) {
        rubro = rubroService.getRubroPorId(idRubro);
    }
    Proveedor proveedor = null;
    if (idProveedor != null) {
        proveedor = proveedorService.getProveedorPorId(idProveedor);
    }
    if (tamanio == null || tamanio <= 0) {
        tamanio = TAMANIO_PAGINA_DEFAULT;
    }
    if (pagina == null || pagina < 0) {
        pagina = 0;
    }
    Pageable pageable = new PageRequest(pagina, tamanio, new Sort(Sort.Direction.ASC, "descripcion"));
    BusquedaProductoCriteria criteria = BusquedaProductoCriteria.builder().buscarPorCodigo((codigo != null && !codigo.isEmpty())).codigo(codigo).buscarPorDescripcion(descripcion != null && !descripcion.isEmpty()).descripcion(descripcion).buscarPorRubro(rubro != null).rubro(rubro).buscarPorProveedor(proveedor != null).proveedor(proveedor).empresa(empresaService.getEmpresaPorId(idEmpresa)).listarSoloFaltantes(soloFantantes).pageable(pageable).build();
    return productoService.buscarProductos(criteria);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) BusquedaProductoCriteria(sic.modelo.BusquedaProductoCriteria) Pageable(org.springframework.data.domain.Pageable) Rubro(sic.modelo.Rubro) Proveedor(sic.modelo.Proveedor) Sort(org.springframework.data.domain.Sort) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 59 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)

Example 60 with PageRequest

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

the class PersonDashboardJpaRepositoryProvider method iterator.

/**
     * @see SortableDataProvider#iterator(long, long)
     */
@Override
public Iterator<UserDashboard> iterator(final long first, final long count) {
    int page = (int) ((double) first / WebConstants.PAGE_SIZE);
    Page<UserDashboard> findAll = userDashboardRepository.findDashboardsForPersonId(SecurityUtil.getCurrentAuthenticatedPerson().getId(), new PageRequest(page, WebConstants.PAGE_SIZE, translateSort()));
    return findAll.iterator();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) UserDashboard(org.devgateway.ocds.persistence.dao.UserDashboard)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)106 Sort (org.springframework.data.domain.Sort)29 Pageable (org.springframework.data.domain.Pageable)25 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)14 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)9 Transactional (org.springframework.transaction.annotation.Transactional)9 UUID (java.util.UUID)8 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)7 ApiOperation (io.swagger.annotations.ApiOperation)7 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)6 IdmTreeNode (eu.bcvsolutions.idm.core.model.entity.IdmTreeNode)6 List (java.util.List)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)5 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 PageImpl (org.springframework.data.domain.PageImpl)5