Interface BulkUpdateService<P extends BulkUpdate>

All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P>
All Known Implementing Classes:
DefaultBulkUpdateService

public interface BulkUpdateService<P extends BulkUpdate> extends com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P>
Service API for BulkUpdates. Supported by BulkUpdateRepository.
Author:
Samarth Dhruva (samarthd)
  • Method Details

    • setProcessingStatus

      @Nullable P setProcessingStatus(String bulkUpdateId)
      Acquires a lock on the given bulkUpdateId, and if it is found to have a BulkUpdate.status of BulkUpdateStatus.REQUESTED, atomically updates the BulkUpdate.status to BulkUpdateStatus.PROCESSING and renews BulkUpdate.lastUpdated.
      Parameters:
      bulkUpdateId - the ID of the bulk update to find and update
      Returns:
      the updated BulkUpdate if successfully found and updated, null otherwise
      Throws:
      com.broadleafcommerce.common.messaging.exception.ResourceLockException - if the lock could not be acquired
    • setContainedErrors

      boolean setContainedErrors(P bulkUpdate)
      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.

      Parameters:
      bulkUpdate - a bulk update object containing the errors to set
      Returns:
      true if the change was successfully applied, false otherwise
    • setNumberOfRecordsProcessed

      boolean setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed)
      Acquires a lock on the given bulkUpdateId, and if the bulk update is found and has a BulkUpdate.status of BulkUpdateStatus.PROCESSING, atomically sets BulkUpdate.numberOfRecordsProcessed to the given value and renews BulkUpdate.lastUpdated.
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      numberOfRecordsProcessed - the new value to set for BulkUpdate.numberOfRecordsProcessed
      Returns:
      true if the update was successfully performed, false otherwise
      Throws:
      com.broadleafcommerce.common.messaging.exception.ResourceLockException - if the lock could not be acquired
    • setFinishedStatus

      boolean setFinishedStatus(String bulkUpdateId)
      Acquires a lock on the given bulkUpdateId, and if the bulk update is found and has a BulkUpdate.status of BulkUpdateStatus.PROCESSING, atomically sets the BulkUpdate.status to BulkUpdateStatus.FINISHED and renews BulkUpdate.lastUpdated
      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      true if the update was successfully performed, false otherwise
      Throws:
      com.broadleafcommerce.common.messaging.exception.ResourceLockException - if the lock could not be acquired
    • notifyOfCreateSandboxRequest

      @Nullable P notifyOfCreateSandboxRequest(String bulkUpdateId)
      Acquires a lock on the given bulkUpdateId, and if the bulkUpdate is found and has a BulkUpdate.status of BulkUpdateStatus.PROCESSING, atomically initializes its NotificationState for CreateSandboxRequestProducer.TYPE and renews BulkUpdate.lastUpdated.

      If the update is successful, calls NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String) for the CreateSandboxRequestProducer.TYPE.

      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if successfully found and updated, null otherwise
      Throws:
      com.broadleafcommerce.common.messaging.exception.ResourceLockException - if the lock could not be acquired
    • notifyOfDeleteSandboxRequest

      @Nullable P notifyOfDeleteSandboxRequest(String bulkUpdateId)
      Acquires a lock on the given bulkUpdateId, and if the bulkUpdate is found and has a BulkUpdate.status of BulkUpdateStatus.ERROR, atomically initializes its NotificationState for DeleteSandboxRequestProducer.TYPE and renews BulkUpdate.lastUpdated.

      If the update is successful, calls NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String) for the DeleteSandboxRequestProducer.TYPE.

      Parameters:
      bulkUpdateId - the ID of the bulk update to modify
      Returns:
      the updated BulkUpdate if successfully found and updated, null otherwise
      Throws:
      com.broadleafcommerce.common.messaging.exception.ResourceLockException - if the lock could not be acquired
    • readByTargetAndApplicationId

      org.springframework.data.domain.Page<P> readByTargetAndApplicationId(@NonNull String target, @Nullable String applicationId, @NonNull org.springframework.data.domain.Pageable pageable)
      Reads the bulk updates with the given BulkUpdate.target and BulkUpdate.applicationId.
      Parameters:
      target - the BulkUpdate.target to filter by
      applicationId - the BulkUpdate.applicationId to filter results by. Note that if this is null, only bulk updates with null application IDs will be returned.
      pageable - information about which page of results to return from the database
      Returns:
      the bulk updates with the given BulkUpdate.target
    • readIncompleteLastUpdatedBefore

      List<P> readIncompleteLastUpdatedBefore(Instant cutoff)
      Reads the bulk updates which are incomplete (those with status BulkUpdateStatus.REQUESTED or BulkUpdateStatus.PROCESSING) whose BulkUpdate.lastUpdated is before the given cutoff.
      Parameters:
      cutoff - the results will be filtered to only include those updates whose BulkUpdate.lastUpdated is before this value
      Returns:
      the bulk updates which are incomplete and have a BulkUpdate.lastUpdated before the given cutoff
    • readIncompleteLastUpdatedBeforeAndTenantId

      List<P> readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)
      Reads the bulk updates which are incomplete (those with status BulkUpdateStatus.REQUESTED or BulkUpdateStatus.PROCESSING) whose BulkUpdate.lastUpdated is before the given cutoff.
      Parameters:
      cutoff - the results will be filtered to only include those updates whose BulkUpdate.lastUpdated is before this value
      tenantId - the tenant id that this bulk update operation was initiated from
      Returns:
      the bulk updates which are incomplete and have a BulkUpdate.lastUpdated before the given cutoff and tenantId