List of usage examples for org.springframework.data.domain PageRequest getSort
public Sort getSort()
From source file:com.alliander.osgp.adapter.ws.core.application.services.DeviceManagementService.java
@Transactional(value = "transactionManager") public Page<Event> findEvents(@Identification final String organisationIdentification, final String deviceIdentification, final Integer pageSize, final Integer pageNumber, final DateTime from, final DateTime until, final List<EventType> eventTypes) throws FunctionalException { LOGGER.debug("findEvents called for organisation {} and device {}", organisationIdentification, deviceIdentification);//from w ww . j a v a2 s.c o m final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); this.pagingSettings.updatePagingSettings(pageSize, pageNumber); final PageRequest request = new PageRequest(this.pagingSettings.getPageNumber(), this.pagingSettings.getPageSize(), Sort.Direction.DESC, "dateTime"); Specifications<Event> specifications = null; try { if (deviceIdentification != null && !deviceIdentification.isEmpty()) { final Device device = this.domainHelperService.findDevice(deviceIdentification); this.domainHelperService.isAllowed(organisation, device, DeviceFunction.GET_EVENT_NOTIFICATIONS); specifications = where(this.eventSpecifications.isFromDevice(device)); } else { specifications = where(this.eventSpecifications.isAuthorized(organisation)); } if (from != null) { specifications = specifications.and(this.eventSpecifications.isCreatedAfter(from.toDate())); } if (until != null) { specifications = specifications.and(this.eventSpecifications.isCreatedBefore(until.toDate())); } if (eventTypes != null && !eventTypes.isEmpty()) { specifications = specifications.and(this.eventSpecifications.hasEventTypes(eventTypes)); } } catch (final ArgumentNullOrEmptyException e) { throw new FunctionalException(FunctionalExceptionType.ARGUMENT_NULL, ComponentType.WS_CORE, e); } LOGGER.debug("request offset : {}", request.getOffset()); LOGGER.debug(" pageNumber : {}", request.getPageNumber()); LOGGER.debug(" pageSize : {}", request.getPageSize()); LOGGER.debug(" sort : {}", request.getSort()); return this.eventRepository.findAll(specifications, request); }