Package org.springframework.hateoas

Examples of org.springframework.hateoas.TemplateVariables


    UriComponentsBuilder builder = fromUri(base.expand());
    pageableResolver.enhance(builder, getMethodParameter(), pageable);

    UriComponents components = builder.build();
    TemplateVariables variables = new TemplateVariables(base.getVariables());
    variables = variables.concat(pageableResolver.getPaginationTemplateVariables(getMethodParameter(), components));

    return new Link(new UriTemplate(components.toString()).with(variables), rel);
  }
View Full Code Here


      return TemplateVariables.NONE;
    }

    String description = String.format("pagination.%s.description", sortParameter);
    VariableType type = append ? REQUEST_PARAM_CONTINUED : REQUEST_PARAM;
    return new TemplateVariables(new TemplateVariable(sortParameter, type, description));
  }
View Full Code Here

        String description = String.format("pagination.%s.description", propertyName);
        names.add(new TemplateVariable(propertyName, type, description));
      }
    }

    TemplateVariables pagingVariables = new TemplateVariables(names);
    return pagingVariables.concat(sortResolver.getSortTemplateVariables(parameter, template));
  }
View Full Code Here

      if (!mapping.isExported()) {
        continue;
      }

      TemplateVariables variables = new TemplateVariables();

      for (ParameterMetadata metadata : mapping.getParametersMetadata()) {
        variables = variables.concat(new TemplateVariable(metadata.getName(), VariableType.REQUEST_PARAM));
      }

      String href = builder.slash(mapping.getPath()).toString().concat(variables.toString());

      Link link = new Link(href, mapping.getRel());

      if (mapping.isPagingResource()) {
        link = assembler.appendPaginationParameterTemplates(link);
      } else if (mapping.isSortableResource()) {

        TemplateVariables sortVariable = sortResolver.getSortTemplateVariables(null, UriComponentsBuilder
            .fromUriString(link.expand().getHref()).build());
        link = new Link(new UriTemplate(link.getHref()).with(sortVariable), link.getRel());
      }

      links.add(link);
View Full Code Here

  }

  public Link linkToPagedResource(Class<?> type, Pageable pageable) {

    ResourceMetadata metadata = mappings.getMappingFor(type);
    TemplateVariables variables = new TemplateVariables();
    String href = linkFor(type).withSelfRel().getHref();

    if (metadata.isPagingResource()) {

      UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(href);

      if (pageable != null) {
        resolver.enhance(builder, null, pageable);
      }

      href = builder.build().toString();

      variables = variables.concat(resolver.getPaginationTemplateVariables(null, builder.build()));
    }

    ProjectionDefinitionConfiguration projectionConfiguration = config.projectionConfiguration();

    if (projectionConfiguration.hasProjectionFor(type)) {
      variables = variables.concat(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM));
    }

    return variables.asList().isEmpty() ? linkFor(type).withRel(metadata.getRel()) : new Link(new UriTemplate(href,
        variables), metadata.getRel());
  }
View Full Code Here

    if (!projectionConfiguration.hasProjectionFor(type)) {
      return link;
    }

    String parameterName = projectionConfiguration.getParameterName();
    TemplateVariables templateVariables = new TemplateVariables(new TemplateVariable(parameterName, REQUEST_PARAM));
    UriTemplate template = new UriTemplate(link.getHref(), templateVariables);

    return new Link(template.toString(), metadata.getItemResourceRel());
  }
View Full Code Here


    // Maybe https://github.com/spring-projects/spring-hateoas/issues/169 will help eventually
    TemplateVariable start = new TemplateVariable("start", VariableType.REQUEST_PARAM);
    TemplateVariable lod = new TemplateVariable("detailLevel", VariableType.REQUEST_PARAM_CONTINUED);
    TemplateVariables vars = new TemplateVariables(start, lod);
    for (CompletionKind k : CompletionKind.values()) {
      Object mi = ControllerLinkBuilder.methodOn(CompletionsController.class).completions(k, "", 42);
      Link link = ControllerLinkBuilder.linkTo(mi).withRel(String.format("completions/%s", k));
      String href = link.getHref().substring(0, link.getHref().lastIndexOf('?'));
      UriTemplate template = new UriTemplate(href, vars);
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.TemplateVariables

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.