VerreSupplementAssoLoadStepConfig.java
package com.sintia.ffl.admin.optique.services.batch.refcatalogue.load;
import com.sintia.ffl.admin.optique.dal.entities.VerreSupplementAsso;
import com.sintia.ffl.admin.optique.dal.entities.staging.VerreSupplementAssoStaging;
import com.sintia.ffl.admin.optique.dal.repositories.VerreSupplementAssoRepository;
import com.sintia.ffl.admin.optique.dal.repositories.staging.VerreSupplementAssoStagingRepository;
import com.sintia.ffl.admin.optique.services.batch.refcatalogue.load.converters.VerreSupplementAssoStagingStateConverter;
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.AbstractCommunDBStateImportStepConfig;
import com.sintia.ffl.adminui.commons.enums.TypeStaging;
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 VerreSupplementAssoLoadStepConfig extends AbstractCommunDBStateImportStepConfig<
VerreSupplementAsso, Integer, VerreSupplementAssoRepository,
VerreSupplementAssoStaging, Integer, VerreSupplementAssoStagingRepository
> {
public VerreSupplementAssoLoadStepConfig(VerreSupplementAssoStagingRepository verreSupplementAssoStagingRepository, VerreSupplementAssoStagingStateConverter verreSupplementAssoStagingStateConverter) {
super(
VerreSupplementAsso.class,
TypeStaging.REF_CATALOGUE,
verreSupplementAssoStagingRepository,
verreSupplementAssoStagingStateConverter
);
}
@Bean
@JobScope
public Step verreSupplementAssoLoadStep(StepBuilderFactory stepBuilderFactory, FileUtils fileUtils,
VerreSupplementAssoRepository verreSupplementAssoRepository,
StagingStepListener<VerreSupplementAsso, Integer> stepListener, AsyncTaskExecutor asyncExecutor) throws IOException {
return super.buildStep(stepBuilderFactory, verreSupplementAssoRepository, fileUtils, stepListener, asyncExecutor);
}
@Bean("verreSupplementAssoItemReader")
@StepScope
@Override
public GenerericItemReadFromFile<VerreSupplementAsso> reader(
FileUtils fileUtils,
@Value("#{jobParameters['envSource'] ?: 'pprod'}") String envSource,
@Value("#{jobParameters['envCible'] ?: 'pprod'}") String envCible
) throws IOException {
return super.buildReader(fileUtils, envSource, envCible);
}
}