Search in sources :

Example 6 with Pageable

use of org.springframework.data.domain.Pageable 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 7 with Pageable

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

the class OcdsController method ocdsReleases.

/**
     * Returns a list of OCDS Releases, order by Id, using pagination
     *
     * @return the release data
     */
@ApiOperation(value = "Resturns all available releases, filtered by the given criteria.")
@RequestMapping(value = "/api/ocds/release/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<Release> ocdsReleases(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
    Pageable pageRequest = new PageRequest(releaseRequest.getPageNumber(), releaseRequest.getPageSize(), Direction.ASC, "id");
    List<Release> find = mongoTemplate.find(query(getYearFilterCriteria(releaseRequest, "planning.bidPlanProjectDateApprove").andOperator(getDefaultFilterCriteria(releaseRequest))).with(pageRequest), Release.class);
    return find;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Release(org.devgateway.ocds.persistence.mongo.Release) ApiOperation(io.swagger.annotations.ApiOperation) JsonView(com.fasterxml.jackson.annotation.JsonView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)7 Pageable (org.springframework.data.domain.Pageable)7 Sort (org.springframework.data.domain.Sort)6 JsonView (com.fasterxml.jackson.annotation.JsonView)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Release (org.devgateway.ocds.persistence.mongo.Release)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 BusquedaProductoCriteria (sic.modelo.BusquedaProductoCriteria)1 Proveedor (sic.modelo.Proveedor)1 Rubro (sic.modelo.Rubro)1 Association (uk.ac.ebi.spot.goci.model.Association)1 DiseaseTrait (uk.ac.ebi.spot.goci.model.DiseaseTrait)1 EfoTrait (uk.ac.ebi.spot.goci.model.EfoTrait)1 Study (uk.ac.ebi.spot.goci.model.Study)1