Interface IAppointmentImportDAO
- All Known Implementing Classes:
AppointmentImportDAO
public interface IAppointmentImportDAO
Data access for uploaded import files, slot batches and source rows.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanarchiveBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Archives a batch, if it is still completed.voidarchiveFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Archives a file and removes its validation report.booleanbatchHasErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a row of the batch is in error.booleanclaimBatch(int nId, String strFromStatus, LocalDateTime dtLastExecBefore, String strToken, fr.paris.lutece.portal.service.plugin.Plugin plugin) Takes a batch for processing: moves it fromstrFromStatustoPROCESSINGwith the given token, unless another process took it first.voidcompleteBatchWithoutErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Completes a batch completed with errors that has no row in error any more.voidcompleteFileWithoutErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Completes a file completed with errors that has no row in error any more.intcountAppointmentsByBatch(int nBatchId, boolean bProcessedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of a batch.countAppointmentsByBatches(List<Integer> listBatchIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of the given batches by outcome.countAppointmentsByFiles(List<Integer> listFileIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of the given files by outcome.voiddeleteAppointmentsByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the rows of a batch.voiddeleteFingerprintByAppointment(int nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprint of a row.voiddeleteFingerprintsBefore(LocalDate dateBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprints of the appointments before a date: a line in the past is refused anyway.voiddeleteFingerprintsNotCreatedByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprints of the rows of a batch that did not create their appointment, so that their lines can be imported again.booleanexistsDuplicateFile(String strHash, int nFormId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a file with the same content was already accepted for the form.booleanfileAllBatchesArchived(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether every batch of the file is archived.booleanfileHasErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a row of the file is in error.voidinsertAppointments(List<AppointmentImportAppointment> listAppointments, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts the rows of an import.intinsertBatch(AppointmentImportBatch batch, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts a new batch.intinsertFile(AppointmentImportFile file, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts a new import file record.voidinsertFingerprints(List<AppointmentImportFingerprint> listFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts fingerprints.loadAppointment(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads a row.loadBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads a batch.loadFile(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads an import file.booleanreassignFingerprint(AppointmentImportFingerprint fingerprint, int nFromAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Gives a fingerprint to a new row, if it still belongs to the given row.booleanreplaceAppointment(int nId, String strExcludedErrorCode, String strMessage, fr.paris.lutece.portal.service.plugin.Plugin plugin) Marks a row in error as replaced by a row of another file, unless it was interrupted while its appointment was being saved.booleanrequeueBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts a completed or pending batch back in the queue of the daemon; a batch being processed or archived is left as it is.voidrequeueErrorRows(int nBatchId, String strExcludedErrorCode, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts the rows in error of a batch back to pending, except those with the given error code.voidrequeueRow(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts a row in error back to pending.selectAppointmentIdsByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Gives the ids of the rows of a file, by line.selectAppointmentsByBatch(int nBatchId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the rows of a batch, by source line.selectBatchesByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the batches of a file, by starting date.selectBatchesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads the batches with the given ids, in the order of the list.selectBatchesByStatus(String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the batches with the given status, oldest first.selectBatchIds(List<Integer> listFormIds, String strFormId, String strStatus, String strFileName, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the ids of the batches matching the filters, newest first.selectBatchIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the completed batches last updated before the given date.selectFileIds(List<Integer> listFormIds, String strFormId, String strFileName, String strStatus, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the ids of the files matching the filters, newest first.selectFileIdsToClose(fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the files still pending whose batches are all done.selectFileNames(List<Integer> listFormIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the distinct names of the files imported on the given forms.selectFilesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads the files with the given ids, in the order of the list.selectFingerprints(int nFormId, Collection<String> collectionFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin) Finds the lines already imported on a form among the given fingerprints, with the file and the row that imported them.selectRejectedFileIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the files rejected at validation before the given date.voidtouchBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Records that a batch is still being processed.voidupdateAppointment(int nId, String strStatus, String strCode, String strMessage, Integer nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the state of a row.voidupdateAppointmentData(int nId, String strGenericAttributesData, String strFormFieldsData, fr.paris.lutece.portal.service.plugin.Plugin plugin) Replaces the values of a row.voidupdateBatchStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the status of a batch and releases its token.voidupdateFileStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the status of a file.
-
Method Details
-
insertFile
Inserts a new import file record.- Parameters:
file- the file to persistplugin- the plugin- Returns:
- the generated
id_import_file
-
loadFile
Loads an import file.- Parameters:
nId- theid_import_fileplugin- the plugin- Returns:
- the file, or null if not found
-
selectFileIds
List<Integer> selectFileIds(List<Integer> listFormIds, String strFormId, String strFileName, String strStatus, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the ids of the files matching the filters, newest first.- Parameters:
listFormIds- the forms the files must belong tostrFormId- optional form idstrFileName- optional exact file namestrStatus- optional exact statusstrDate- optional date (yyyy-MM-dd) of a slot of the fileplugin- the plugin- Returns:
- the matching ids
-
selectFilesByIds
List<AppointmentImportFile> selectFilesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads the files with the given ids, in the order of the list.- Parameters:
listIds- the idsplugin- the plugin- Returns:
- the files
-
selectFileNames
List<String> selectFileNames(List<Integer> listFormIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the distinct names of the files imported on the given forms.- Parameters:
listFormIds- the formsplugin- the plugin- Returns:
- the file names, sorted
-
existsDuplicateFile
boolean existsDuplicateFile(String strHash, int nFormId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a file with the same content was already accepted for the form.- Parameters:
strHash- the SHA-256 of the contentnFormId- the formplugin- the plugin- Returns:
- true if a duplicate exists
-
updateFileStatus
void updateFileStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the status of a file.- Parameters:
nId- theid_import_filestrStatus- the new statusplugin- the plugin
-
selectFileIdsToClose
Selects the files still pending whose batches are all done.- Parameters:
plugin- the plugin- Returns:
- the ids of the files whose status must be computed
-
countAppointmentsByFiles
Map<Integer,ImportCounts> countAppointmentsByFiles(List<Integer> listFileIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of the given files by outcome.- Parameters:
listFileIds- the filesplugin- the plugin- Returns:
- the counts of each file that has rows
-
fileHasErrors
boolean fileHasErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a row of the file is in error.- Parameters:
nFileId- theid_import_fileplugin- the plugin- Returns:
- true if at least one row failed
-
fileAllBatchesArchived
boolean fileAllBatchesArchived(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether every batch of the file is archived.- Parameters:
nFileId- theid_import_fileplugin- the plugin- Returns:
- true if no batch is left to archive
-
archiveFile
void archiveFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Archives a file and removes its validation report.- Parameters:
nFileId- theid_import_fileplugin- the plugin
-
selectRejectedFileIdsToPurge
List<Integer> selectRejectedFileIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the files rejected at validation before the given date.- Parameters:
dtBefore- the thresholdplugin- the plugin- Returns:
- the ids of the files to archive
-
insertBatch
Inserts a new batch.- Parameters:
batch- the batchplugin- the plugin- Returns:
- the generated
id_import_batch
-
loadBatch
Loads a batch.- Parameters:
nId- theid_import_batchplugin- the plugin- Returns:
- the batch, or null if not found
-
selectBatchesByFile
List<AppointmentImportBatch> selectBatchesByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the batches of a file, by starting date.- Parameters:
nFileId- theid_import_fileplugin- the plugin- Returns:
- the batches
-
selectBatchesByStatus
List<AppointmentImportBatch> selectBatchesByStatus(String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the batches with the given status, oldest first.- Parameters:
strStatus- the statusplugin- the plugin- Returns:
- the batches
-
selectBatchIds
List<Integer> selectBatchIds(List<Integer> listFormIds, String strFormId, String strStatus, String strFileName, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the ids of the batches matching the filters, newest first.- Parameters:
listFormIds- the forms the batches must belong tostrFormId- optional form idstrStatus- optional statusstrFileName- optional file namestrDate- optional starting date (yyyy-MM-dd)plugin- the plugin- Returns:
- the ids
-
selectBatchesByIds
List<AppointmentImportBatch> selectBatchesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads the batches with the given ids, in the order of the list.- Parameters:
listIds- the idsplugin- the plugin- Returns:
- the batches
-
claimBatch
boolean claimBatch(int nId, String strFromStatus, LocalDateTime dtLastExecBefore, String strToken, fr.paris.lutece.portal.service.plugin.Plugin plugin) Takes a batch for processing: moves it fromstrFromStatustoPROCESSINGwith the given token, unless another process took it first.- Parameters:
nId- theid_import_batchstrFromStatus- the status the batch must still havedtLastExecBefore- if not null, the batch must not have been touched since this datestrToken- the token identifying the callerplugin- the plugin- Returns:
- true if the caller now owns the batch
-
touchBatch
void touchBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Records that a batch is still being processed.- Parameters:
nId- theid_import_batchplugin- the plugin
-
updateBatchStatus
void updateBatchStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the status of a batch and releases its token.- Parameters:
nId- theid_import_batchstrStatus- the new statusplugin- the plugin
-
requeueBatch
boolean requeueBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts a completed or pending batch back in the queue of the daemon; a batch being processed or archived is left as it is.- Parameters:
nBatchId- theid_import_batchplugin- the plugin- Returns:
- true if the batch is now pending, false if it is being processed or archived
-
countAppointmentsByBatches
Map<Integer,ImportCounts> countAppointmentsByBatches(List<Integer> listBatchIds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of the given batches by outcome.- Parameters:
listBatchIds- the batchesplugin- the plugin- Returns:
- the counts of each batch that has rows
-
batchHasErrors
boolean batchHasErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Tells whether a row of the batch is in error.- Parameters:
nBatchId- theid_import_batchplugin- the plugin- Returns:
- true if at least one row failed
-
selectBatchIdsToPurge
List<Integer> selectBatchIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the completed batches last updated before the given date.- Parameters:
dtBefore- the thresholdplugin- the plugin- Returns:
- the ids
-
archiveBatch
boolean archiveBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Archives a batch, if it is still completed.- Parameters:
nBatchId- theid_import_batchplugin- the plugin- Returns:
- true if the batch is archived, false if it was retried meanwhile
-
insertAppointments
void insertAppointments(List<AppointmentImportAppointment> listAppointments, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts the rows of an import.- Parameters:
listAppointments- the rowsplugin- the plugin
-
selectAppointmentsByBatch
List<AppointmentImportAppointment> selectAppointmentsByBatch(int nBatchId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin) Selects the rows of a batch, by source line.- Parameters:
nBatchId- theid_import_batchstrStatus- optional statusplugin- the plugin- Returns:
- the rows
-
countAppointmentsByBatch
int countAppointmentsByBatch(int nBatchId, boolean bProcessedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin) Counts the rows of a batch.- Parameters:
nBatchId- theid_import_batchbProcessedOnly- true to count only the rows created or in errorplugin- the plugin- Returns:
- the count
-
updateAppointment
void updateAppointment(int nId, String strStatus, String strCode, String strMessage, Integer nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Updates the state of a row.- Parameters:
nId- theid_import_appointmentstrStatus- the new statusstrCode- the error code, or nullstrMessage- the error message, or nullnAppointmentId- the created appointment, or nullplugin- the plugin
-
loadAppointment
AppointmentImportAppointment loadAppointment(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Loads a row.- Parameters:
nId- theid_import_appointmentplugin- the plugin- Returns:
- the row, or null
-
updateAppointmentData
void updateAppointmentData(int nId, String strGenericAttributesData, String strFormFieldsData, fr.paris.lutece.portal.service.plugin.Plugin plugin) Replaces the values of a row.- Parameters:
nId- theid_import_appointmentstrGenericAttributesData- the values of the standard columns, as JSONstrFormFieldsData- the values of the form fields, as JSONplugin- the plugin
-
requeueErrorRows
void requeueErrorRows(int nBatchId, String strExcludedErrorCode, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts the rows in error of a batch back to pending, except those with the given error code.- Parameters:
nBatchId- theid_import_batchstrExcludedErrorCode- the error code of the rows to leave in errorplugin- the plugin
-
requeueRow
void requeueRow(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Puts a row in error back to pending.- Parameters:
nId- theid_import_appointmentplugin- the plugin
-
deleteAppointmentsByBatch
void deleteAppointmentsByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the rows of a batch.- Parameters:
nBatchId- theid_import_batchplugin- the plugin
-
selectAppointmentIdsByFile
Map<Integer,Integer> selectAppointmentIdsByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Gives the ids of the rows of a file, by line.- Parameters:
nFileId- theid_import_fileplugin- the plugin- Returns:
- the
id_import_appointmentof each line
-
replaceAppointment
boolean replaceAppointment(int nId, String strExcludedErrorCode, String strMessage, fr.paris.lutece.portal.service.plugin.Plugin plugin) Marks a row in error as replaced by a row of another file, unless it was interrupted while its appointment was being saved.- Parameters:
nId- theid_import_appointmentstrExcludedErrorCode- the error code of the rows that cannot be replacedstrMessage- what replaced the rowplugin- the plugin- Returns:
- true if the row is replaced
-
completeBatchWithoutErrors
void completeBatchWithoutErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Completes a batch completed with errors that has no row in error any more.- Parameters:
nBatchId- theid_import_batchplugin- the plugin
-
completeFileWithoutErrors
void completeFileWithoutErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Completes a file completed with errors that has no row in error any more.- Parameters:
nFileId- theid_import_fileplugin- the plugin
-
selectFingerprints
List<AppointmentImportFingerprint> selectFingerprints(int nFormId, Collection<String> collectionFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin) Finds the lines already imported on a form among the given fingerprints, with the file and the row that imported them.- Parameters:
nFormId- the formcollectionFingerprints- the fingerprintsplugin- the plugin- Returns:
- the fingerprints found
-
insertFingerprints
void insertFingerprints(List<AppointmentImportFingerprint> listFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin) Inserts fingerprints. One already there for its form fails: the line was imported meanwhile.- Parameters:
listFingerprints- the fingerprintsplugin- the plugin
-
reassignFingerprint
boolean reassignFingerprint(AppointmentImportFingerprint fingerprint, int nFromAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Gives a fingerprint to a new row, if it still belongs to the given row.- Parameters:
fingerprint- the fingerprint with its new rownFromAppointmentId- theid_import_appointmentof the row it belongs toplugin- the plugin- Returns:
- true if the fingerprint belongs to the new row
-
deleteFingerprintByAppointment
void deleteFingerprintByAppointment(int nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprint of a row.- Parameters:
nAppointmentId- theid_import_appointmentplugin- the plugin
-
deleteFingerprintsNotCreatedByBatch
void deleteFingerprintsNotCreatedByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprints of the rows of a batch that did not create their appointment, so that their lines can be imported again.- Parameters:
nBatchId- theid_import_batchplugin- the plugin
-
deleteFingerprintsBefore
void deleteFingerprintsBefore(LocalDate dateBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin) Deletes the fingerprints of the appointments before a date: a line in the past is refused anyway.- Parameters:
dateBefore- the first date keptplugin- the plugin
-