Class DataAccess
- java.lang.Object
-
- org.linuxforhealth.fhir.bucket.scanner.DataAccess
-
public class DataAccess extends java.lang.Object
The data access layer encapsulating interactions with the FHIR bucket schema
-
-
Constructor Summary
Constructors Constructor Description DataAccess(IDatabaseAdapter dbAdapter, ITransactionProvider txProvider, java.lang.String schemaName)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allocateJobs(java.util.List<BucketLoaderJob> jobList, FileType fileType, int free, int recycleSeconds, java.util.Collection<BucketPath> bucketPaths)
Allocate up to free jobs to this loader instancejava.lang.Integer
getLastProcessedLineNumber(long resourceBundleId, int version)
Get the last processed line number for the given resource bundle identified by its id.java.util.List<ResourceRef>
getResourceRefsForLine(long resourceBundleId, int version, int lineNumber)
Get the list of resourceType/logicalId resource references generated when processing the given lineNumber of the identified resource bundle and its versionvoid
heartbeat()
Update the heartbeat tstamp of the record representing this loader instance to tell everyone that we're still alive.void
init()
Initialize the objectvoid
markJobDone(BucketLoaderJob job)
void
recordErrors(long resourceBundleLoadId, int lineNumber, java.util.List<ResourceBundleError> errors)
Save the errors generated when loading the given resource bundle.void
recordLogicalId(java.lang.String resourceType, java.lang.String logicalId, long resourceBundleLoadId, int lineNumber, java.lang.Integer responseTimeMs)
Save the logical idvoid
recordLogicalIds(long resourceBundleLoadId, int lineNumber, java.util.List<ResourceIdValue> idValues, int batchSize)
Load the list of resourceType/logicalId DTO objects as a batch in one transactionvoid
registerBucketItem(CosItem item)
Create a record in the database to track this item if it doesn't currently existvoid
selectRandomPatientIds(java.util.List<java.lang.String> patientIds, int maxPatients)
-
-
-
Constructor Detail
-
DataAccess
public DataAccess(IDatabaseAdapter dbAdapter, ITransactionProvider txProvider, java.lang.String schemaName)
Public constructor- Parameters:
connectionPool
-txProvider
-schemaName
-
-
-
Method Detail
-
init
public void init()
Initialize the object
-
registerBucketItem
public void registerBucketItem(CosItem item)
Create a record in the database to track this item if it doesn't currently exist- Parameters:
item
-
-
allocateJobs
public void allocateJobs(java.util.List<BucketLoaderJob> jobList, FileType fileType, int free, int recycleSeconds, java.util.Collection<BucketPath> bucketPaths)
Allocate up to free jobs to this loader instance- Parameters:
jobList
-free
-
-
recordLogicalId
public void recordLogicalId(java.lang.String resourceType, java.lang.String logicalId, long resourceBundleLoadId, int lineNumber, java.lang.Integer responseTimeMs)
Save the logical id- Parameters:
simpleName
-logicalId
-
-
heartbeat
public void heartbeat()
Update the heartbeat tstamp of the record representing this loader instance to tell everyone that we're still alive.
-
markJobDone
public void markJobDone(BucketLoaderJob job)
- Parameters:
job
-
-
recordLogicalIds
public void recordLogicalIds(long resourceBundleLoadId, int lineNumber, java.util.List<ResourceIdValue> idValues, int batchSize)
Load the list of resourceType/logicalId DTO objects as a batch in one transaction- Parameters:
resourceBundleId
-lineNumber
-idValues
-
-
recordErrors
public void recordErrors(long resourceBundleLoadId, int lineNumber, java.util.List<ResourceBundleError> errors)
Save the errors generated when loading the given resource bundle. Because a given bundle may be loaded multiple times with different outcomes, the error records are each associated with the current loaderInstanceId. This can occur when a loader dies before the bundle completes.- Parameters:
resourceBundleId
-lineNumber
-errors
-batchSize
-
-
getLastProcessedLineNumber
public java.lang.Integer getLastProcessedLineNumber(long resourceBundleId, int version)
Get the last processed line number for the given resource bundle identified by its id. This is calculated by looking for the max line_number value recorded for the bundle in the logical_resources table.- Parameters:
resourceBundleId
-version
-
-
getResourceRefsForLine
public java.util.List<ResourceRef> getResourceRefsForLine(long resourceBundleId, int version, int lineNumber)
Get the list of resourceType/logicalId resource references generated when processing the given lineNumber of the identified resource bundle and its version- Parameters:
resourceBundleId
-version
-lineNumber
-- Returns:
-
selectRandomPatientIds
public void selectRandomPatientIds(java.util.List<java.lang.String> patientIds, int maxPatients)
- Parameters:
patientIds
-patientsPerBatch
-
-
-