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.PredicatebuildIdFilter(String bulkUpdateId, jakarta.persistence.criteria.Root<D> bulkUpdateEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildStatusFilter(String status, jakarta.persistence.criteria.Root<D> bulkUpdateEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildStatusInFilter(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.EntityManagerprotected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragmentinitializeCreateSandboxNotificationState(String bulkUpdateId) Atomically initializes theNotificationStateforCreateSandboxRequestProducer.TYPEon the given bulk update if it is found to have aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.initializeDeleteSandboxNotificationState(String bulkUpdateId) Atomically initializes theNotificationStateforDeleteSandboxRequestProducer.TYPEon the given bulk update if it is found to have aBulkUpdate.statusofBulkUpdateStatus.ERROR.protected voidinitializeNotificationState(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.errorsto the errors contained within the givenbulkUpdate, setsBulkUpdate.statustoBulkUpdateStatus.ERROR, and renewsBulkUpdate.lastUpdated.booleansetFailedNotificationAttempt(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) setFinishedStatus(String bulkUpdateId) Atomically sets theBulkUpdate.statustoBulkUpdateStatus.FINISHEDand renewsBulkUpdate.lastUpdatedif the bulk update is found and has aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.booleansetNotificationAcknowledged(Object nativeId, String messageType, int attemptCount, Class<?> entityType) setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed) Atomically sets theBulkUpdate.numberOfRecordsProcessedto the given value and renewsBulkUpdate.lastUpdatedif the bulk update is found and has aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.setProcessingStatus(String bulkUpdateId) Atomically updateBulkUpdate.statustoBulkUpdateStatus.PROCESSINGand renewBulkUpdate.lastUpdatedif the currentBulkUpdate.statusisBulkUpdateStatus.REQUESTED.
-
Constructor Details
-
JpaCustomizedBulkUpdateRepository
public JpaCustomizedBulkUpdateRepository(@NonNull com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment)
-
-
Method Details
-
save
-
saveAll
-
getDomainType
- Specified by:
getDomainTypein interfacecom.broadleafcommerce.common.extension.DomainTypeAware
-
setNotificationAcknowledged
public boolean setNotificationAcknowledged(@NonNull Object nativeId, @NonNull String messageType, int attemptCount, @NonNull Class<?> entityType) - Specified by:
setNotificationAcknowledgedin 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:
setFailedNotificationAttemptin 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:
findNotificationReadyMembersin interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
setProcessingStatus
Description copied from interface:CustomizedBulkUpdateRepositoryAtomically updateBulkUpdate.statustoBulkUpdateStatus.PROCESSINGand renewBulkUpdate.lastUpdatedif the currentBulkUpdate.statusisBulkUpdateStatus.REQUESTED.- Specified by:
setProcessingStatusin interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdateId- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdateif found and updated,nullotherwise
-
buildIdFilter
-
buildStatusFilter
-
setContainedErrors
Description copied from interface:CustomizedBulkUpdateRepositoryAtomically finds and updates the given bulk update: finds the bulk update with the ID matching the givenbulkUpdate, sets the bulk update'sBulkUpdate.errorsto the errors contained within the givenbulkUpdate, setsBulkUpdate.statustoBulkUpdateStatus.ERROR, and renewsBulkUpdate.lastUpdated. No other values frombulkUpdateare applied.The change is applied only if the bulk update is found to have a
BulkUpdate.statusofBulkUpdateStatus.REQUESTEDorBulkUpdateStatus.PROCESSING.- Specified by:
setContainedErrorsin interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdate- a bulk update object containing the errors to set- Returns:
- the updated bulk update if found and updated,
nullotherwise
-
buildStatusInFilter
-
setNumberOfRecordsProcessed
@Nullable @Transactional public D setNumberOfRecordsProcessed(String bulkUpdateId, long numberOfRecordsProcessed) Description copied from interface:CustomizedBulkUpdateRepositoryAtomically sets theBulkUpdate.numberOfRecordsProcessedto the given value and renewsBulkUpdate.lastUpdatedif the bulk update is found and has aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.- Specified by:
setNumberOfRecordsProcessedin interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdateId- the ID of the bulk update to modifynumberOfRecordsProcessed- the new value to set forBulkUpdate.numberOfRecordsProcessed- Returns:
- the updated
BulkUpdateif found and updated,nullotherwise
-
setFinishedStatus
Description copied from interface:CustomizedBulkUpdateRepositoryAtomically sets theBulkUpdate.statustoBulkUpdateStatus.FINISHEDand renewsBulkUpdate.lastUpdatedif the bulk update is found and has aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.- Specified by:
setFinishedStatusin interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdateId- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdateif found and updated,nullotherwise
-
initializeCreateSandboxNotificationState
Description copied from interface:CustomizedBulkUpdateRepositoryAtomically initializes theNotificationStateforCreateSandboxRequestProducer.TYPEon the given bulk update if it is found to have aBulkUpdate.statusofBulkUpdateStatus.PROCESSING.- Specified by:
initializeCreateSandboxNotificationStatein interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdateId- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdateif found and updated,nullotherwise
-
initializeNotificationState
-
initializeDeleteSandboxNotificationState
Description copied from interface:CustomizedBulkUpdateRepositoryAtomically initializes theNotificationStateforDeleteSandboxRequestProducer.TYPEon the given bulk update if it is found to have aBulkUpdate.statusofBulkUpdateStatus.ERROR.- Specified by:
initializeDeleteSandboxNotificationStatein interfaceCustomizedBulkUpdateRepository<D extends JpaBulkUpdate>- Parameters:
bulkUpdateId- the ID of the bulk update to modify- Returns:
- the updated
BulkUpdateif found and updated,nullotherwise
-
getNotificationFragment
@NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment getNotificationFragment() -
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()
-