MateriauProtheseAssoStepConfig.java
package com.sintia.ffl.admin.dentaire.services.batch.refpromoteur.export;
import com.sintia.ffl.admin.dentaire.dal.entities.MateriauProtheseAsso;
import com.sintia.ffl.admin.dentaire.dal.repositories.MateriauProtheseAssoRepository;
import com.sintia.ffl.admin.staging.FileUtils;
import com.sintia.ffl.admin.staging.GenerericItemReadFromDB;
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.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 MateriauProtheseAssoStepConfig extends
AbstractPromoteurExportStepConfig<MateriauProtheseAsso, Integer, MateriauProtheseAssoRepository> {
public MateriauProtheseAssoStepConfig(){
super(TypeStaging.REF_PROMOTEUR, "findByPromoteurId");
}
@Bean
public Step materiauProtheseAssoStep(StepBuilderFactory stepBuilderFactory, FileUtils fileUtils, MateriauProtheseAssoRepository materiauProtheseAssoRepository) throws IOException {
return super.buildStep(stepBuilderFactory, materiauProtheseAssoRepository, fileUtils);
}
@Bean("materiauProtheseAssoReader")
@StepScope
@Override
public AbstractItemStreamItemReader<MateriauProtheseAsso> reader(
MateriauProtheseAssoRepository repository,
@Value("#{jobParameters['idPromoteur']}") Integer idPromoteur,
@Value("#{jobParameters['codePromoteur']}") String codePromoteur
) throws IOException {
return super.buildReader(repository, idPromoteur, codePromoteur);
}
@Bean("materiauProtheseAssoWriter")
@StepScope
@Override
public AsyncItemWriter<MateriauProtheseAsso> 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);
}
}