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

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

Introduction

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

Prototype

ResourceDescription getItemResourceDescription();

Source Link

Document

Returns the ResourceDescription for the item resource.

Usage

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

private Descriptor buildRepresentationDescriptor(Class<?> type) {

    ResourceMetadata metadata = associations.getMetadataFor(type);

    String href = ProfileController.getPath(this.configuration, metadata);

    return descriptor().//
            id(getRepresentationDescriptorId(metadata)).//
            href(href).//
            doc(getDocFor(metadata.getItemResourceDescription())).//
            descriptors(buildPropertyDescriptors(type, metadata.getItemResourceRel())).//
            build();//w  w  w  .jav a  2s .  co m
}

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

private Descriptor buildItemResourceDescriptor(RootResourceInformation resourceInformation,
        Descriptor representationDescriptor, HttpMethod method) {

    PersistentEntity<?, ?> entity = resourceInformation.getPersistentEntity();
    ResourceMetadata metadata = associations.getMetadataFor(entity.getType());

    return descriptor().//
            id(prefix(method).concat(metadata.getItemResourceRel())).//
            name(metadata.getItemResourceRel()).//
            type(getType(method)).//
            doc(getDocFor(metadata.getItemResourceDescription())).//
            rt("#".concat(representationDescriptor.getId())). //
            descriptors(getProjectionDescriptor(entity.getType(), method)).//
            build();//from ww  w .  ja  v  a 2  s  .c o  m
}

From source file:org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaConverter.java

@Override
public JsonSchema convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {

    final PersistentEntity<?, ?> persistentEntity = entities.getPersistentEntity((Class<?>) source);
    final ResourceMetadata metadata = associations.getMappings().getMetadataFor(persistentEntity.getType());

    Definitions definitions = new Definitions();
    List<AbstractJsonSchemaProperty<?>> propertiesFor = getPropertiesFor(persistentEntity.getType(), metadata,
            definitions);/*  w w  w  .jav a 2  s . c  o m*/

    String title = resolveMessageWithDefault(new ResolvableType(persistentEntity.getType()));

    return new JsonSchema(title, resolveMessage(metadata.getItemResourceDescription()), propertiesFor,
            definitions);
}