PromoteurLoadStepConfig.java

  1. package com.sintia.ffl.admin.dentaire.services.batch.parampromoteur.load;

  2. import com.sintia.ffl.admin.dentaire.dal.entities.Promoteur;
  3. import com.sintia.ffl.admin.dentaire.dal.repositories.PromoteurRepository;
  4. import com.sintia.ffl.admin.staging.FileUtils;
  5. import com.sintia.ffl.admin.staging.GenerericItemReadFromFile;
  6. import com.sintia.ffl.admin.staging.StagingStepListener;
  7. import com.sintia.ffl.admin.staging.step.imports.AbstractPromoteurImportStepConfig;
  8. import com.sintia.ffl.adminui.commons.enums.TypeStaging;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.batch.core.Step;
  11. import org.springframework.batch.core.configuration.annotation.JobScope;
  12. import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
  13. import org.springframework.batch.core.configuration.annotation.StepScope;
  14. import org.springframework.beans.factory.annotation.Value;
  15. import org.springframework.context.annotation.Bean;
  16. import org.springframework.context.annotation.Configuration;

  17. import java.io.IOException;

  18. @Slf4j
  19. @Configuration
  20. public class PromoteurLoadStepConfig extends AbstractPromoteurImportStepConfig<Promoteur, Integer, PromoteurRepository> {
  21.    
  22.     public PromoteurLoadStepConfig(){
  23.         super(
  24.                 Promoteur.class,
  25.                 TypeStaging.PARAM_PROMOTEUR
  26.         );
  27.     }
  28.    
  29.     @Bean
  30.     @JobScope
  31.     public Step promoteurLoadStep(StepBuilderFactory stepBuilderFactory,
  32.             PromoteurRepository promoteurRepository, FileUtils fileUtils,
  33.             StagingStepListener<Promoteur, Integer> stepListener) throws IOException {
  34.         return super.buildStep(stepBuilderFactory, promoteurRepository, fileUtils, stepListener);
  35.     }
  36.    
  37.     @Bean("promoteurItemReader")
  38.     @StepScope
  39.     @Override
  40.     public GenerericItemReadFromFile<Promoteur> reader(
  41.             FileUtils fileUtils,
  42.             @Value("#{jobParameters['envSource'] ?: 'pprod'}") String envSource,
  43.             @Value("#{jobParameters['envCible'] ?: 'pprod'}") String envCible,
  44.             @Value("#{jobParameters['codePromoteur']}") String codePromoteur
  45.     ) throws IOException {
  46.         return super.buildReader(fileUtils, envSource, envCible, codePromoteur);
  47.     }
  48.    
  49. }