VerreTraitIntegresAssoIteLoadStepConfig.java

package com.sintia.ffl.admin.optique.services.batch.refpromoteur.load.ite;

import com.sintia.ffl.admin.optique.dal.entities.VerreTraitIntegresAssoIte;
import com.sintia.ffl.admin.optique.dal.entities.staging.VerreTraitIntegresAssoIteStaging;
import com.sintia.ffl.admin.optique.dal.repositories.VerreTraitIntegresAssoIteRepository;
import com.sintia.ffl.admin.optique.dal.repositories.staging.VerreTraitIntegresAssoIteStagingRepository;
import com.sintia.ffl.admin.optique.services.batch.refpromoteur.load.ite.staging.VerreTraitIntegresAssoIteStagingStateConverter;
import com.sintia.ffl.admin.staging.FileUtils;
import com.sintia.ffl.admin.staging.GenerericItemReadFromFile;
import com.sintia.ffl.admin.staging.StagingStepListener;
import com.sintia.ffl.admin.staging.step.imports.AbstractSinglePromoteurDBStateLoadStepConfig;
import com.sintia.ffl.adminui.commons.enums.TypeStaging;
import com.sintia.ffl.core.commons.enums.CodePromoteur;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;

import java.io.IOException;

@Slf4j
@Configuration
public class VerreTraitIntegresAssoIteLoadStepConfig extends AbstractSinglePromoteurDBStateLoadStepConfig<
        VerreTraitIntegresAssoIte, Integer, VerreTraitIntegresAssoIteRepository,
        VerreTraitIntegresAssoIteStaging, Integer, VerreTraitIntegresAssoIteStagingRepository
        > {
    
    public VerreTraitIntegresAssoIteLoadStepConfig(
            VerreTraitIntegresAssoIteStagingRepository verreTraitIntegresAssoIteStagingRepository,
            VerreTraitIntegresAssoIteStagingStateConverter verreTraitIntegresAssoIteStagingStateConverter
        ){
        super(
                VerreTraitIntegresAssoIte.class,
                TypeStaging.REF_PROMOTEUR,
                CodePromoteur.ITE,
                verreTraitIntegresAssoIteStagingRepository,
                verreTraitIntegresAssoIteStagingStateConverter
        );
    }
    
    @Bean
    @JobScope
    public Step verreTraitIntegresAssoIteLoadStep(StepBuilderFactory stepBuilderFactory,
            VerreTraitIntegresAssoIteRepository verreTraitIntegresAssoIteRepository, FileUtils fileUtils,
            StagingStepListener<VerreTraitIntegresAssoIte, Integer> stepListener, AsyncTaskExecutor asyncExecutor) throws IOException {
        return super.buildStep(stepBuilderFactory, verreTraitIntegresAssoIteRepository, fileUtils, stepListener, asyncExecutor);
    }
    
    @Bean("verreTraitIntegresAssoIteItemReader")
    @StepScope
    @Override
    public GenerericItemReadFromFile<VerreTraitIntegresAssoIte> reader(
            FileUtils fileUtils,
            @Value("#{jobParameters['envSource'] ?: 'pprod'}") String envSource,
            @Value("#{jobParameters['envCible'] ?: 'pprod'}") String envCible,
            @Value("#{jobParameters['codePromoteur']}") String codePromoteur
    ) throws IOException {
        return super.buildReader(fileUtils, envSource, envCible, codePromoteur);
    }
    
}