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

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

Introduction

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

Prototype

Class<?> getDomainType();

Source Link

Document

Returns the domain type that is exposed through the resource.

Usage

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

List<RequestHandler> operations() {
    List<RequestHandler> requestHandlers = newArrayList();
    for (ResourceMetadata resource : restMappings) {

        Class<?> domainType = resource.getDomainType();
        RepositoryInformation entity = repositories.getRepositoryInformationFor(domainType);
        Class<? extends Serializable> idType = entity.getIdType();
        //TODO: cache the id/type combo

        requestHandlers.add(new EntityRequestHandler(typeResolver, resource, idType, domainType,
                requestMappingInfo, handlerMethod));

    }// www. j  ava 2s .c om
    return requestHandlers;
}

From source file:org.lightadmin.core.web.support.ConfigurationHandlerMethodArgumentResolver.java

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    ResourceMetadata resourceMetadata = resourceMetadataResolver.resolveArgument(parameter, mavContainer,
            webRequest, binderFactory);/* w w w  . j  a va2 s .  c  o m*/

    return configuration.forManagedDomainType(resourceMetadata.getDomainType());
}

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

/**
 * Builds a descriptor for the projection parameter of the given resource.
 * //from  ww w . j a v a2s.c o m
 * @param metadata
 * @return
 */
private Descriptor buildProjectionDescriptor(ResourceMetadata metadata) {

    ProjectionDefinitionConfiguration projectionConfiguration = configuration.getProjectionConfiguration();
    String projectionParameterName = projectionConfiguration.getParameterName();

    Map<String, Class<?>> projections = projectionConfiguration.getProjectionsFor(metadata.getDomainType());
    List<Descriptor> projectionDescriptors = new ArrayList<Descriptor>(projections.size());

    for (Entry<String, Class<?>> projection : projections.entrySet()) {

        Class<?> type = projection.getValue();
        String key = String.format("%s.%s.%s", metadata.getRel(), projectionParameterName, projection.getKey());
        ResourceDescription fallback = SimpleResourceDescription.defaultFor(key);
        AnnotationBasedResourceDescription projectionDescription = new AnnotationBasedResourceDescription(type,
                fallback);

        projectionDescriptors.add(//
                descriptor().//
                        type(Type.SEMANTIC).//
                        name(projection.getKey()).//
                        doc(getDocFor(projectionDescription)).//
                        descriptors(createJacksonDescriptor(projection.getKey(), type)).//
                        build());
    }

    return descriptor().//
            type(Type.SEMANTIC).//
            name(projectionParameterName).//
            doc(getDocFor(SimpleResourceDescription.defaultFor(projectionParameterName))).//
            descriptors(projectionDescriptors).build();
}