Java Code Examples for org.springframework.data.domain.Pageable#unpaged()

The following examples show how to use org.springframework.data.domain.Pageable#unpaged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JpaSystemManagement.java    From hawkbit with Eclipse Public License 1.0 7 votes vote down vote up
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
// Exception squid:S2229 - calling findTenants without transaction is
// intended in this case
@SuppressWarnings("squid:S2229")
public void forEachTenant(final Consumer<String> consumer) {

    Page<String> tenants;
    Pageable query = PageRequest.of(0, MAX_TENANTS_QUERY);
    do {
        tenants = findTenants(query);
        tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> {
            try {
                consumer.accept(tenant);
            } catch (final RuntimeException ex) {
                LOGGER.debug("Exception on forEachTenant execution for tenant {}. Continue with next tenant.",
                        tenant, ex);
                LOGGER.error("Exception on forEachTenant execution for tenant {} with error message [{}]. "
                        + "Continue with next tenant.", tenant, ex.getMessage());
            }
            return null;
        }));
    } while ((query = tenants.nextPageable()) != Pageable.unpaged());

}
 
Example 2
Source File: SimpleKeyValueRepository.java    From spring-data-keyvalue with Apache License 2.0 6 votes vote down vote up
@Override
public Page<T> findAll(Pageable pageable) {

	Assert.notNull(pageable, "Pageable must not be null!");

	if (pageable.isUnpaged()) {
		List<T> result = findAll();
		return new PageImpl<>(result, Pageable.unpaged(), result.size());
	}

	Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
			entityInformation.getJavaType());

	return new PageImpl<>(IterableConverter.toList(content), pageable,
			this.operations.count(entityInformation.getJavaType()));
}
 
Example 3
Source File: SpringPageableRequestArgumentBinder.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public BindingResult<Pageable> bind(ArgumentConversionContext<Pageable> context, HttpRequest<?> source) {
    HttpParameters parameters = source.getParameters();
    int page = Math.max(parameters.getFirst(configuration.getPageParameterName(), Integer.class)
            .orElse(0), 0);
    final int configuredMaxSize = configuration.getMaxPageSize();
    final int defaultSize = configuration.getDefaultPageSize();
    int size = Math.min(parameters.getFirst(configuration.getSizeParameterName(), Integer.class)
            .orElse(defaultSize), configuredMaxSize);
    String sortParameterName = configuration.getSortParameterName();
    boolean hasSort = parameters.contains(sortParameterName);
    Pageable pageable;
    Sort sort;
    if (hasSort) {
        List<String> sortParams = parameters.getAll(sortParameterName);

        List<Sort.Order> orders = sortParams.stream()
                .map(sortMapper)
                .collect(Collectors.toList());
        sort = Sort.by(orders);
    } else {
        sort = Sort.unsorted();
    }

    if (size < 1) {
        if (page == 0 && configuredMaxSize < 1 && sort.isUnsorted()) {
            pageable = Pageable.unpaged();
        } else {
            pageable = PageRequest.of(page, defaultSize, sort);
        }
    } else {
        pageable = PageRequest.of(page, size, sort);
    }

    return () -> Optional.of(pageable);
}
 
Example 4
Source File: SongResource.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@GET
@Produces("application/json")
@Path("/all")
public String all() {
    Pageable wholePage = Pageable.unpaged();
    Page<Song> page = songRepository.findAll(wholePage);
    return page.hasPrevious() + " - " + page.hasNext() + " / " + page.getNumberOfElements();
}
 
Example 5
Source File: PageableAdapter.java    From graphql-spqr-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Override
public Pagination convertOutput(Pageable original, AnnotatedType type, ResolutionEnvironment resolutionEnvironment) {
    return original == Pageable.unpaged() ? null : new Pagination(original);
}
 
Example 6
Source File: MongoAxonEventRepository.java    From hesperides with GNU General Public License v3.0 4 votes vote down vote up
private static Pageable buildPageable(Integer page, Integer size) {
    return page != null && size != null && page > 0 && size > 0
            ? PageRequest.of(page - 1, size)
            : Pageable.unpaged();
}