Class JpaCustomizedExportRepository<D extends JpaExport>

java.lang.Object
com.broadleafcommerce.common.dataexport.provider.jpa.repository.JpaCustomizedExportRepository<D>
All Implemented Interfaces:
CustomizedExportRepository<D>, com.broadleafcommerce.common.extension.DomainTypeAware, com.broadleafcommerce.common.messaging.notification.NotificationStateRepository, com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment

public class JpaCustomizedExportRepository<D extends JpaExport> extends Object implements CustomizedExportRepository<D>, com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
Author:
Samarth Dhruva (samarthd)
  • Constructor Details

    • JpaCustomizedExportRepository

      public JpaCustomizedExportRepository(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment)
  • Method Details

    • save

      @Transactional public Object save(Object entity)
    • saveAll

      @Transactional public List<Object> saveAll(Iterable<?> entities)
    • getDomainType

      public Class<D> getDomainType()
      Specified by:
      getDomainType in interface com.broadleafcommerce.common.extension.DomainTypeAware
    • setNotificationAcknowledged

      public boolean setNotificationAcknowledged(@NonNull Object nativeId, @NonNull String messageType, int attemptCount, @NonNull Class<?> entityType)
      Specified by:
      setNotificationAcknowledged in interface com.broadleafcommerce.common.messaging.notification.NotificationStateRepository
    • setFailedNotificationAttempt

      public boolean setFailedNotificationAttempt(@NonNull Object nativeId, @NonNull String messageType, int attemptCount, @NonNull Instant nextAttempt, @NonNull Class<?> entityType, boolean stopped)
      Specified by:
      setFailedNotificationAttempt in interface com.broadleafcommerce.common.messaging.notification.NotificationStateRepository
    • findNotificationReadyMembers

      @NonNull public Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware> findNotificationReadyMembers(Object lastProcessedNativeId, int pageSize, @NonNull String messageType, @NonNull Duration faultThreshold, @NonNull Class<?> entityType)
      Specified by:
      findNotificationReadyMembers in interface com.broadleafcommerce.common.messaging.notification.NotificationStateRepository
    • setProcessingStatus

      @Nullable @Transactional public D setProcessingStatus(String exportId)
      Description copied from interface: CustomizedExportRepository
      Atomically update Export.status to ExportStatus.PROCESSING and renew Export.lastUpdated if the current Export.status is ExportStatus.REQUESTED.
      Specified by:
      setProcessingStatus in interface CustomizedExportRepository<D extends JpaExport>
      Parameters:
      exportId - the ID of the export to modify
      Returns:
      the updated Export if found and updated, null otherwise
    • buildIdFilter

      protected jakarta.persistence.criteria.Predicate buildIdFilter(String exportId, jakarta.persistence.criteria.Root<D> exportEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • buildStatusFilter

      protected jakarta.persistence.criteria.Predicate buildStatusFilter(String status, jakarta.persistence.criteria.Root<D> exportEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • setError

      @Nullable @Transactional public D setError(String exportId, String errorMessage)
      Description copied from interface: CustomizedExportRepository
      Atomically finds and updates the given export: finds the export with the ID matching the given export, sets the export's Export.errorMessage to the given value, sets Export.status to ExportStatus.ERROR, and renews Export.lastUpdated.

      The update is applied only if the export is found to have a Export.status of ExportStatus.REQUESTED or ExportStatus.PROCESSING.

      Specified by:
      setError in interface CustomizedExportRepository<D extends JpaExport>
      Parameters:
      exportId - the ID of the export to find and update
      errorMessage - the error message to set on the export
      Returns:
      the updated export if found and updated, null otherwise
    • buildStatusInFilter

      protected jakarta.persistence.criteria.Predicate buildStatusInFilter(Collection<String> statuses, jakarta.persistence.criteria.Root<D> exportEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • setNumberOfRecordsProcessed

      @Nullable @Transactional public D setNumberOfRecordsProcessed(String exportId, long numberOfRecordsProcessed)
      Description copied from interface: CustomizedExportRepository
      Atomically sets the Export.numberOfRecordsProcessed to the given value and renews Export.lastUpdated if the export is found and has a Export.status of ExportStatus.PROCESSING.
      Specified by:
      setNumberOfRecordsProcessed in interface CustomizedExportRepository<D extends JpaExport>
      Parameters:
      exportId - the ID of the export to modify
      numberOfRecordsProcessed - the new value to set for Export.numberOfRecordsProcessed
      Returns:
      the updated Export if found and updated, null otherwise
    • setFileLocationAndFinishedStatus

      @Nullable @Transactional public D setFileLocationAndFinishedStatus(String exportId, String fileLocation)
      Description copied from interface: CustomizedExportRepository
      Atomically sets the Export.status to ExportStatus.FINISHED, sets the Export.fileLocation to fileLocation, and renews Export.lastUpdated if the export is found and has a Export.status of ExportStatus.PROCESSING.
      Specified by:
      setFileLocationAndFinishedStatus in interface CustomizedExportRepository<D extends JpaExport>
      Parameters:
      exportId - the ID of the export to modify
      fileLocation - the file location to set on the export
      Returns:
      the updated Export if found and updated, null otherwise
    • getNotificationFragment

      @NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment getNotificationFragment()
    • getEm

      @NonNull protected jakarta.persistence.EntityManager getEm()