Package org.springframework.data.rest.core.mapping

Examples of org.springframework.data.rest.core.mapping.ResourceMapping


      @Override
      public void doWithPersistentProperty(PersistentProperty<?> property) {

        BeanPropertyDefinition propertyDefinition = jackson.getDefinitionFor(property);
        ResourceMapping propertyMapping = propertyMappings.getMappingFor(property);

        if (propertyDefinition != null) {
          propertyDescriptors.add(//
              descriptor(). //
                  type(Type.SEMANTIC).//
                  name(propertyDefinition.getName()).//
                  doc(getDocFor(propertyMapping.getDescription())).//
                  build());
        }
      }
    });

    entity.doWithAssociations(new SimpleAssociationHandler() {

      @Override
      public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {

        PersistentProperty<?> property = association.getInverse();
        ResourceMapping mapping = propertyMappings.getMappingFor(property);

        DescriptorBuilder builder = descriptor().//
            name(mapping.getRel()).doc(getDocFor(mapping.getDescription()));

        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()));

          builder = builder.//
              type(Type.SEMANTIC).//
              descriptors(nestedDescriptors);
        }
View Full Code Here


      return response;
    }

    ResourceMetadata repoMapping = repoRequest.getResourceMetadata();
    PersistentProperty<?> persistentProp = repoRequest.getPersistentEntity().getPersistentProperty(property);
    ResourceMapping propertyMapping = repoMapping.getMappingFor(persistentProp);

    ResourceSupport resource = response.getBody();

    List<Link> links = new ArrayList<Link>();

    ControllerLinkBuilder linkBuilder = linkTo(methodOn(RepositoryPropertyReferenceController.class)
        .followPropertyReference(repoRequest, id, property, assembler));

    if (resource instanceof Resource) {

      Object content = ((Resource<?>) resource).getContent();
      if (content instanceof Iterable) {

        for (Resource<?> res : (Iterable<Resource<?>>) content) {
          links.add(linkBuilder.withRel(propertyMapping.getRel()));
        }

      } else if (content instanceof Map) {

        Map<Object, Resource<?>> map = (Map<Object, Resource<?>>) content;

        for (Entry<Object, Resource<?>> entry : map.entrySet()) {
          Link l = new Link(entry.getValue().getLink("self").getHref(), entry.getKey().toString());
          links.add(l);
        }
      }

    } else {
      links.add(linkBuilder.withRel(propertyMapping.getRel()));
    }

    return ControllerUtils.toResponseEntity(HttpStatus.OK, null, new Resource<Object>(EMPTY_RESOURCE_LIST, links));
  }
View Full Code Here

      public void doWithPersistentProperty(PersistentProperty<?> persistentProperty) {

        Class<?> propertyType = persistentProperty.getType();
        String type = uncapitalize(propertyType.getSimpleName());

        ResourceMapping propertyMapping = metadata.getMappingFor(persistentProperty);
        ResourceDescription description = propertyMapping.getDescription();
        String message = resolveMessage(description);

        Property property = persistentProperty.isCollectionLike() ? //
        new ArrayProperty("array", message, false)
            : new Property(type, message, false);
View Full Code Here

    PersistentProperty<?> property = association.getInverse();

    if (isLinkableAssociation(property)) {

      ResourceMapping propertyMapping = propertyMappings.getMappingFor(property);

      String href = path.slash(propertyMapping.getPath()).toString();
      String rel = propertyMapping.getRel();

      return Collections.singletonList(new Link(href, rel));
    }

    return Collections.emptyList();
View Full Code Here

TOP

Related Classes of org.springframework.data.rest.core.mapping.ResourceMapping

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.