java.lang.Object
fr.paris.lutece.plugins.appointment.modules.importer.business.AppointmentImportDAO
All Implemented Interfaces:
IAppointmentImportDAO

@ApplicationScoped public final class AppointmentImportDAO extends Object implements IAppointmentImportDAO
SQL implementation of IAppointmentImportDAO.
  • Constructor Details

    • AppointmentImportDAO

      public AppointmentImportDAO()
  • Method Details

    • insertFile

      public int insertFile(AppointmentImportFile file, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Inserts a new import file record.
      Specified by:
      insertFile in interface IAppointmentImportDAO
      Parameters:
      file - the file to persist
      plugin - the plugin
      Returns:
      the generated id_import_file
    • loadFile

      public AppointmentImportFile loadFile(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Loads an import file.
      Specified by:
      loadFile in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_file
      plugin - the plugin
      Returns:
      the file, or null if not found
    • selectFileIds

      public List<Integer> selectFileIds(List<Integer> listFormIds, String strFormId, String strFileName, String strStatus, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the ids of the files matching the filters, newest first.
      Specified by:
      selectFileIds in interface IAppointmentImportDAO
      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

      public List<AppointmentImportFile> selectFilesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Loads the files with the given ids, in the order of the list.
      Specified by:
      selectFilesByIds in interface IAppointmentImportDAO
      Parameters:
      listIds - the ids
      plugin - the plugin
      Returns:
      the files
    • selectFileNames

      public List<String> selectFileNames(List<Integer> listFormIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the distinct names of the files imported on the given forms.
      Specified by:
      selectFileNames in interface IAppointmentImportDAO
      Parameters:
      listFormIds - the forms
      plugin - the plugin
      Returns:
      the file names, sorted
    • existsDuplicateFile

      public boolean existsDuplicateFile(String strHash, int nFormId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Tells whether a file with the same content was already accepted for the form.
      Specified by:
      existsDuplicateFile in interface IAppointmentImportDAO
      Parameters:
      strHash - the SHA-256 of the content
      nFormId - the form
      plugin - the plugin
      Returns:
      true if a duplicate exists
    • updateFileStatus

      public void updateFileStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Updates the status of a file.
      Specified by:
      updateFileStatus in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_file
      strStatus - the new status
      plugin - the plugin
    • selectFileIdsToClose

      public List<Integer> selectFileIdsToClose(fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the files still pending whose batches are all done.
      Specified by:
      selectFileIdsToClose in interface IAppointmentImportDAO
      Parameters:
      plugin - the plugin
      Returns:
      the ids of the files whose status must be computed
    • countAppointmentsByFiles

      public Map<Integer,ImportCounts> countAppointmentsByFiles(List<Integer> listFileIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Counts the rows of the given files by outcome.
      Specified by:
      countAppointmentsByFiles in interface IAppointmentImportDAO
      Parameters:
      listFileIds - the files
      plugin - the plugin
      Returns:
      the counts of each file that has rows
    • fileHasErrors

      public boolean fileHasErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Tells whether a row of the file is in error.
      Specified by:
      fileHasErrors in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
      Returns:
      true if at least one row failed
    • fileAllBatchesArchived

      public boolean fileAllBatchesArchived(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Tells whether every batch of the file is archived.
      Specified by:
      fileAllBatchesArchived in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
      Returns:
      true if no batch is left to archive
    • archiveFile

      public void archiveFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Archives a file and removes its validation report.
      Specified by:
      archiveFile in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
    • selectRejectedFileIdsToPurge

      public List<Integer> selectRejectedFileIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the files rejected at validation before the given date.
      Specified by:
      selectRejectedFileIdsToPurge in interface IAppointmentImportDAO
      Parameters:
      dtBefore - the threshold
      plugin - the plugin
      Returns:
      the ids of the files to archive
    • insertBatch

      public int insertBatch(AppointmentImportBatch batch, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Inserts a new batch.
      Specified by:
      insertBatch in interface IAppointmentImportDAO
      Parameters:
      batch - the batch
      plugin - the plugin
      Returns:
      the generated id_import_batch
    • loadBatch

      public AppointmentImportBatch loadBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Loads a batch.
      Specified by:
      loadBatch in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_batch
      plugin - the plugin
      Returns:
      the batch, or null if not found
    • selectBatchesByFile

      public List<AppointmentImportBatch> selectBatchesByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the batches of a file, by starting date.
      Specified by:
      selectBatchesByFile in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
      Returns:
      the batches
    • selectBatchesByStatus

      public List<AppointmentImportBatch> selectBatchesByStatus(String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the batches with the given status, oldest first.
      Specified by:
      selectBatchesByStatus in interface IAppointmentImportDAO
      Parameters:
      strStatus - the status
      plugin - the plugin
      Returns:
      the batches
    • selectBatchIds

      public List<Integer> selectBatchIds(List<Integer> listFormIds, String strFormId, String strStatus, String strFileName, String strDate, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the ids of the batches matching the filters, newest first.
      Specified by:
      selectBatchIds in interface IAppointmentImportDAO
      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

      public List<AppointmentImportBatch> selectBatchesByIds(List<Integer> listIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Loads the batches with the given ids, in the order of the list.
      Specified by:
      selectBatchesByIds in interface IAppointmentImportDAO
      Parameters:
      listIds - the ids
      plugin - the plugin
      Returns:
      the batches
    • claimBatch

      public boolean claimBatch(int nId, String strFromStatus, LocalDateTime dtLastExecBefore, String strToken, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Takes a batch for processing: moves it from strFromStatus to PROCESSING with the given token, unless another process took it first.
      Specified by:
      claimBatch in interface IAppointmentImportDAO
      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

      public void touchBatch(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Records that a batch is still being processed.
      Specified by:
      touchBatch in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_batch
      plugin - the plugin
    • updateBatchStatus

      public void updateBatchStatus(int nId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Updates the status of a batch and releases its token.
      Specified by:
      updateBatchStatus in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_batch
      strStatus - the new status
      plugin - the plugin
    • requeueBatch

      public boolean requeueBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Puts a completed or pending batch back in the queue of the daemon; a batch being processed or archived is left as it is.
      Specified by:
      requeueBatch in interface IAppointmentImportDAO
      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

      public Map<Integer,ImportCounts> countAppointmentsByBatches(List<Integer> listBatchIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Counts the rows of the given batches by outcome.
      Specified by:
      countAppointmentsByBatches in interface IAppointmentImportDAO
      Parameters:
      listBatchIds - the batches
      plugin - the plugin
      Returns:
      the counts of each batch that has rows
    • batchHasErrors

      public boolean batchHasErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Tells whether a row of the batch is in error.
      Specified by:
      batchHasErrors in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      plugin - the plugin
      Returns:
      true if at least one row failed
    • selectBatchIdsToPurge

      public List<Integer> selectBatchIdsToPurge(LocalDateTime dtBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the completed batches last updated before the given date.
      Specified by:
      selectBatchIdsToPurge in interface IAppointmentImportDAO
      Parameters:
      dtBefore - the threshold
      plugin - the plugin
      Returns:
      the ids
    • archiveBatch

      public boolean archiveBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Archives a batch, if it is still completed.
      Specified by:
      archiveBatch in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      plugin - the plugin
      Returns:
      true if the batch is archived, false if it was retried meanwhile
    • insertAppointments

      public void insertAppointments(List<AppointmentImportAppointment> listAppointments, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Inserts the rows of an import.
      Specified by:
      insertAppointments in interface IAppointmentImportDAO
      Parameters:
      listAppointments - the rows
      plugin - the plugin
    • selectAppointmentsByBatch

      public List<AppointmentImportAppointment> selectAppointmentsByBatch(int nBatchId, String strStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Selects the rows of a batch, by source line.
      Specified by:
      selectAppointmentsByBatch in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      strStatus - optional status
      plugin - the plugin
      Returns:
      the rows
    • countAppointmentsByBatch

      public int countAppointmentsByBatch(int nBatchId, boolean bProcessedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Counts the rows of a batch.
      Specified by:
      countAppointmentsByBatch in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      bProcessedOnly - true to count only the rows created or in error
      plugin - the plugin
      Returns:
      the count
    • updateAppointment

      public void updateAppointment(int nId, String strStatus, String strCode, String strMessage, Integer nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Updates the state of a row.
      Specified by:
      updateAppointment in interface IAppointmentImportDAO
      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

      public AppointmentImportAppointment loadAppointment(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Loads a row.
      Specified by:
      loadAppointment in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_appointment
      plugin - the plugin
      Returns:
      the row, or null
    • updateAppointmentData

      public void updateAppointmentData(int nId, String strGenericAttributesData, String strFormFieldsData, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Replaces the values of a row.
      Specified by:
      updateAppointmentData in interface IAppointmentImportDAO
      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

      public void requeueErrorRows(int nBatchId, String strExcludedErrorCode, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Puts the rows in error of a batch back to pending, except those with the given error code.
      Specified by:
      requeueErrorRows in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      strExcludedErrorCode - the error code of the rows to leave in error
      plugin - the plugin
    • requeueRow

      public void requeueRow(int nId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Puts a row in error back to pending.
      Specified by:
      requeueRow in interface IAppointmentImportDAO
      Parameters:
      nId - the id_import_appointment
      plugin - the plugin
    • deleteAppointmentsByBatch

      public void deleteAppointmentsByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Deletes the rows of a batch.
      Specified by:
      deleteAppointmentsByBatch in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      plugin - the plugin
    • selectAppointmentIdsByFile

      public Map<Integer,Integer> selectAppointmentIdsByFile(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Gives the ids of the rows of a file, by line.
      Specified by:
      selectAppointmentIdsByFile in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
      Returns:
      the id_import_appointment of each line
    • replaceAppointment

      public boolean replaceAppointment(int nId, String strExcludedErrorCode, String strMessage, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Marks a row in error as replaced by a row of another file, unless it was interrupted while its appointment was being saved.
      Specified by:
      replaceAppointment in interface IAppointmentImportDAO
      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

      public void completeBatchWithoutErrors(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Completes a batch completed with errors that has no row in error any more.
      Specified by:
      completeBatchWithoutErrors in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      plugin - the plugin
    • completeFileWithoutErrors

      public void completeFileWithoutErrors(int nFileId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Completes a file completed with errors that has no row in error any more.
      Specified by:
      completeFileWithoutErrors in interface IAppointmentImportDAO
      Parameters:
      nFileId - the id_import_file
      plugin - the plugin
    • selectFingerprints

      public List<AppointmentImportFingerprint> selectFingerprints(int nFormId, Collection<String> collectionFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Finds the lines already imported on a form among the given fingerprints, with the file and the row that imported them.
      Specified by:
      selectFingerprints in interface IAppointmentImportDAO
      Parameters:
      nFormId - the form
      collectionFingerprints - the fingerprints
      plugin - the plugin
      Returns:
      the fingerprints found
    • insertFingerprints

      public void insertFingerprints(List<AppointmentImportFingerprint> listFingerprints, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Inserts fingerprints. One already there for its form fails: the line was imported meanwhile.
      Specified by:
      insertFingerprints in interface IAppointmentImportDAO
      Parameters:
      listFingerprints - the fingerprints
      plugin - the plugin
    • reassignFingerprint

      public boolean reassignFingerprint(AppointmentImportFingerprint fingerprint, int nFromAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Gives a fingerprint to a new row, if it still belongs to the given row.
      Specified by:
      reassignFingerprint in interface IAppointmentImportDAO
      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

      public void deleteFingerprintByAppointment(int nAppointmentId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Deletes the fingerprint of a row.
      Specified by:
      deleteFingerprintByAppointment in interface IAppointmentImportDAO
      Parameters:
      nAppointmentId - the id_import_appointment
      plugin - the plugin
    • deleteFingerprintsNotCreatedByBatch

      public void deleteFingerprintsNotCreatedByBatch(int nBatchId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Deletes the fingerprints of the rows of a batch that did not create their appointment, so that their lines can be imported again.
      Specified by:
      deleteFingerprintsNotCreatedByBatch in interface IAppointmentImportDAO
      Parameters:
      nBatchId - the id_import_batch
      plugin - the plugin
    • deleteFingerprintsBefore

      public void deleteFingerprintsBefore(LocalDate dateBefore, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Description copied from interface: IAppointmentImportDAO
      Deletes the fingerprints of the appointments before a date: a line in the past is refused anyway.
      Specified by:
      deleteFingerprintsBefore in interface IAppointmentImportDAO
      Parameters:
      dateBefore - the first date kept
      plugin - the plugin