MontureControleRemisePromoteurAssoStepConfig.java

package com.sintia.ffl.admin.optique.services.batch.refpromoteur.export.promoteur;

import com.sintia.ffl.admin.optique.dal.entities.MontureControleRemisePromoteurAsso;
import com.sintia.ffl.admin.optique.dal.repositories.MontureControleRemisePromoteurAssoRepository;
import com.sintia.ffl.admin.staging.FileUtils;
import com.sintia.ffl.admin.staging.service.PromoteurStagingService;
import com.sintia.ffl.admin.staging.step.export.AbstractPromoteurByCodePromoteurExportStepConfig;
import com.sintia.ffl.adminui.commons.enums.TypeStaging;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.integration.async.AsyncItemWriter;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.support.AbstractItemStreamItemReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MontureControleRemisePromoteurAssoStepConfig extends
        AbstractPromoteurByCodePromoteurExportStepConfig<MontureControleRemisePromoteurAsso, Integer, MontureControleRemisePromoteurAssoRepository> {
    
    public MontureControleRemisePromoteurAssoStepConfig(){
        super(TypeStaging.REF_PROMOTEUR, "findByCodePromoteur");
    }
    
    @Bean
    public Step montureControleRemisePromoteurAssoStep(StepBuilderFactory stepBuilderFactory, FileUtils fileUtils, MontureControleRemisePromoteurAssoRepository repository
    ) throws IOException {
        return super.buildStep(stepBuilderFactory, repository, fileUtils);
    }
    
    @Bean("montureControleRemisePromoteurAssoReader")
    @StepScope
    @Override
    public AbstractItemStreamItemReader<MontureControleRemisePromoteurAsso> reader(
            MontureControleRemisePromoteurAssoRepository repository,
            @Value("#{jobParameters['idPromoteur']}") Integer idPromoteur,
            @Value("#{jobParameters['codePromoteur']}") String codePromoteur
    ) throws IOException {
        return super.buildReader(repository, codePromoteur);
    }
    
    @Bean("montureControleRemisePromoteurAssoWriter")
    @StepScope
    @Override
    public AsyncItemWriter<MontureControleRemisePromoteurAsso> writer(
            FileUtils fileUtils,
            @Value("#{jobParameters['envSource'] ?: 'pprod'}") String envSource,
            @Value("#{jobParameters['envCible'] ?: 'pprod'}") String envCible,
            @Value("#{jobParameters['codePromoteur']}") String codePromoteur
    ) throws IOException {
        return super.buildWriter(fileUtils, envSource, envCible, codePromoteur);
    }
}