TraitementSpecifiqueStepConfig.java

package com.sintia.ffl.admin.optique.services.batch.refcommun.export;

import com.sintia.ffl.admin.optique.dal.entities.TraitementSpecifique;
import com.sintia.ffl.admin.optique.dal.repositories.TraitementSpecifiqueRepository;
import com.sintia.ffl.admin.staging.FileUtils;
import com.sintia.ffl.admin.staging.step.export.AbstractCommunExportStepConfig;
import com.sintia.ffl.adminui.commons.enums.TypeStaging;
import org.springframework.batch.core.Step;

import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.integration.async.AsyncItemWriter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import com.sintia.ffl.admin.staging.StagingStepListener;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.transaction.PlatformTransactionManager;



@Configuration
public class TraitementSpecifiqueStepConfig extends AbstractCommunExportStepConfig<TraitementSpecifique, Integer, TraitementSpecifiqueRepository> {
    
    public TraitementSpecifiqueStepConfig(){
        super(
                TypeStaging.REF_COMMUN
        );
    }
    

    @Bean
    @JobScope
    public Step traitementSpecifiqueStep(JobRepository jobRepository, PlatformTransactionManager transactionManager, FileUtils fileUtils,
                                         TraitementSpecifiqueRepository repository, StagingStepListener<TraitementSpecifique, Integer> stepListener) throws IOException {
        return super.buildStep(jobRepository, transactionManager, fileUtils, repository /*, stepListener*/);
    }


    @Bean("traitementSpecifiqueWriter")
    @StepScope
    @Override
    public AsyncItemWriter<TraitementSpecifique> writer(
            FileUtils fileUtils,
            @Value("#{jobParameters['envSource'] ?: 'pprod'}") String envSource,
            @Value("#{jobParameters['envCible'] ?: 'pprod'}") String envCible
    ) throws IOException {
        return super.buildWriter(fileUtils, envSource, envCible);
    }
    
}