/** * List a profile link for each exported repository. * * @return */ @RequestMapping(value = PROFILE_ROOT_MAPPING, method = GET) HttpEntity<ResourceSupport> listAllFormsOfMetadata() { ResourceSupport profile = new ResourceSupport(); profile.add(new Link(getRootPath(this.configuration)).withSelfRel()); for (Class<?> domainType : this.repositories) { ResourceMetadata mapping = this.mappings.getMetadataFor(domainType); if (mapping.isExported()) { profile.add(new Link(getPath(this.configuration, mapping), mapping.getRel())); } } return new ResponseEntity<ResourceSupport>(profile, HttpStatus.OK); }
private List<Link> getCollectionResourceLinks(RootResourceInformation resourceInformation, DefaultedPageable pageable) { ResourceMetadata metadata = resourceInformation.getResourceMetadata(); SearchResourceMappings searchMappings = metadata.getSearchResourceMappings(); List<Link> links = new ArrayList<Link>(); links.add(new Link(ProfileController.getPath(this.config, metadata), ProfileResourceProcessor.PROFILE_REL)); if (searchMappings.isExported()) { links.add(entityLinks.linkFor(metadata.getDomainType()).slash(searchMappings.getPath()) .withRel(searchMappings.getRel())); } return links; }
/** * Return the href for the profile link of a given baseUri and domain type mapping. * * @param configuration is the source of the app's baseUri. * @param mapping provides the resource's path. * @return */ public static String getPath(RepositoryRestConfiguration configuration, ResourceMapping mapping) { String path = getRootPath(configuration); return mapping == null ? path : path + mapping.getPath(); } }
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(); }
/** * Add a link to the {@link ProfileController}'s base URI to the app's root URI. * * @param resource * @return */ @Override public RepositoryLinksResource process(RepositoryLinksResource resource) { resource.add(new Link(ProfileController.getRootPath(this.configuration), PROFILE_REL)); return resource; } }
/** * List a profile link for each exported repository. * * @return */ @RequestMapping(value = PROFILE_ROOT_MAPPING, method = GET) HttpEntity<ResourceSupport> listAllFormsOfMetadata() { ResourceSupport profile = new ResourceSupport(); profile.add(new Link(getRootPath(this.configuration)).withSelfRel()); for (Class<?> domainType : this.repositories) { ResourceMetadata mapping = this.mappings.getMetadataFor(domainType); if (mapping.isExported()) { profile.add(new Link(getPath(this.configuration, mapping), mapping.getRel())); } } return new ResponseEntity<ResourceSupport>(profile, HttpStatus.OK); }
@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 the href for the profile link of a given baseUri and domain type mapping. * * @param configuration is the source of the app's baseUri. * @param mapping provides the resource's path. * @return */ public static String getPath(RepositoryRestConfiguration configuration, ResourceMapping mapping) { String path = getRootPath(configuration); return mapping == null ? path : path + mapping.getPath(); } }
private List<Link> getCollectionResourceLinks(RootResourceInformation resourceInformation, DefaultedPageable pageable) { ResourceMetadata metadata = resourceInformation.getResourceMetadata(); SearchResourceMappings searchMappings = metadata.getSearchResourceMappings(); List<Link> links = new ArrayList<Link>(); links.add(new Link(ProfileController.getPath(this.config, metadata), ProfileResourceProcessor.PROFILE_REL)); if (searchMappings.isExported()) { links.add(entityLinks.linkFor(metadata.getDomainType()).slash(searchMappings.getPath()) .withRel(searchMappings.getRel())); } return links; }
/** * Add a link to the {@link ProfileController}'s base URI to the app's root URI. * * @param resource * @return */ @Override public RepositoryLinksResource process(RepositoryLinksResource resource) { resource.add(new Link(ProfileController.getRootPath(this.configuration), PROFILE_REL)); return resource; } }
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(); }
@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()); } });