@Override public LinkBuilder linkForSingleResource(Class<?> type, Object id) { return linkFor(type).slash(id); }
/** * Returns the {@link Link} to point to the {@link Payment} for the given {@link Order}. * * @param order must not be {@literal null}. * @return */ Link getPaymentLink(Order order) { return entityLinks.linkForSingleResource(order).slash(PAYMENT).withRel(PAYMENT_REL); }
/** * Returns the {@link Link} to the {@link Receipt} of the given {@link Order}. * * @param order * @return */ Link getReceiptLink(Order order) { return entityLinks.linkForSingleResource(order).slash(RECEIPT).withRel(RECEIPT_REL); } }
@Override public Link linkToSingleResource(Class<?> entity, Object id) { return linkFor(entity).slash(id).withSelfRel(); }
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; }
/** * Renders the given {@link Receipt} including links to the associated {@link Order} as well as a self link in case * the {@link Receipt} is still available. * * @param receipt * @return */ private HttpEntity<Resource<Receipt>> createReceiptResponse(Receipt receipt) { Order order = receipt.getOrder(); Resource<Receipt> resource = new Resource<>(receipt); resource.add(entityLinks.linkToSingleResource(order)); if (!order.isTaken()) { resource.add(entityLinks.linkForSingleResource(order).slash("receipt").withSelfRel()); } return ResponseEntity.ok(resource); }
@Override public Link linkToSingleResource(Class<?> type, Object id) { Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!"); ResourceMetadata metadata = mappings.getMetadataFor(type); String mappedId = idConverters.getPluginFor(type)// .orElse(DefaultIdConverter.INSTANCE)// .toRequestId((Serializable) id, type); Link link = linkFor(type).slash(mappedId).withRel(metadata.getItemResourceRel()); return new Link(new UriTemplate(link.getHref(), getProjectionVariable(type)).toString(), metadata.getItemResourceRel()); }
/** * Returns the link pointing to the search resource with the given rel of the given type and pre-expands the * calculated URi tempalte with the given {@link Pageable} and {@link Sort}. * * @param type must not be {@literal null}. * @param rel must not be {@literal null} or empty. * @param pageable can be {@literal null}. * @param sort can be {@literal null}. * @return */ private Link getSearchResourceLinkFor(Class<?> type, String rel, Pageable pageable, Sort sort) { Assert.notNull(type, "Domain type must not be null!"); Assert.hasText(rel, "Relation name must not be null or empty!"); SearchResourceMappings searchMappings = mappings.getSearchResourceMappings(type); MethodResourceMapping mapping = searchMappings.getExportedMethodMappingForRel(rel); if (mapping == null) { return null; } LinkBuilder builder = linkFor(type).// slash(mappings.getSearchResourceMappings(type).getPath()).// slash(mapping.getPath()); UriComponents uriComponents = prepareUri(builder.toString(), mapping, pageable, sort); TemplateVariables variables = getParameterVariables(mapping).// concat(getTemplateVariables(uriComponents, mapping, pageable, sort)).// concat(getProjectionVariable(mapping.getReturnedDomainType())); return new Link(new UriTemplate(uriComponents.toString(), variables), mapping.getRel()); }
@Override public LinkBuilder linkForSingleResource(Class<?> type, Object id) { return linkFor(type).slash(id); }
@Override public Link linkToSingleResource(Class<?> entity, Object id) { return linkFor(entity).slash(id).withSelfRel(); }
public Link getConfigurationLink(WorkBook workBook) { return this.entityLinks.linkForSingleResource(WorkBook.class, workBook.getId()) .slash("configuration").withRel("configuration"); } }
public Link getConfigurationLink(Workbench workbench) { return this.entityLinks.linkForSingleResource(Workbench.class, workbench.getId()) .slash("configuration").withRel("configuration"); } }
@Override public PagedResources<Resource<Taco>> process(PagedResources<Resource<Taco>> resources) { resources .add(entityLinks .linkFor(Taco.class) .slash("recent") .withRel("recents")); return resources; }
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; }
@Override public Link linkToSingleResource(Class<?> type, Object id) { Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!"); ResourceMetadata metadata = mappings.getMetadataFor(type); String mappedId = idConverters.getPluginFor(type)// .orElse(DefaultIdConverter.INSTANCE)// .toRequestId((Serializable) id, type); Link link = linkFor(type).slash(mappedId).withRel(metadata.getItemResourceRel()); return new Link(new UriTemplate(link.getHref(), getProjectionVariable(type)).toString(), metadata.getItemResourceRel()); }
/** * Returns the link pointing to the search resource with the given rel of the given type and pre-expands the * calculated URi tempalte with the given {@link Pageable} and {@link Sort}. * * @param type must not be {@literal null}. * @param rel must not be {@literal null} or empty. * @param pageable can be {@literal null}. * @param sort can be {@literal null}. * @return */ private Link getSearchResourceLinkFor(Class<?> type, String rel, Pageable pageable, Sort sort) { Assert.notNull(type, "Domain type must not be null!"); Assert.hasText(rel, "Relation name must not be null or empty!"); SearchResourceMappings searchMappings = mappings.getSearchResourceMappings(type); MethodResourceMapping mapping = searchMappings.getExportedMethodMappingForRel(rel); if (mapping == null) { return null; } LinkBuilder builder = linkFor(type).// slash(mappings.getSearchResourceMappings(type).getPath()).// slash(mapping.getPath()); UriComponents uriComponents = prepareUri(builder.toString(), mapping, pageable, sort); TemplateVariables variables = getParameterVariables(mapping).// concat(getTemplateVariables(uriComponents, mapping, pageable, sort)).// concat(getProjectionVariable(mapping.getReturnedDomainType())); return new Link(new UriTemplate(uriComponents.toString(), variables), mapping.getRel()); }
.withRel("jobs/executions/execution/steps"))); root.add(unescapeTemplateVariables(entityLinks.linkFor(StepExecutionResource.class, "{jobExecutionId}") .slash("{stepId}").withRel("jobs/executions/execution/steps/step"))); root.add(unescapeTemplateVariables( entityLinks.linkFor(StepExecutionProgressInfoResource.class, "{jobExecutionId}").slash("{stepId}") .slash("progress").withRel("jobs/executions/execution/steps/step/progress"))); taskTemplated = entityLinks.linkToCollectionResource(JobInstanceResource.class).getHref() + "{?name}"; root.add(new Link(taskTemplated).withRel("jobs/instances/name"));
.withRel("jobs/executions/execution/steps"))); root.add(unescapeTemplateVariables(entityLinks.linkFor(StepExecutionResource.class, "{jobExecutionId}") .slash("{stepId}").withRel("jobs/executions/execution/steps/step"))); root.add(unescapeTemplateVariables( entityLinks.linkFor(StepExecutionProgressInfoResource.class, "{jobExecutionId}").slash("{stepId}") .slash("progress").withRel("jobs/executions/execution/steps/step/progress"))); taskTemplated = entityLinks.linkToCollectionResource(JobInstanceResource.class).getHref() + "{?name}"; root.add(new Link(taskTemplated).withRel("jobs/instances/name"));