package uk.ac.ebi.quickgo.client.service.loader.presets;

import uk.ac.ebi.quickgo.client.model.presets.impl.CompositePresetImpl;

import java.util.HashMap;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

/**
 * Provides common Spring Batch job configuration details and methods used when populating preset information.
 *
 * Created 01/09/16
 * @author Edd
 */
@Configuration
@EnableBatchProcessing
@ComponentScan({"uk.ac.ebi.quickgo.rest"})
public class PresetsCommonConfig {
    @Autowired
    private JobBuilderFactory jobBuilders;
    @Autowired
    private StepBuilderFactory stepBuilders;

    @Value("${preset.chunk.size:500}")
    private int chunkSize;

    @Bean
    public Integer chunkSize() {
        return chunkSize;
    }

    @Bean DbDescriptions dbDescriptions() {
        return new DbDescriptions();
    }

    @Bean
    public CompositePresetImpl presets() {
        return new CompositePresetImpl();
    }

    @Bean
    static PropertySourcesPlaceholderConfigurer propertyPlaceHolderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }

    public static class DbDescriptions {
        public final HashMap<String, String> dbDescriptions = new HashMap<>();

    }
}

@@ -122,16 +122,174 @@
 setImpl;
+%0Aimport uk.ac.ebi.quickgo.rest.search.request.config.FilterConfigRetrieval;%0Aimport uk.ac.ebi.quickgo.rest.search.request.converter.RESTFilterConverterFactory;
 %0A%0Aimport
@@ -935,16 +935,70 @@
 figurer;
+%0Aimport org.springframework.web.client.RestOperations;
 %0A%0A/**%0A *
@@ -2000,11 +2000,431 @@
 ;%0A%0A    %7D
+%0A%0A    @Bean%0A    public RestValuesRetriever restValuesRetriever(FilterConfigRetrieval externalFilterConfigRetrieval,%0A                                                   RestOperations restOperations) %7B%0A        RESTFilterConverterFactory restConverterFactory =%0A                new RESTFilterConverterFactory(externalFilterConfigRetrieval, restOperations);%0A        return new RestValuesRetriever(restConverterFactory);%0A    %7D
 %0A%7D%0A

Add Spring bean for a RestValuesRetriever instance.