FabricantPromoteurStepConfig.java
package com.sintia.ffl.admin.optique.services.batch.refpromoteur.export.promoteur;
import com.sintia.ffl.admin.optique.dal.entities.FabricantPromoteur;
import com.sintia.ffl.admin.optique.dal.repositories.FabricantPromoteurRepository;
import com.sintia.ffl.admin.staging.FileUtils;
import com.sintia.ffl.admin.staging.step.export.AbstractPromoteurExportStepConfig;
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.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 FabricantPromoteurStepConfig extends
AbstractPromoteurExportStepConfig<FabricantPromoteur, Integer, FabricantPromoteurRepository> {
public FabricantPromoteurStepConfig(){
super(TypeStaging.REF_PROMOTEUR, "findByIdPromoteur");
}
@Bean
public Step fabricantPromoteurStep(StepBuilderFactory stepBuilderFactory, FileUtils fileUtils, FabricantPromoteurRepository fabricantPromoteurRepository) throws IOException {
return super.buildStep(stepBuilderFactory, fabricantPromoteurRepository, fileUtils);
}
@Bean("fabricantPromoteurReader")
@StepScope
@Override
public AbstractItemStreamItemReader<FabricantPromoteur> reader(
FabricantPromoteurRepository repository,
@Value("#{jobParameters['idPromoteur']}") Integer idPromoteur,
@Value("#{jobParameters['codePromoteur']}") String codePromoteur
) throws IOException {
return super.buildReader(repository, idPromoteur, codePromoteur);
}
@Bean("fabricantPromoteurWriter")
@StepScope
@Override
public AsyncItemWriter<FabricantPromoteur> 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);
}
}