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 forBulkUpdates
. Supported byBulkUpdateRepository
.- Author:
- Samarth Dhruva (samarthd)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description P
notifyOfCreateSandboxRequest(String bulkUpdateId)
Acquires a lock on the givenbulkUpdateId
, and if the bulkUpdate is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically initializes itsNotificationState
forCreateSandboxRequestProducer.TYPE
and renewsBulkUpdate.lastUpdated
.P
notifyOfDeleteSandboxRequest(String bulkUpdateId)
Acquires a lock on the givenbulkUpdateId
, and if the bulkUpdate is found and has aBulkUpdate.status
ofBulkUpdateStatus.ERROR
, atomically initializes itsNotificationState
forDeleteSandboxRequestProducer.TYPE
and renewsBulkUpdate.lastUpdated
.org.springframework.data.domain.Page<P>
readByTargetAndApplicationId(String target, String applicationId, org.springframework.data.domain.Pageable pageable)
Reads the bulk updates with the givenBulkUpdate.target
andBulkUpdate.applicationId
.List<P>
readIncompleteLastUpdatedBefore(Instant cutoff)
Reads the bulk updates which are incomplete (those with statusBulkUpdateStatus.REQUESTED
orBulkUpdateStatus.PROCESSING
) whoseBulkUpdate.lastUpdated
is before the givencutoff
.List<P>
readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)
Reads the bulk updates which are incomplete (those with statusBulkUpdateStatus.REQUESTED
orBulkUpdateStatus.PROCESSING
) whoseBulkUpdate.lastUpdated
is before the givencutoff
.boolean
setContainedErrors(P bulkUpdate)
Atomically finds and updates the given bulk update: finds the bulk update with the ID matching the givenbulkUpdate
, sets the bulk update'sBulkUpdate.errors
to the errors contained within the givenbulkUpdate
, setsBulkUpdate.status
toBulkUpdateStatus.ERROR
, and renewsBulkUpdate.lastUpdated
.boolean
setFinishedStatus(String bulkUpdateId)
Acquires a lock on the givenbulkUpdateId
, and if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically sets theBulkUpdate.status
toBulkUpdateStatus.FINISHED
and renewsBulkUpdate.lastUpdated
boolean
setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed)
Acquires a lock on the givenbulkUpdateId
, and if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically setsBulkUpdate.numberOfRecordsProcessed
to the given value and renewsBulkUpdate.lastUpdated
.P
setProcessingStatus(String bulkUpdateId)
Acquires a lock on the givenbulkUpdateId
, and if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.REQUESTED
, atomically updates theBulkUpdate.status
toBulkUpdateStatus.PROCESSING
and renewsBulkUpdate.lastUpdated
.-
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByIds, readById, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess
-
-
-
-
Method Detail
-
setProcessingStatus
@Nullable P setProcessingStatus(String bulkUpdateId)
Acquires a lock on the givenbulkUpdateId
, and if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.REQUESTED
, atomically updates theBulkUpdate.status
toBulkUpdateStatus.PROCESSING
and renewsBulkUpdate.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 givenbulkUpdate
, sets the bulk update'sBulkUpdate.errors
to the errors contained within the givenbulkUpdate
, setsBulkUpdate.status
toBulkUpdateStatus.ERROR
, and renewsBulkUpdate.lastUpdated
. No other values frombulkUpdate
are applied.The change is applied only if the bulk update is found to have a
BulkUpdate.status
ofBulkUpdateStatus.REQUESTED
orBulkUpdateStatus.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 givenbulkUpdateId
, and if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically setsBulkUpdate.numberOfRecordsProcessed
to the given value and renewsBulkUpdate.lastUpdated
.- Parameters:
bulkUpdateId
- the ID of the bulk update to modifynumberOfRecordsProcessed
- the new value to set forBulkUpdate.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 givenbulkUpdateId
, and if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically sets theBulkUpdate.status
toBulkUpdateStatus.FINISHED
and renewsBulkUpdate.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 givenbulkUpdateId
, and if the bulkUpdate is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
, atomically initializes itsNotificationState
forCreateSandboxRequestProducer.TYPE
and renewsBulkUpdate.lastUpdated
.If the update is successful, calls
NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String)
for theCreateSandboxRequestProducer.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 givenbulkUpdateId
, and if the bulkUpdate is found and has aBulkUpdate.status
ofBulkUpdateStatus.ERROR
, atomically initializes itsNotificationState
forDeleteSandboxRequestProducer.TYPE
and renewsBulkUpdate.lastUpdated
.If the update is successful, calls
NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String)
for theDeleteSandboxRequestProducer.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 givenBulkUpdate.target
andBulkUpdate.applicationId
.- Parameters:
target
- theBulkUpdate.target
to filter byapplicationId
- theBulkUpdate.applicationId
to filter results by. Note that if this isnull
, only bulk updates withnull
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 statusBulkUpdateStatus.REQUESTED
orBulkUpdateStatus.PROCESSING
) whoseBulkUpdate.lastUpdated
is before the givencutoff
.- Parameters:
cutoff
- the results will be filtered to only include those updates whoseBulkUpdate.lastUpdated
is before this value- Returns:
- the bulk updates which are incomplete and have a
BulkUpdate.lastUpdated
before the givencutoff
-
readIncompleteLastUpdatedBeforeAndTenantId
List<P> readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)
Reads the bulk updates which are incomplete (those with statusBulkUpdateStatus.REQUESTED
orBulkUpdateStatus.PROCESSING
) whoseBulkUpdate.lastUpdated
is before the givencutoff
.- Parameters:
cutoff
- the results will be filtered to only include those updates whoseBulkUpdate.lastUpdated
is before this valuetenantId
- 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 givencutoff
andtenantId
-
-