Class BaseReverseCronologicalBatchPidReader

java.lang.Object
ca.uhn.fhir.jpa.batch.reader.BaseReverseCronologicalBatchPidReader
All Implemented Interfaces:
org.springframework.batch.item.ItemReader<List<Long>>, org.springframework.batch.item.ItemStream
Direct Known Subclasses:
ReverseCronologicalBatchMdmLinkPidReader, ReverseCronologicalBatchResourcePidReader

public abstract class BaseReverseCronologicalBatchPidReader extends Object implements org.springframework.batch.item.ItemReader<List<Long>>, org.springframework.batch.item.ItemStream
This Spring Batch reader takes 4 parameters: BatchConstants.JOB_PARAM_REQUEST_LIST: A list of URLs to search for along with the partitions those searches should be performed on BatchConstants.JOB_PARAM_BATCH_SIZE: The number of resources to return with each search. If ommitted, DaoConfig.getExpungeBatchSize() will be used. BatchConstants.JOB_PARAM_START_TIME: The latest timestamp of entities to search for

The reader will return at most BatchConstants.JOB_PARAM_BATCH_SIZE pids every time it is called, or null once no more matching entities are available. It returns the resources in reverse chronological order and stores where it's at in the Spring Batch execution context with the key BatchConstants.CURRENT_THRESHOLD_HIGH appended with "." and the index number of the url list item it has gotten up to. This is to permit restarting jobs that use this reader so it can pick up where it left off.

  • Constructor Details

  • Method Details

    • buildJobParameters

      @Nonnull public static org.springframework.batch.core.JobParameters buildJobParameters(String theOperationName, Integer theBatchSize, RequestListJson theRequestListJson)
    • setRequestListJson

      @Autowired public void setRequestListJson(@Value("#{jobParameters[\'url-list\']}") String theRequestListJson)
    • setStartTime

      @Autowired public void setStartTime(@Value("#{jobParameters[\'start-time\']}") Date theStartTime)
    • read

      public List<Long> read() throws Exception
      Specified by:
      read in interface org.springframework.batch.item.ItemReader<List<Long>>
      Throws:
      Exception
    • getNextBatch

      protected List<Long> getNextBatch()
    • getCurrentHighThreshold

    • setDateExtractorFunction

      protected void setDateExtractorFunction(Function<Long,Date> theDateExtractorFunction)
    • addDateCountAndSortToSearch

      protected void addDateCountAndSortToSearch(ResourceSearch resourceSearch)
    • open

      public void open(org.springframework.batch.item.ExecutionContext executionContext) throws org.springframework.batch.item.ItemStreamException
      Specified by:
      open in interface org.springframework.batch.item.ItemStream
      Throws:
      org.springframework.batch.item.ItemStreamException
    • update

      public void update(org.springframework.batch.item.ExecutionContext executionContext) throws org.springframework.batch.item.ItemStreamException
      Specified by:
      update in interface org.springframework.batch.item.ItemStream
      Throws:
      org.springframework.batch.item.ItemStreamException
    • close

      public void close() throws org.springframework.batch.item.ItemStreamException
      Specified by:
      close in interface org.springframework.batch.item.ItemStream
      Throws:
      org.springframework.batch.item.ItemStreamException
    • getBatchSize

      protected Integer getBatchSize()
    • setBatchSize

      @Autowired public void setBatchSize(@Value("#{jobParameters[\'batch-size\']}") Integer theBatchSize)
    • getAlreadySeenPids

      protected Set<Long> getAlreadySeenPids()
    • getNextPidBatch

      protected abstract Set<Long> getNextPidBatch(ResourceSearch resourceSearch)
    • setDateFromPidFunction

      protected abstract void setDateFromPidFunction(ResourceSearch resourceSearch)