Example usage for org.springframework.data.rest.core.mapping ResourceMetadata getSearchResourceMappings

List of usage examples for org.springframework.data.rest.core.mapping ResourceMetadata getSearchResourceMappings

Introduction

In this page you can find the example usage for org.springframework.data.rest.core.mapping ResourceMetadata getSearchResourceMappings.

Prototype

SearchResourceMappings getSearchResourceMappings();

Source Link

Document

Returns the SearchResourceMappings , i.e.

Usage

From source file:springfox.documentation.spring.data.rest.EntitySearchRequestTemplate.java

Collection<? extends RequestHandler> operations() {
    List<RequestHandler> requestHandlers = newArrayList();
    boolean collectionHandlerAdded = false;
    for (ResourceMetadata resource : mappings) {
        for (MethodResourceMapping searchResource : resource.getSearchResourceMappings()) {
            EntitySearchRequestHandler handler = new EntitySearchRequestHandler(resolver, requestMapping,
                    new HandlerMethod(searchResource.getMethod().getClass(), searchResource.getMethod()),
                    searchResource, resource);
            if (handler.resourceType() == ResourceType.ITEM || !collectionHandlerAdded) {
                requestHandlers.add(handler);
                if (!collectionHandlerAdded) {
                    collectionHandlerAdded = (handler.resourceType() == ResourceType.COLLECTION);
                }//  w ww. jav a2 s . c o m
            }
        }
    }
    return requestHandlers;
}

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

private Collection<Descriptor> buildSearchResourceDescriptors(PersistentEntity<?, ?> entity) {

    ResourceMetadata metadata = associations.getMetadataFor(entity.getType());
    List<Descriptor> descriptors = new ArrayList<Descriptor>();

    for (MethodResourceMapping methodMapping : metadata.getSearchResourceMappings()) {

        List<Descriptor> parameterDescriptors = new ArrayList<Descriptor>();

        for (ParameterMetadata parameterMetadata : methodMapping.getParametersMetadata()) {

            parameterDescriptors.add(//
                    descriptor().//
                            name(parameterMetadata.getName()).//
                            doc(getDocFor(parameterMetadata.getDescription())).//
                            type(Type.SEMANTIC)//
                            .build());//from   w  w w.  jav a  2 s.  co  m
        }

        descriptors.add(descriptor().//
                type(Type.SAFE).//
                name(methodMapping.getRel()).//
                descriptors(parameterDescriptors).//
                build());
    }

    return descriptors;
}