Class JpaCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>

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

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

    • JpaCustomizedBulkUpdateRepository

      public JpaCustomizedBulkUpdateRepository(@NonNull 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 bulkUpdateId)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically update BulkUpdate.status to BulkUpdateStatus.PROCESSING and renew BulkUpdate.lastUpdated if the current BulkUpdate.status is BulkUpdateStatus.REQUESTED.
      Specified by:
      setProcessingStatus in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if found and updated, null otherwise
    • buildIdFilter

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

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

      @Nullable @Transactional public D setContainedErrors(D bulkUpdate)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically finds and updates the given bulk update: finds the bulk update with the ID matching the given bulkUpdate, sets the bulk update's BulkUpdate.errors to the errors contained within the given bulkUpdate, sets BulkUpdate.status to BulkUpdateStatus.ERROR, and renews BulkUpdate.lastUpdated. No other values from bulkUpdate are applied.

      The change is applied only if the bulk update is found to have a BulkUpdate.status of BulkUpdateStatus.REQUESTED or BulkUpdateStatus.PROCESSING.

      Specified by:
      setContainedErrors in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdate - a bulk update object containing the errors to set
      Returns:
      the updated bulk update if found and updated, null otherwise
    • buildStatusInFilter

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

      @Nullable @Transactional public D setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically sets the BulkUpdate.numberOfRecordsProcessed to the given value and renews BulkUpdate.lastUpdated if the bulk update is found and has a BulkUpdate.status of BulkUpdateStatus.PROCESSING.
      Specified by:
      setNumberOfRecordsProcessed in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      numberOfRecordsProcessed - the new value to set for BulkUpdate.numberOfRecordsProcessed
      Returns:
      the updated BulkUpdate if found and updated, null otherwise
    • setFinishedStatus

      @Nullable @Transactional public D setFinishedStatus(String bulkUpdateId)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically sets the BulkUpdate.status to BulkUpdateStatus.FINISHED and renews BulkUpdate.lastUpdated if the bulk update is found and has a BulkUpdate.status of BulkUpdateStatus.PROCESSING.
      Specified by:
      setFinishedStatus in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if found and updated, null otherwise
    • initializeCreateSandboxNotificationState

      @Nullable @Transactional public D initializeCreateSandboxNotificationState(String bulkUpdateId)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically initializes the NotificationState for CreateSandboxRequestProducer.TYPE on the given bulk update if it is found to have a BulkUpdate.status of BulkUpdateStatus.PROCESSING.
      Specified by:
      initializeCreateSandboxNotificationState in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if found and updated, null otherwise
    • initializeNotificationState

      protected void initializeNotificationState(D entity, String notificationStateName, Instant changeTimestamp)
    • initializeDeleteSandboxNotificationState

      @Nullable @Transactional public D initializeDeleteSandboxNotificationState(String bulkUpdateId)
      Description copied from interface: CustomizedBulkUpdateRepository
      Atomically initializes the NotificationState for DeleteSandboxRequestProducer.TYPE on the given bulk update if it is found to have a BulkUpdate.status of BulkUpdateStatus.ERROR.
      Specified by:
      initializeDeleteSandboxNotificationState in interface CustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if found and updated, null otherwise
    • getNotificationFragment

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

      protected jakarta.persistence.EntityManager getEntityManager()