Example usage for org.springframework.data.repository.core RepositoryInformation isPagingRepository

List of usage examples for org.springframework.data.repository.core RepositoryInformation isPagingRepository

Introduction

In this page you can find the example usage for org.springframework.data.repository.core RepositoryInformation isPagingRepository.

Prototype

boolean isPagingRepository();

Source Link

Document

Returns whether the repository is a paging one.

Usage

From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java

/**
 * Creates the {@link Descriptor}s for pagination parameters.
 * //from w w w.  j  a  va  2 s  .  c o m
 * @param type
 * @return
 */
private List<Descriptor> getPaginationDescriptors(Class<?> type, HttpMethod method) {

    RepositoryInformation information = repositories.getRepositoryInformationFor(type);

    if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) {
        return Collections.emptyList();
    }

    Link linkToCollectionResource = entityLinks.linkToCollectionResource(type);
    List<TemplateVariable> variables = linkToCollectionResource.getVariables();
    List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size());

    ProjectionDefinitionConfiguration projectionConfiguration = configuration.getProjectionConfiguration();

    for (TemplateVariable variable : variables) {

        // Skip projection parameter
        if (projectionConfiguration.getParameterName().equals(variable.getName())) {
            continue;
        }

        ResourceDescription description = SimpleResourceDescription.defaultFor(variable.getDescription());

        descriptors.add(//
                descriptor().//
                        name(variable.getName()).//
                        type(Type.SEMANTIC).//
                        doc(getDocFor(description)).//
                        build());
    }

    return descriptors;
}