List of usage examples for org.springframework.data.rest.core.mapping ResourceMapping getRel
LinkRelation getRel();
From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java
private List<Descriptor> buildPropertyDescriptors(final Class<?> type, String baseRel) { final PersistentEntity<?, ?> entity = persistentEntities.getPersistentEntity(type); final List<Descriptor> propertyDescriptors = new ArrayList<Descriptor>(); final JacksonMetadata jackson = new JacksonMetadata(mapper, type); final ResourceMetadata metadata = associations.getMetadataFor(entity.getType()); entity.doWithProperties(new SimplePropertyHandler() { @Override/*w ww . j a va 2 s . c om*/ public void doWithPersistentProperty(PersistentProperty<?> property) { BeanPropertyDefinition propertyDefinition = jackson.getDefinitionFor(property); ResourceMapping propertyMapping = metadata.getMappingFor(property); if (propertyDefinition != null) { if (property.isIdProperty() && !configuration.isIdExposedFor(property.getOwner().getType())) { return; } propertyDescriptors.add(// descriptor(). // type(Type.SEMANTIC).// name(propertyDefinition.getName()).// doc(getDocFor(propertyMapping.getDescription(), property)).// build()); } } }); entity.doWithAssociations(new SimpleAssociationHandler() { @Override public void doWithAssociation(Association<? extends PersistentProperty<?>> association) { PersistentProperty<?> property = association.getInverse(); if (!jackson.isExported(property) || !associations.isLinkableAssociation(property)) { return; } ResourceMapping mapping = metadata.getMappingFor(property); DescriptorBuilder builder = descriptor().// name(mapping.getRel()).doc(getDocFor(mapping.getDescription())); ResourceMetadata targetTypeMetadata = associations.getMetadataFor(property.getActualType()); String href = ProfileController.getPath(configuration, targetTypeMetadata) + "#" + getRepresentationDescriptorId(targetTypeMetadata); Link link = new Link(href).withSelfRel(); builder.// type(Type.SAFE).// rt(link.getHref()); propertyDescriptors.add(builder.build()); } }); return propertyDescriptors; }