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();
}
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;
}
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);
}
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 + "]");
}
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();
}
Aggregations