Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link


  }

  @Test
  public void testname2() throws Exception {

    Link usersLink = discoverUnique("users");
    Link userLink = assertHasContentLinkWithRel("self", request(usersLink));

    MockHttpServletResponse response = patchAndGet(userLink,
        "[{ \"op\": \"replace\", \"path\": \"/address/zipCode\", \"value\": \"ZIP\" },"
        // + "{ \"op\": \"replace\", \"path\": \"/lastname\", \"value\": null }]", //
            + "{ \"op\": \"remove\", \"path\": \"/lastname\" }]", //
View Full Code Here


    movement.orgOrDstFlightPart = part;

    JpaPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(AircraftMovement.class);

    Resource<Object> resource = PersistentEntityResource.build(movement, persistentEntity).//
        withLink(new Link("/api/airports/" + movement.id)).//
        build();

    String result = mapper.writeValueAsString(resource);

    assertThat(JsonPath.read(result, "$_links.self"), is(notNullValue()));
View Full Code Here

    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

    Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!");

    ResourceMetadata metadata = mappings.getMappingFor(type);
    String mappedId = idConverters.getPluginFor(type, DefaultIdConverter.INSTANCE).toRequestId((Serializable) id, type);

    Link link = linkFor(type).slash(mappedId).withRel(metadata.getItemResourceRel());
    ProjectionDefinitionConfiguration projectionConfiguration = config.projectionConfiguration();

    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

    if (!information.isPagingRepository() || !getType(method).equals(Type.SAFE)) {
      return Collections.emptyList();
    }

    Link linkToCollectionResource = entityLinks.linkToCollectionResource(type);
    List<TemplateVariable> variables = linkToCollectionResource.getVariables();
    List<Descriptor> descriptors = new ArrayList<Descriptor>(variables.size());

    ProjectionDefinitionConfiguration projectionConfiguration = configuration.projectionConfiguration();

    for (TemplateVariable variable : variables) {
View Full Code Here

        if (associationLinks.isLinkableAssociation(property)) {

          ResourceMetadata targetTypeMapping = mappings.getMappingFor(property.getActualType());
          String localPath = targetTypeMapping.getRel().concat("#").concat(targetTypeMapping.getItemResourceRel());
          Link link = ControllerLinkBuilder.linkTo(AlpsController.class).slash(localPath).withSelfRel();

          builder.//
              type(Type.SAFE).//
              rt(link.getHref());

        } else {

          List<Descriptor> nestedDescriptors = buildPropertyDescriptors(property.getActualType(), baseRel.concat(".")
              .concat(mapping.getRel()));
View Full Code Here

    if (configuration.metadataConfiguration().alpsEnabled()) {

      BaseUri baseUri = new BaseUri(configuration.getBaseUri());
      String href = baseUri.getUriComponentsBuilder().path(AlpsController.ALPS_ROOT_MAPPING).build().toString();

      resource.add(new Link(href, PROFILE_REL));
    }

    return resource;
  }
View Full Code Here

    }

    BeanWrapper<Object> wrapper = BeanWrapper.create(instance, null);
    Object id = wrapper.getProperty(entity.getIdProperty());

    Link resourceLink = entityLinks.linkToSingleResource(entity.getType(), id);
    return new Link(resourceLink.getHref(), Link.REL_SELF);
  }
View Full Code Here

  @Autowired RepositoryEntityLinks entityLinks;

  @Test
  public void returnsLinkToSingleResource() {

    Link link = entityLinks.linkToSingleResource(Person.class, 1);

    assertThat(link.getHref(), endsWith("/people/1{?projection}"));
    assertThat(link.getRel(), is("person"));
  }
View Full Code Here

  }

  @Test
  public void returnsTemplatedLinkForPagingResource() {

    Link link = entityLinks.linkToCollectionResource(Person.class);

    assertThat(link.isTemplated(), is(true));
    assertThat(link.getVariableNames(), hasItems("page", "size", "sort"));
    assertThat(link.getRel(), is("people"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.Link

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.