Package org.springframework.data.rest.core.config

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


  @Autowired RepositoryRestConfiguration config;

  @Test
  public void shouldProvideResourceMappingForConfiguredRepository() throws Exception {
    ResourceMapping mapping = config.getResourceMappingForRepository(ConfiguredPersonRepository.class);

    assertThat(mapping, notNullValue());
    assertThat(mapping.getRel(), is("people"));
    assertThat(mapping.getPath(), is("people"));
    assertThat(mapping.isExported(), is(false));
  }
View Full Code Here


    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

  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

      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

    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

    }
    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

TOP

Related Classes of org.springframework.data.rest.core.config.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.