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
Constructors Constructor Description JpaCustomizedBulkUpdateRepository(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.persistence.criteria.Predicate
buildIdFilter(String bulkUpdateId, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
protected javax.persistence.criteria.Predicate
buildStatusFilter(String status, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
protected javax.persistence.criteria.Predicate
buildStatusInFilter(Collection<String> statuses, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.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)
Class<D>
getDomainType()
protected javax.persistence.EntityManager
getEntityManager()
protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
getNotificationFragment()
D
initializeCreateSandboxNotificationState(String bulkUpdateId)
Atomically initializes theNotificationState
forCreateSandboxRequestProducer.TYPE
on the given bulk update if it is found to have aBulkUpdate.status
ofBulkUpdateStatus.PROCESSING
.D
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)
Object
save(Object entity)
List<Object>
saveAll(Iterable<?> entities)
D
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)
D
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)
D
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
.D
setProcessingStatus(String bulkUpdateId)
Atomically updateBulkUpdate.status
toBulkUpdateStatus.PROCESSING
and renewBulkUpdate.lastUpdated
if the currentBulkUpdate.status
isBulkUpdateStatus.REQUESTED
.
-
-
-
Method Detail
-
getDomainType
public Class<D> 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
@Nullable @Transactional public D setProcessingStatus(String bulkUpdateId)
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
protected javax.persistence.criteria.Predicate buildIdFilter(String bulkUpdateId, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
-
buildStatusFilter
protected javax.persistence.criteria.Predicate buildStatusFilter(String status, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.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 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
protected javax.persistence.criteria.Predicate buildStatusInFilter(Collection<String> statuses, javax.persistence.criteria.Root<D> bulkUpdateEntity, javax.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 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
@Nullable @Transactional public D setFinishedStatus(String bulkUpdateId)
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
@Nullable @Transactional public D initializeCreateSandboxNotificationState(String bulkUpdateId)
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
protected void initializeNotificationState(D entity, String notificationStateName, Instant changeTimestamp)
-
initializeDeleteSandboxNotificationState
@Nullable @Transactional public D initializeDeleteSandboxNotificationState(String bulkUpdateId)
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 javax.persistence.EntityManager getEntityManager()
-
-