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 Type
    Method
    Description
    boolean
    archiveBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Archives a batch, if it is still completed.
    void
    archiveFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Archives a file and removes its validation report.
    boolean
    batchHasErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Tells whether a row of the batch is in error.
    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 from strFromStatus to PROCESSING with the given token, unless another process took it first.
    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.
    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.
    int
    countAppointmentsByBatch(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.
    void
    deleteAppointmentsByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Deletes the rows of a batch.
    void
    deleteFingerprintByAppointment(int nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Deletes the fingerprint of a row.
    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.
    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.
    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.
    boolean
    fileAllBatchesArchived(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Tells whether every batch of the file is archived.
    boolean
    fileHasErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Tells whether a row of the file is in error.
    void
    insertAppointments(List<AppointmentImportAppointment> listAppointments, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Inserts the rows of an import.
    int
    insertBatch(AppointmentImportBatch batch, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Inserts a new batch.
    int
    insertFile(AppointmentImportFile file, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Inserts a new import file record.
    void
    insertFingerprints(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.
    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.
    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.
    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.
    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.
    void
    requeueRow(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.
    void
    touchBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Records that a batch is still being processed.
    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.
    void
    updateAppointmentData(int nId, String strGenericAttributesData, String strFormFieldsData, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Replaces the values of a row.
    void
    updateBatchStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Updates the status of a batch and releases its token.
    void
    updateFileStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Updates the status of a file.
  • Method Details

    • insertFile

      int insertFile(AppointmentImportFile file, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Inserts a new import file record.
      Parameters:
      file - the file to persist
      plugin - the plugin
      Returns:
      the generated id_import_file
    • loadFile

      AppointmentImportFile loadFile(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Loads an import file.
      Parameters:
      nId - the id_import_file
      plugin - 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 to
      strFormId - optional form id
      strFileName - optional exact file name
      strStatus - optional exact status
      strDate - optional date (yyyy-MM-dd) of a slot of the file
      plugin - 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 ids
      plugin - 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 forms
      plugin - 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 content
      nFormId - the form
      plugin - 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 - the id_import_file
      strStatus - the new status
      plugin - the plugin
    • selectFileIdsToClose

      List<Integer> selectFileIdsToClose(fr.paris.lutece.portal.service.plugin.Plugin plugin)
      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 files
      plugin - 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 - the id_import_file
      plugin - 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 - the id_import_file
      plugin - 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 - the id_import_file
      plugin - 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 threshold
      plugin - the plugin
      Returns:
      the ids of the files to archive
    • insertBatch

      int insertBatch(AppointmentImportBatch batch, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Inserts a new batch.
      Parameters:
      batch - the batch
      plugin - the plugin
      Returns:
      the generated id_import_batch
    • loadBatch

      AppointmentImportBatch loadBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Loads a batch.
      Parameters:
      nId - the id_import_batch
      plugin - 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 - the id_import_file
      plugin - 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 status
      plugin - 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 to
      strFormId - optional form id
      strStatus - optional status
      strFileName - optional file name
      strDate - 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 ids
      plugin - 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 from strFromStatus to PROCESSING with the given token, unless another process took it first.
      Parameters:
      nId - the id_import_batch
      strFromStatus - the status the batch must still have
      dtLastExecBefore - if not null, the batch must not have been touched since this date
      strToken - the token identifying the caller
      plugin - 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 - the id_import_batch
      plugin - 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 - the id_import_batch
      strStatus - the new status
      plugin - 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 - the id_import_batch
      plugin - 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 batches
      plugin - 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 - the id_import_batch
      plugin - 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 threshold
      plugin - 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 - the id_import_batch
      plugin - 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 rows
      plugin - 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 - the id_import_batch
      strStatus - optional status
      plugin - 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 - the id_import_batch
      bProcessedOnly - true to count only the rows created or in error
      plugin - 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 - the id_import_appointment
      strStatus - the new status
      strCode - the error code, or null
      strMessage - the error message, or null
      nAppointmentId - the created appointment, or null
      plugin - the plugin
    • loadAppointment

      AppointmentImportAppointment loadAppointment(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Loads a row.
      Parameters:
      nId - the id_import_appointment
      plugin - 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 - the id_import_appointment
      strGenericAttributesData - the values of the standard columns, as JSON
      strFormFieldsData - the values of the form fields, as JSON
      plugin - 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 - the id_import_batch
      strExcludedErrorCode - the error code of the rows to leave in error
      plugin - 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 - the id_import_appointment
      plugin - the plugin
    • deleteAppointmentsByBatch

      void deleteAppointmentsByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Deletes the rows of a batch.
      Parameters:
      nBatchId - the id_import_batch
      plugin - 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 - the id_import_file
      plugin - the plugin
      Returns:
      the id_import_appointment of 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 - the id_import_appointment
      strExcludedErrorCode - the error code of the rows that cannot be replaced
      strMessage - what replaced the row
      plugin - 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 - the id_import_batch
      plugin - 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 - the id_import_file
      plugin - 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 form
      collectionFingerprints - the fingerprints
      plugin - 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 fingerprints
      plugin - 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 row
      nFromAppointmentId - the id_import_appointment of the row it belongs to
      plugin - 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 - the id_import_appointment
      plugin - 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 - the id_import_batch
      plugin - 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 kept
      plugin - the plugin