Class JpaCustomizedExportRepository<D extends JpaExport>
java.lang.Object
com.broadleafcommerce.common.dataexport.provider.jpa.repository.JpaCustomizedExportRepository<D>
- All Implemented Interfaces:
CustomizedExportRepository<D>
,com.broadleafcommerce.common.extension.DomainTypeAware
,com.broadleafcommerce.common.messaging.notification.NotificationStateRepository
,com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
public class JpaCustomizedExportRepository<D extends JpaExport>
extends Object
implements CustomizedExportRepository<D>, com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorDescriptionJpaCustomizedExportRepository
(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationFragment) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.Predicate
buildIdFilter
(String exportId, jakarta.persistence.criteria.Root<D> exportEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildStatusFilter
(String status, jakarta.persistence.criteria.Root<D> exportEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildStatusInFilter
(Collection<String> statuses, jakarta.persistence.criteria.Root<D> exportEntity, 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
getEm()
protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
Atomically finds and updates the given export: finds the export with the ID matching the givenexport
, sets the export'sExport.errorMessage
to the given value, setsExport.status
toExportStatus.ERROR
, and renewsExport.lastUpdated
.boolean
setFailedNotificationAttempt
(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) setFileLocationAndFinishedStatus
(String exportId, String fileLocation) Atomically sets theExport.status
toExportStatus.FINISHED
, sets theExport.fileLocation
tofileLocation
, and renewsExport.lastUpdated
if the export is found and has aExport.status
ofExportStatus.PROCESSING
.boolean
setNotificationAcknowledged
(Object nativeId, String messageType, int attemptCount, Class<?> entityType) setNumberOfRecordsProcessed
(String exportId, long numberOfRecordsProcessed) Atomically sets theExport.numberOfRecordsProcessed
to the given value and renewsExport.lastUpdated
if the export is found and has aExport.status
ofExportStatus.PROCESSING
.setProcessingStatus
(String exportId) Atomically updateExport.status
toExportStatus.PROCESSING
and renewExport.lastUpdated
if the currentExport.status
isExportStatus.REQUESTED
.
-
Constructor Details
-
JpaCustomizedExportRepository
public JpaCustomizedExportRepository(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:CustomizedExportRepository
Atomically updateExport.status
toExportStatus.PROCESSING
and renewExport.lastUpdated
if the currentExport.status
isExportStatus.REQUESTED
.- Specified by:
setProcessingStatus
in interfaceCustomizedExportRepository<D extends JpaExport>
- Parameters:
exportId
- the ID of the export to modify- Returns:
- the updated
Export
if found and updated,null
otherwise
-
buildIdFilter
-
buildStatusFilter
-
setError
Description copied from interface:CustomizedExportRepository
Atomically finds and updates the given export: finds the export with the ID matching the givenexport
, sets the export'sExport.errorMessage
to the given value, setsExport.status
toExportStatus.ERROR
, and renewsExport.lastUpdated
.The update is applied only if the export is found to have a
Export.status
ofExportStatus.REQUESTED
orExportStatus.PROCESSING
.- Specified by:
setError
in interfaceCustomizedExportRepository<D extends JpaExport>
- Parameters:
exportId
- the ID of the export to find and updateerrorMessage
- the error message to set on the export- Returns:
- the updated export if found and updated,
null
otherwise
-
buildStatusInFilter
-
setNumberOfRecordsProcessed
@Nullable @Transactional public D setNumberOfRecordsProcessed(String exportId, long numberOfRecordsProcessed) Description copied from interface:CustomizedExportRepository
Atomically sets theExport.numberOfRecordsProcessed
to the given value and renewsExport.lastUpdated
if the export is found and has aExport.status
ofExportStatus.PROCESSING
.- Specified by:
setNumberOfRecordsProcessed
in interfaceCustomizedExportRepository<D extends JpaExport>
- Parameters:
exportId
- the ID of the export to modifynumberOfRecordsProcessed
- the new value to set forExport.numberOfRecordsProcessed
- Returns:
- the updated
Export
if found and updated,null
otherwise
-
setFileLocationAndFinishedStatus
@Nullable @Transactional public D setFileLocationAndFinishedStatus(String exportId, String fileLocation) Description copied from interface:CustomizedExportRepository
Atomically sets theExport.status
toExportStatus.FINISHED
, sets theExport.fileLocation
tofileLocation
, and renewsExport.lastUpdated
if the export is found and has aExport.status
ofExportStatus.PROCESSING
.- Specified by:
setFileLocationAndFinishedStatus
in interfaceCustomizedExportRepository<D extends JpaExport>
- Parameters:
exportId
- the ID of the export to modifyfileLocation
- the file location to set on the export- Returns:
- the updated
Export
if found and updated,null
otherwise
-
getNotificationFragment
@NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment getNotificationFragment() -
getEm
@NonNull protected jakarta.persistence.EntityManager getEm()
-