use of org.springframework.data.domain.PageRequest in project oc-explorer 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();
}
use of org.springframework.data.domain.PageRequest in project uplace.es by Uplace.
the class UserServiceIntTest method assertThatAnonymousUserIsNotGet.
@Test
@Transactional
public void assertThatAnonymousUserIsNotGet() {
user.setLogin(Constants.ANONYMOUS_USER);
if (!userRepository.findOneByLogin(Constants.ANONYMOUS_USER).isPresent()) {
userRepository.saveAndFlush(user);
}
final PageRequest pageable = new PageRequest(0, (int) userRepository.count());
final Page<UserDTO> allManagedUsers = userService.getAllManagedUsers(pageable);
assertThat(allManagedUsers.getContent().stream().noneMatch(user -> Constants.ANONYMOUS_USER.equals(user.getLogin()))).isTrue();
}
use of org.springframework.data.domain.PageRequest in project uplace.es by Uplace.
the class PaginationUtilUnitTest method generatePaginationHttpHeadersTest.
@Test
public void generatePaginationHttpHeadersTest() {
String baseUrl = "/api/_search/example";
List<String> content = new ArrayList<>();
Page<String> page = new PageImpl<>(content, new PageRequest(6, 50), 400L);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, baseUrl);
List<String> strHeaders = headers.get(HttpHeaders.LINK);
assertNotNull(strHeaders);
assertTrue(strHeaders.size() == 1);
String headerData = strHeaders.get(0);
assertTrue(headerData.split(",").length == 4);
String expectedData = "</api/_search/example?page=7&size=50>; rel=\"next\"," + "</api/_search/example?page=5&size=50>; rel=\"prev\"," + "</api/_search/example?page=7&size=50>; rel=\"last\"," + "</api/_search/example?page=0&size=50>; rel=\"first\"";
assertEquals(expectedData, headerData);
List<String> xTotalCountHeaders = headers.get("X-Total-Count");
assertTrue(xTotalCountHeaders.size() == 1);
assertTrue(Long.valueOf(xTotalCountHeaders.get(0)).equals(400L));
}
use of org.springframework.data.domain.PageRequest in project zhcet-web by zhcet-amu.
the class NotificationReadingService method getNotifications.
public Page<NotificationRecipient> getNotifications(int page) {
String userId = Auditor.getLoggedInUsername();
PageRequest pageRequest = PageRequest.of(page - 1, PAGE_SIZE, Sort.Direction.DESC, "notification.sentTime");
return notificationRecipientRepository.findByRecipientUserId(userId, pageRequest);
}
use of org.springframework.data.domain.PageRequest in project zhcet-web by zhcet-amu.
the class NotificationReadingService method getFavoriteNotifications.
public Page<NotificationRecipient> getFavoriteNotifications(int page) {
String userId = Auditor.getLoggedInUsername();
PageRequest pageRequest = PageRequest.of(page - 1, PAGE_SIZE, Sort.Direction.DESC, "notification.sentTime");
return notificationRecipientRepository.findByRecipientUserIdAndFavorite(userId, true, pageRequest);
}
Aggregations