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 Summary
ConstructorsConstructorDescriptionJpaCustomizedBulkUpdateRepository
(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.Predicate
buildIdFilter
(String bulkUpdateId, jakarta.persistence.criteria.Root<D> bulkUpdateEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildStatusFilter
(String status, jakarta.persistence.criteria.Root<D> bulkUpdateEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildStatusInFilter
(Collection<String> statuses, jakarta.persistence.criteria.Root<D> bulkUpdateEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware>
findNotificationReadyMembers
(Object lastProcessedNativeId, int pageSize, String messageType, Duration faultThreshold, Class<?> entityType) protected jakarta.persistence.EntityManager
protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
initializeCreateSandboxNotificationState
(String bulkUpdateId) Atomically initializes theNotificationState
forCreateSandboxRequestProducer.TYPE
on the given bulk update if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.initializeDeleteSandboxNotificationState
(String bulkUpdateId) Atomically initializes theNotificationState
forDeleteSandboxRequestProducer.TYPE
on the given bulk update if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.ERROR
.protected void
initializeNotificationState
(D entity, String notificationStateName, Instant changeTimestamp) setContainedErrors
(D 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
setFailedNotificationAttempt
(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) setFinishedStatus
(String bulkUpdateId) Atomically sets theBulkUpdate.status
toBulkUpdateStatus.FINISHED
and renewsBulkUpdate.lastUpdated
if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.boolean
setNotificationAcknowledged
(Object nativeId, String messageType, int attemptCount, Class<?> entityType) setNumberOfRecordsProcessed
(String bulkUpdateId, long numberOfRecordsProcessed) Atomically sets theBulkUpdate.numberOfRecordsProcessed
to the given value and renewsBulkUpdate.lastUpdated
if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.setProcessingStatus
(String bulkUpdateId) Atomically updateBulkUpdate.status
toBulkUpdateStatus.PROCESSING
and renewBulkUpdate.lastUpdated
if the currentBulkUpdate.status
isBulkUpdateStatus.REQUESTED
.
-
Constructor Details
-
JpaCustomizedBulkUpdateRepository
public JpaCustomizedBulkUpdateRepository(@NonNull com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment)
-
-
Method Details
-
save
-
saveAll
-
getDomainType
- Specified by:
getDomainType
in interfacecom.broadleafcommerce.common.extension.DomainTypeAware
-
setNotificationAcknowledged
public boolean setNotificationAcknowledged(@NonNull Object nativeId, @NonNull String messageType, int attemptCount, @NonNull Class<?> entityType) - Specified by:
setNotificationAcknowledged
in interfacecom.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 interfacecom.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 interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
setProcessingStatus
Description copied from interface:CustomizedBulkUpdateRepository
Atomically updateBulkUpdate.status
toBulkUpdateStatus.PROCESSING
and renewBulkUpdate.lastUpdated
if the currentBulkUpdate.status
isBulkUpdateStatus.REQUESTED
.- Specified by:
setProcessingStatus
in interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
- Parameters:
bulkUpdateId
- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdate
if found and updated,null
otherwise
-
buildIdFilter
-
buildStatusFilter
-
setContainedErrors
Description copied from interface:CustomizedBulkUpdateRepository
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
.- Specified by:
setContainedErrors
in interfaceCustomizedBulkUpdateRepository<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
-
setNumberOfRecordsProcessed
@Nullable @Transactional public D setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed) Description copied from interface:CustomizedBulkUpdateRepository
Atomically sets theBulkUpdate.numberOfRecordsProcessed
to the given value and renewsBulkUpdate.lastUpdated
if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.- Specified by:
setNumberOfRecordsProcessed
in interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
- Parameters:
bulkUpdateId
- the ID of the bulk update to modifynumberOfRecordsProcessed
- the new value to set forBulkUpdate.numberOfRecordsProcessed
- Returns:
- the updated
BulkUpdate
if found and updated,null
otherwise
-
setFinishedStatus
Description copied from interface:CustomizedBulkUpdateRepository
Atomically sets theBulkUpdate.status
toBulkUpdateStatus.FINISHED
and renewsBulkUpdate.lastUpdated
if the bulk update is found and has aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.- Specified by:
setFinishedStatus
in interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
- Parameters:
bulkUpdateId
- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdate
if found and updated,null
otherwise
-
initializeCreateSandboxNotificationState
Description copied from interface:CustomizedBulkUpdateRepository
Atomically initializes theNotificationState
forCreateSandboxRequestProducer.TYPE
on the given bulk update if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.- Specified by:
initializeCreateSandboxNotificationState
in interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>
- Parameters:
bulkUpdateId
- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdate
if found and updated,null
otherwise
-
initializeNotificationState
-
initializeDeleteSandboxNotificationState
Description copied from interface:CustomizedBulkUpdateRepository
Atomically initializes theNotificationState
forDeleteSandboxRequestProducer.TYPE
on the given bulk update if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.ERROR
.- Specified by:
initializeDeleteSandboxNotificationState
in interfaceCustomizedBulkUpdateRepository<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()
-