Java Code Examples for org.springframework.data.rest.core.config.RepositoryRestConfiguration#exposeIdsFor()

The following examples show how to use org.springframework.data.rest.core.config.RepositoryRestConfiguration#exposeIdsFor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestConfiguration.java    From moserp with Apache License 2.0 6 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.addIncludeFilter(new AssignableTypeFilter(IdentifiableEntity.class));
    Set<BeanDefinition> components = provider.findCandidateComponents(this.getClass().getPackage().getName());
    List<Class<?>> classes = new ArrayList<>();

    components.forEach(component -> {
        try {
            classes.add(Class.forName(component.getBeanClassName()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    });

    config.exposeIdsFor(classes.toArray(new Class[classes.size()]));
}
 
Example 2
Source File: CustomRestMvcConfiguration.java    From spring-data-jpa-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Repository rest configurer repository rest configurer.
 *
 * @return the repository rest configurer
 */
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {
    return new RepositoryRestConfigurer() {
        @Override
        public void configureRepositoryRestConfiguration(RepositoryRestConfiguration configuration) {
            configuration.exposeIdsFor(Dept.class, Employee.class);
        }
    };
}
 
Example 3
Source File: SpringRestDataConfig.java    From microservice-atom with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example 4
Source File: SpringRestDataConfig.java    From microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Customer.class);
		}
	};
}
 
Example 5
Source File: MainApp.java    From botanic-ng with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {
	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(
							RepositoryRestConfiguration config) {
			config.exposeIdsFor(Plant.class, Image.class, Garden.class);
			config.setBasePath("/api");
		}
	};
}
 
Example 6
Source File: RepositoryConfig.java    From entref-spring-boot with MIT License 5 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    // expose the ids for the given model types
    config.exposeIdsFor(Person.class);
    config.exposeIdsFor(Title.class);

    // configure how we find and load repositories to let us disable them at runtime with an environment variable
    config.setRepositoryDetectionStrategy(metadata -> {
        // if it's not exported, exclude it
        if (!metadata.getRepositoryInterface().getAnnotation(RepositoryRestResource.class).exported()) {
            return false;
        }

        String className = metadata.getRepositoryInterface().getName();
        String exclusionList = env.getProperty(Constants.ENV_EXCLUDE_FILTER);

        if (exclusionList != null && !exclusionList.isEmpty()) {
            for (String exclude : exclusionList.split(",")) {
                // see if we get any hits, treating the exclusion list entry as a regex pattern
                // note: this allows us to hit 'ClassA' even if it's really 'com.package.ClassA'
                if (Pattern.compile(exclude).matcher(className).find()) {
                    // exclude if we match
                    return false;
                }
            }
        }

        // default to allowing the repository
        return true;
    });
}
 
Example 7
Source File: SpringRestDataConfig.java    From microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example 8
Source File: SimpleRepositoryRestMvcConfiguration.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureRepositoryRestConfiguration(
		RepositoryRestConfiguration config) {
	config.exposeIdsFor(Person.class);
}
 
Example 9
Source File: ApplicationConfiguration.java    From spring-rest-black-market with MIT License 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.exposeIdsFor(Ad.class);
    config.getProjectionConfiguration().addProjection(MinimalAdProjection.class);
    config.getProjectionConfiguration().addProjection(StandardAdProjection.class);
}
 
Example 10
Source File: ShoppingCartApplication.java    From spring-cloud-event-sourcing-example with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.exposeIdsFor(Order.class);
    config.setBasePath("/api");
}
 
Example 11
Source File: SpringDataRestCustomization.java    From spring-boot-greendogdelivery-casadocodigo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	config.exposeIdsFor(Item.class,ClienteRepository.class);
}
 
Example 12
Source File: AppRepositoryRestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.exposeIdsFor(Rubric.class, Criterion.class, Rating.class, ToolItemRubricAssociation.class, Evaluation.class, Resource.class, CriterionOutcome.class);
}
 
Example 13
Source File: Application.java    From micro-ecommerce with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	config.exposeIdsFor(Product.class, Category.class);
}
 
Example 14
Source File: SimpleRepositoryRestMvcConfiguration.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureRepositoryRestConfiguration(
		RepositoryRestConfiguration config) {
	config.exposeIdsFor(Person.class);
}
 
Example 15
Source File: Application.java    From spring-cloud-microservice-example with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) {
    ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);

    RepositoryRestConfiguration restConfiguration = ctx.getBean("config", RepositoryRestConfiguration.class);
    restConfiguration.exposeIdsFor(User.class);
}
 
Example 16
Source File: AppRepositoryRestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.exposeIdsFor(Rubric.class, Criterion.class, Rating.class, ToolItemRubricAssociation.class, Evaluation.class, Resource.class, CriterionOutcome.class);
}
 
Example 17
Source File: SpringDataRestConfiguration.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
  config.exposeIdsFor(Ingredient.class);
}
 
Example 18
Source File: SpringDataRestConfiguration.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
  config.exposeIdsFor(Ingredient.class);
}
 
Example 19
Source File: SpringDataRestConfiguration.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
  config.exposeIdsFor(Ingredient.class);
}
 
Example 20
Source File: SpringRestDataConfig.java    From microservice-istio with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	config.exposeIdsFor(Order.class, Item.class, Customer.class);
	config.setDefaultMediaType(MediaType.APPLICATION_JSON);
}