Class JpaCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>
java.lang.Object
com.broadleafcommerce.dataimport.provider.jpa.repository.JpaCustomizedImportBatchItemCompletionRepository<D>
- All Implemented Interfaces:
com.broadleafcommerce.common.extension.DomainTypeAware,com.broadleafcommerce.common.messaging.notification.NotificationStateRepository,com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment,CustomizedImportBatchItemCompletionRepository<D>
@Repository
public class JpaCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>
extends Object
implements CustomizedImportBatchItemCompletionRepository<D>, com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorsConstructorDescriptionJpaCustomizedImportBatchItemCompletionRepository(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationStateRepository) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyImportIdCorrelationIdTopLevelParentCorrelationIdFilters(String importId, Collection<String> correlationIdIn, Collection<String> topLevelParentCorrelationIdIn, jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, jakarta.persistence.criteria.CriteriaQuery<?> criteria, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Creates and applies thePredicatesrequired forfindByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String, Collection, Collection).protected jakarta.persistence.criteria.PredicatebuildCorrelationIdInFilter(Collection<String> correlationIdIn, jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildIdFilter(String batchItemCompletionId, jakarta.persistence.criteria.Root<D> root, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildImportIdFilter(jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, String importId, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildTopLevelParentCorrelationIdInFilter(Collection<String> topLevelParentCorrelationIdIn, jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected LongcountByCorrelationIdInOrTopLevelParentIdIn(String importId, Collection<String> correlationIdIn, Collection<String> topLevelParentCorrelationIdIn) Has the same criteria filters asfindByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String, Collection, Collection), and is used for its paging implementation.deleteAllByIdInBatch(List<String> ids) Delete the batch item completions that match the corresponding ids using a single query.findAllBatchItemCompletionIdsByImportIds(@NonNull List<String> importIds, int batchSize) Read a list of batch item completion ids for the provided import ids.findByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String importId, Collection<String> correlationIdIn, Collection<String> topLevelParentCorrelationIdIn) For the givenimportId, returns all batch item completion records which either have aBatchItemCompletion.correlationIdthat matches one of the givencorrelationIdInvalues or aBatchItemCompletion.topLevelParentCorrelationIdthat matches one of the giventopLevelParentCorrelationIdInvalues.Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware>findNotificationReadyMembers(Object lastProcessedNativeId, int pageSize, String messageType, Duration faultThreshold, Class<?> entityType) protected jakarta.persistence.EntityManagerinitializeForIndexing(String batchItemCompletionId, com.broadleafcommerce.data.tracking.core.messaging.search.BatchIndexableType type, List<String> idsToIndex) Deprecated, for removal: This API element is subject to removal in a future version.initializeForIndexing(String batchItemCompletionId, String batchIndexableType, List<String> idsToIndex) If the import is found, atomically initializes theNotificationStateforBatchIndexRequestProducer.TYPE, and renewsImport.getLastUpdated().protected voidinitializeIndexNotificationState(D entity, Instant changeTimestamp, com.broadleafcommerce.data.tracking.core.messaging.search.BatchIndexableType type, List<String> idsToIndex) Deprecated, for removal: This API element is subject to removal in a future version.protected voidinitializeIndexNotificationState(D entity, Instant changeTimestamp, String batchIndexableType, List<String> idsToIndex) Initializes theBatchIndexRequestProducer.TYPEnotification state on the given entity.protected com.broadleafcommerce.common.messaging.notification.domain.NotificationStateinitializeNotificationState(D entity, String notificationStateName, Instant changeTimestamp) booleansetFailedNotificationAttempt(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) booleansetNotificationAcknowledged(Object nativeId, String messageType, int attemptCount, Class<?> entityType)
-
Constructor Details
-
JpaCustomizedImportBatchItemCompletionRepository
public JpaCustomizedImportBatchItemCompletionRepository(com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment notificationStateRepository)
-
-
Method Details
-
getDomainType
- Specified by:
getDomainTypein interfacecom.broadleafcommerce.common.extension.DomainTypeAware
-
save
-
saveAll
-
findByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber
public Stream<D> findByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String importId, @Nullable Collection<String> correlationIdIn, @Nullable Collection<String> topLevelParentCorrelationIdIn) Description copied from interface:CustomizedImportBatchItemCompletionRepositoryFor the givenimportId, returns all batch item completion records which either have aBatchItemCompletion.correlationIdthat matches one of the givencorrelationIdInvalues or aBatchItemCompletion.topLevelParentCorrelationIdthat matches one of the giventopLevelParentCorrelationIdInvalues.Results must be sorted by
BatchItemCompletion.lineNumberin ascending order.- Specified by:
findByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumberin interfaceCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>- Parameters:
importId- the ID of the import which results should be filtered bycorrelationIdIn- a list of correlation IDs that are valid to return in the result (optional)topLevelParentCorrelationIdIn- a list of top level parent correlation IDs that are valid to return in the result (optional)- Returns:
- all records which either have a
BatchItemCompletion.correlationIdthat matches one of the givencorrelationIdInvalues or aBatchItemCompletion.topLevelParentCorrelationIdthat matches one of the giventopLevelParentCorrelationIdInvalues, sorted byBatchItemCompletion.lineNumberin ascending order
-
initializeForIndexing
@Deprecated(since="1.8.2", forRemoval=true) @Transactional("importTransactionManager") public D initializeForIndexing(String batchItemCompletionId, com.broadleafcommerce.data.tracking.core.messaging.search.BatchIndexableType type, List<String> idsToIndex) Deprecated, for removal: This API element is subject to removal in a future version.replaced byinitializeForIndexing(String, String, List)Description copied from interface:CustomizedImportBatchItemCompletionRepositoryIf the import is found, atomically initializes theNotificationStateforBatchIndexRequestProducer.TYPE, and renewsImport.getLastUpdated().- Specified by:
initializeForIndexingin interfaceCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>- Parameters:
batchItemCompletionId- the ID of the BatchItemCompletion instance to modifytype- The indexable type for the importidsToIndex- The repository entity ids to index- Returns:
- the updated
Importif found and updated,nullotherwise
-
initializeForIndexing
@Transactional("importTransactionManager") public D initializeForIndexing(String batchItemCompletionId, String batchIndexableType, List<String> idsToIndex) Description copied from interface:CustomizedImportBatchItemCompletionRepositoryIf the import is found, atomically initializes theNotificationStateforBatchIndexRequestProducer.TYPE, and renewsImport.getLastUpdated().- Specified by:
initializeForIndexingin interfaceCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>- Parameters:
batchItemCompletionId- the ID of the BatchItemCompletion instance to modifybatchIndexableType- The indexable type for the importidsToIndex- The repository entity ids to index- Returns:
- the updated
Importif found and updated,nullotherwise
-
findAllBatchItemCompletionIdsByImportIds
public List<String> findAllBatchItemCompletionIdsByImportIds(@NonNull @NonNull List<String> importIds, int batchSize) Description copied from interface:CustomizedImportBatchItemCompletionRepositoryRead a list of batch item completion ids for the provided import ids.- Specified by:
findAllBatchItemCompletionIdsByImportIdsin interfaceCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>- Parameters:
importIds- the import ids to match batch item completions againstbatchSize- the batch size for results returned- Returns:
- a list of batch item completion ids for the provided import id
-
deleteAllByIdInBatch
Description copied from interface:CustomizedImportBatchItemCompletionRepositoryDelete the batch item completions that match the corresponding ids using a single query.- Specified by:
deleteAllByIdInBatchin interfaceCustomizedImportBatchItemCompletionRepository<D extends JpaBatchItemCompletion>- Parameters:
ids- the list of ids to delete- Returns:
- the number of batch item completions deleted
-
setNotificationAcknowledged
public boolean setNotificationAcknowledged(Object nativeId, String messageType, int attemptCount, Class<?> entityType) - Specified by:
setNotificationAcknowledgedin interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
setFailedNotificationAttempt
public boolean setFailedNotificationAttempt(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) - Specified by:
setFailedNotificationAttemptin interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
findNotificationReadyMembers
public Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware> findNotificationReadyMembers(Object lastProcessedNativeId, int pageSize, String messageType, Duration faultThreshold, Class<?> entityType) - Specified by:
findNotificationReadyMembersin interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
initializeIndexNotificationState
@Deprecated(since="1.8.2", forRemoval=true) protected void initializeIndexNotificationState(D entity, Instant changeTimestamp, com.broadleafcommerce.data.tracking.core.messaging.search.BatchIndexableType type, List<String> idsToIndex) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
entity- the entity to initialize the notification state onchangeTimestamp- the change timestamp to set on the notification statetype- the batch indexable type to set on the messageidsToIndex- the IDs to index to set on the message
-
initializeIndexNotificationState
protected void initializeIndexNotificationState(D entity, Instant changeTimestamp, String batchIndexableType, List<String> idsToIndex) Initializes theBatchIndexRequestProducer.TYPEnotification state on the given entity.- Parameters:
entity- the entity to initialize the notification state onchangeTimestamp- the change timestamp to set on the notification statebatchIndexableType- the batch indexable type to set on the messageidsToIndex- the IDs to index to set on the message
-
initializeNotificationState
-
buildIdFilter
-
countByCorrelationIdInOrTopLevelParentIdIn
protected Long countByCorrelationIdInOrTopLevelParentIdIn(String importId, @Nullable Collection<String> correlationIdIn, @Nullable Collection<String> topLevelParentCorrelationIdIn) Has the same criteria filters asfindByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String, Collection, Collection), and is used for its paging implementation.- Parameters:
importId- the ID of the import which results should be filtered bycorrelationIdIn- a list of correlation IDs that are valid to return in the result (optional)topLevelParentCorrelationIdIn- a list of top level parent correlation IDs that are valid to return in the result (optional)- Returns:
- the number of results expected to be returned by
findByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String, Collection, Collection)
-
applyImportIdCorrelationIdTopLevelParentCorrelationIdFilters
protected void applyImportIdCorrelationIdTopLevelParentCorrelationIdFilters(String importId, @Nullable Collection<String> correlationIdIn, @Nullable Collection<String> topLevelParentCorrelationIdIn, jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, jakarta.persistence.criteria.CriteriaQuery<?> criteria, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) Creates and applies thePredicatesrequired forfindByCorrelationIdInOrTopLevelParentIdInOrderedByLineNumber(String, Collection, Collection).- Parameters:
importId- the ID of the import which results should be filtered bycorrelationIdIn- a list of correlation IDs that are valid to return in the result (optional)topLevelParentCorrelationIdIn- a list of top level parent correlation IDs that are valid to return in the result (optional)batchItemCompletionEntity- the root entity on which the query will be performedcriteria- the criteria query to which the filters will be appliedcriteriaBuilder- the criteria builder used to generate parameters/predicatesparameterValues- a map of parameter names to argument values that will be used to run the query. Any parameter values required to perform the query should be added to this map.
-
buildImportIdFilter
-
buildCorrelationIdInFilter
-
buildTopLevelParentCorrelationIdInFilter
protected jakarta.persistence.criteria.Predicate buildTopLevelParentCorrelationIdInFilter(Collection<String> topLevelParentCorrelationIdIn, jakarta.persistence.criteria.Root<D> batchItemCompletionEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) -
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()
-
initializeForIndexing(String, String, List)