use of org.springframework.data.domain.Sort in project goci by EBISPOT.
the class StudyController method findSort.
// Find correct sorting type and direction
private Sort findSort(String sortType) {
// Default sort by date
Sort sort = sortByPublicationDateDesc();
Map<String, Sort> sortTypeMap = new HashMap<>();
sortTypeMap.put("authorsortasc", sortByAuthorAsc());
sortTypeMap.put("authorsortdesc", sortByAuthorDesc());
sortTypeMap.put("titlesortasc", sortByTitleAsc());
sortTypeMap.put("titlesortdesc", sortByTitleDesc());
sortTypeMap.put("publicationdatesortasc", sortByPublicationDateAsc());
sortTypeMap.put("publicationdatesortdesc", sortByPublicationDateDesc());
sortTypeMap.put("pubmedsortasc", sortByPubmedIdAsc());
sortTypeMap.put("pubmedsortdesc", sortByPubmedIdDesc());
sortTypeMap.put("publicationsortasc", sortByPublicationAsc());
sortTypeMap.put("publicationsortdesc", sortByPublicationDesc());
sortTypeMap.put("efotraitsortasc", sortByEfoTraitAsc());
sortTypeMap.put("efotraitsortdesc", sortByEfoTraitDesc());
sortTypeMap.put("diseasetraitsortasc", sortByDiseaseTraitAsc());
sortTypeMap.put("diseasetraitsortdesc", sortByDiseaseTraitDesc());
sortTypeMap.put("curatorsortasc", sortByCuratorAsc());
sortTypeMap.put("curatorsortdesc", sortByCuratorDesc());
sortTypeMap.put("curationstatussortasc", sortByCurationStatusAsc());
sortTypeMap.put("curationstatussortdesc", sortByCurationStatusDesc());
if (sortType != null && !sortType.isEmpty()) {
sort = sortTypeMap.get(sortType);
}
return sort;
}
use of org.springframework.data.domain.Sort 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();
}
use of org.springframework.data.domain.Sort 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();
}
use of org.springframework.data.domain.Sort in project springboot_op by SnailFastGo.
the class UserController method curPage.
@RequestMapping(value = "/curpage")
public List<UserEntity> curPage(int page) {
UserEntity user = new UserEntity();
user.setSize(2);
user.setPage(page);
user.setSort("desc");
Sort.Direction direction = Sort.Direction.DESC;
Sort sort = new Sort(direction, "name");
PageRequest pageRequest = new PageRequest(user.getPage() - 1, user.getSize(), sort);
List<UserEntity> res = userService.curPage(pageRequest);
return res;
}
use of org.springframework.data.domain.Sort in project sic by belluccifranco.
the class PedidoServiceImpl method buscarConCriteria.
@Override
public List<Pedido> buscarConCriteria(BusquedaPedidoCriteria criteria) {
//Fecha
if (criteria.isBuscaPorFecha() == true & (criteria.getFechaDesde() == null | criteria.getFechaHasta() == null)) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_fechas_busqueda_invalidas"));
}
if (criteria.isBuscaPorFecha() == true) {
Calendar cal = new GregorianCalendar();
cal.setTime(criteria.getFechaDesde());
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
criteria.setFechaDesde(cal.getTime());
cal.setTime(criteria.getFechaHasta());
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
criteria.setFechaHasta(cal.getTime());
}
//Empresa
if (criteria.getEmpresa() == null) {
throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
}
//Cliente
if (criteria.isBuscaCliente() == true && criteria.getCliente() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_cliente_vacio_razonSocial"));
}
//Usuario
if (criteria.isBuscaUsuario() == true && criteria.getUsuario() == null) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_usuario_vacio_nombre"));
}
QPedido qpedido = QPedido.pedido;
BooleanBuilder builder = new BooleanBuilder();
builder.and(qpedido.empresa.eq(criteria.getEmpresa()).and(qpedido.eliminado.eq(false)));
if (criteria.isBuscaPorFecha() == true) {
FormatterFechaHora formateadorFecha = new FormatterFechaHora(FormatterFechaHora.FORMATO_FECHAHORA_INTERNACIONAL);
DateExpression<Date> fDesde = Expressions.dateTemplate(Date.class, "convert({0}, datetime)", formateadorFecha.format(criteria.getFechaDesde()));
DateExpression<Date> fHasta = Expressions.dateTemplate(Date.class, "convert({0}, datetime)", formateadorFecha.format(criteria.getFechaHasta()));
builder.and(qpedido.fecha.between(fDesde, fHasta));
}
if (criteria.isBuscaCliente() == true) {
builder.and(qpedido.cliente.eq(criteria.getCliente()));
}
if (criteria.isBuscaUsuario() == true) {
builder.and(qpedido.usuario.eq(criteria.getUsuario()));
}
if (criteria.isBuscaPorNroPedido() == true) {
builder.and(qpedido.nroPedido.eq(criteria.getNroPedido()));
}
List<Pedido> pedidos = new ArrayList<>();
pedidoRepository.findAll(builder, new Sort(Sort.Direction.DESC, "fecha")).iterator().forEachRemaining(pedidos::add);
return this.calcularTotalActualDePedidos(pedidos);
}
Aggregations