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

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

Introduction

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

Prototype

LinkRelation getItemResourceRel();

Source Link

Document

Returns the relation type pointing to the item resource within a collection.

Usage

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

private static String getRepresentationDescriptorId(ResourceMetadata metadata) {
    return metadata.getItemResourceRel().concat("-representation");
}

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();//w w w  . j a  v a 2 s.  c o  m
}

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

/**
 * Returns the fallback {@link ResourceDescription} to be used for the given {@link BeanPropertyDefinition}.
 * // ww w .ja va2  s .c  o  m
 * @param ownerMetadata must not be {@literal null}.
 * @param definition must not be {@literal null}.
 * @return
 */
public ResourceDescription getFallbackDescription(ResourceMetadata ownerMetadata,
        BeanPropertyDefinition definition) {

    Assert.notNull(ownerMetadata, "Owner's resource metadata must not be null!");
    Assert.notNull(definition, "BeanPropertyDefinition must not be null!");

    AnnotatedMember member = definition.getPrimaryMember();
    Description description = member.getAnnotation(Description.class);
    ResourceDescription fallback = TypedResourceDescription.defaultFor(ownerMetadata.getItemResourceRel(),
            definition.getInternalName(), definition.getPrimaryMember().getRawType());

    return description == null ? fallback : new AnnotationBasedResourceDescription(description, fallback);
}

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();/*from  w w w  .  j a  v  a2 s  .  co  m*/
}