Examples of ResourceMapping


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

    if (persistentProperty == null) {
      return null;
    }

    ResourceMapping repoMapping = getResourceMapping(config, repoInfo);
    ResourceMapping entityMapping = getResourceMapping(config, persistentProperty.getOwner());
    ResourceMapping propertyMapping = entityMapping.getResourceMappingFor(persistentProperty.getName());

    return String.format("%s.%s.%s", repoMapping.getRel(), entityMapping.getRel(),
        (null != propertyMapping ? propertyMapping.getRel() : persistentProperty.getName()));
  }
View Full Code Here

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

  public static ResourceMapping getResourceMapping(RepositoryRestConfiguration config, RepositoryInformation repoInfo) {
    if (null == repoInfo) {
      return null;
    }
    Class<?> repoType = repoInfo.getRepositoryInterface();
    ResourceMapping mapping = (null != config ? config.getResourceMappingForRepository(repoType) : null);
    return merge(repoType, mapping);
  }
View Full Code Here

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

      PersistentEntity<?, ?> persistentEntity) {
    if (null == persistentEntity) {
      return null;
    }
    Class<?> domainType = persistentEntity.getType();
    ResourceMapping mapping = (null != config ? config.getResourceMappingForDomainType(domainType) : null);
    return merge(domainType, mapping);
  }
View Full Code Here

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

    ResourceMapping mapping = (null != config ? config.getResourceMappingForDomainType(domainType) : null);
    return merge(domainType, mapping);
  }

  public static ResourceMapping merge(Method method, ResourceMapping mapping) {
    ResourceMapping defaultMapping = new ResourceMapping(findRel(method), findPath(method), findExported(method));
    if (null != mapping) {
      return new ResourceMapping((null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel()),
          (null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath()),
          (mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported()));
    }
    return defaultMapping;
  }
View Full Code Here

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

    }
    return defaultMapping;
  }

  public static ResourceMapping merge(Class<?> type, ResourceMapping mapping) {
    ResourceMapping defaultMapping = new ResourceMapping(findRel(type), findPath(type), findExported(type));
    if (null != mapping) {
      return new ResourceMapping((null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel()),
          (null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath()),
          (mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported()))
          .addResourceMappings(mapping.getResourceMappings());
    }
    return defaultMapping;
  }
View Full Code Here

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

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

      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

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

      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

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

    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

Examples of org.springframework.web.portlet.bind.annotation.ResourceMapping

          if (typeMapping != null) {
            params = StringUtils.mergeStringArrays(typeMapping.params(), params);
          }
          ActionMapping actionMapping = AnnotationUtils.findAnnotation(method, ActionMapping.class);
          RenderMapping renderMapping = AnnotationUtils.findAnnotation(method, RenderMapping.class);
          ResourceMapping resourceMapping = AnnotationUtils.findAnnotation(method, ResourceMapping.class);
          EventMapping eventMapping = AnnotationUtils.findAnnotation(method, EventMapping.class);
          RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class);
          if (actionMapping != null) {
            params = StringUtils.mergeStringArrays(params, actionMapping.params());
            predicate = new ActionMappingPredicate(actionMapping.value(), params);
          }
          else if (renderMapping != null) {
            params = StringUtils.mergeStringArrays(params, renderMapping.params());
            predicate = new RenderMappingPredicate(renderMapping.value(), params);
          }
          else if (resourceMapping != null) {
            predicate = new ResourceMappingPredicate(resourceMapping.value());
          }
          else if (eventMapping != null) {
            predicate = new EventMappingPredicate(eventMapping.value());
          }
          if (requestMapping != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.