Package ca.uhn.fhir.jpa.batch.reader
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDateCountAndSortToSearch
(ResourceSearch resourceSearch) static org.springframework.batch.core.JobParameters
buildJobParameters
(String theOperationName, Integer theBatchSize, RequestListJson theRequestListJson) void
close()
protected Integer
protected Date
getNextPidBatch
(ResourceSearch resourceSearch) void
open
(org.springframework.batch.item.ExecutionContext executionContext) read()
void
setBatchSize
(Integer theBatchSize) protected void
setDateExtractorFunction
(Function<Long, Date> theDateExtractorFunction) protected abstract void
setDateFromPidFunction
(ResourceSearch resourceSearch) void
setRequestListJson
(String theRequestListJson) void
setStartTime
(Date theStartTime) void
update
(org.springframework.batch.item.ExecutionContext executionContext)
-
Constructor Details
-
BaseReverseCronologicalBatchPidReader
-
-
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
-
read
-
getNextBatch
-
getCurrentHighThreshold
-
setDateExtractorFunction
-
addDateCountAndSortToSearch
-
open
public void open(org.springframework.batch.item.ExecutionContext executionContext) throws org.springframework.batch.item.ItemStreamException - Specified by:
open
in interfaceorg.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 interfaceorg.springframework.batch.item.ItemStream
- Throws:
org.springframework.batch.item.ItemStreamException
-
close
- Specified by:
close
in interfaceorg.springframework.batch.item.ItemStream
- Throws:
org.springframework.batch.item.ItemStreamException
-
getBatchSize
-
setBatchSize
@Autowired public void setBatchSize(@Value("#{jobParameters[\'batch-size\']}") Integer theBatchSize) -
getAlreadySeenPids
-
getNextPidBatch
-
setDateFromPidFunction
-