Class JpaCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
java.lang.Object
com.broadleafcommerce.sandbox.provider.jpa.repository.nontrackable.JpaCustomizedChangeDeployRepository<D>
- All Implemented Interfaces:
com.broadleafcommerce.common.extension.DomainTypeAware
,com.broadleafcommerce.common.messaging.notification.NotificationStateRepository
,com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
,CustomizedChangeDeployRepository<D>
public class JpaCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
extends Object
implements CustomizedChangeDeployRepository<D>, com.broadleafcommerce.common.messaging.notification.NotificationStateRepositoryFragment
- Author:
- Jeff Fischer
-
Constructor Summary
ConstructorsConstructorDescriptionJpaCustomizedChangeDeployRepository
(com.broadleafcommerce.data.tracking.jpa.messaging.NotificationStateValueUpdater notificationFragment, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.RSQLVisitorHolder<?> rsqlVisitorHolder, org.springframework.transaction.support.TransactionTemplate template) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<jakarta.persistence.criteria.Predicate>
buildUpdateValsPredicates
(String changeDeployId, List<String> whereStates, List<String> whereStatuses, jakarta.persistence.criteria.CriteriaQuery<?> criteria, jakarta.persistence.criteria.Root<D> root, jakarta.persistence.criteria.CriteriaBuilder builder, Map<String, Object> params, boolean vendorNarrowing, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) cleanupBatch
(String startingId, List<ChangeStatusType> detectStatuses, List<ChangeState> detectStates, ChangeStatusType targetStatus, ChangeState targetState, List<ChangeStatusType> summaryDetectStatuses, List<ChangeState> summaryDetectStates, Object source) Check a bag of ChangeDeploy entities for completion state.Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware>
findNotificationReadyMembers
(Object lastProcessedNativeId, int pageSize, String messageType, Duration faultThreshold, Class<?> entityType) protected com.broadleafcommerce.common.extension.TypeFactory
protected JpaVendorNarrowingQueryCustomizer
protected void
insertNotificationStateMatchingValues
(@NonNull String containerId, @NonNull String name, @NonNull Class<?> entityType, @NonNull Map<String, Object> values) readByIdAndArchivedNot
(String id, boolean archived, boolean vendorNarrowing, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) TakesChangeDeploy.getArchived()
into account when retrieving a deployment with the given ID.org.springframework.data.domain.Page<D>
readPageByApplicationAndStateAndArchivedNot
(String applicationId, @NonNull String state, Boolean archived, cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable pageable) Retrieve a page of records filtered by application and stateorg.springframework.data.domain.Page<D>
readPageBySandboxAndStateAndArchivedNot
(@NonNull String sandbox, @NonNull String state, Boolean archived, cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable pageable, boolean vendorNarrowing, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve a page of records filtered by sandbox and stateboolean
removeFromAffectedVendors
(String deployId, String vendorRef) Atomically removes the givenvendorRef
fromChangeDeploy.getAffectedVendorRefs()
of the givendeployId
if present.setAffectedVendors
(@NonNull String deployId, boolean affectsNonVendorData, @NonNull Set<String> affectedVendorRefs) Atomically finds theChangeDeploy
with the givendeployId
and sets itsChangeDeploy.isAffectsNonVendorData()
andChangeDeploy.getAffectedVendorRefs()
to the provided values.void
setEventPublisher
(org.springframework.context.ApplicationEventPublisher eventPublisher) boolean
setFailedNotificationAttempt
(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) void
setJdbcTemplate
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) boolean
setNotificationAcknowledged
(Object nativeId, String messageType, int attemptCount, Class<?> entityType) void
setProperties
(CompletionCleanupProperties properties) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) void
setVendorNarrowingQueryCustomizerProvider
(org.springframework.beans.factory.ObjectProvider<JpaVendorNarrowingQueryCustomizer> vendorNarrowingQueryCustomizerProvider) If vendor processing is enabled, this bean will be injected and and used for vendor narrowing.updateVals
(@NonNull String changeDeployId, List<String> whereStates, List<String> whereStatuses, String notificationStateName, Map<String, Object> vals) Update the fields for a record matching the idupdateVals
(@NonNull String changeDeployId, List<String> whereStates, List<String> whereStatuses, String notificationStateName, Map<String, Object> vals, boolean vendorNarrowing, boolean insertNotificationStateIfMissing, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the fields for a record matching the idupdateVals
(@NonNull String changeDeployId, List<String> whereStates, List<String> whereStatuses, String notificationStateName, Map<String, Object> vals, boolean vendorNarrowing, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the fields for a record matching the id
-
Constructor Details
-
JpaCustomizedChangeDeployRepository
public JpaCustomizedChangeDeployRepository(com.broadleafcommerce.data.tracking.jpa.messaging.NotificationStateValueUpdater notificationFragment, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.RSQLVisitorHolder<?> rsqlVisitorHolder, org.springframework.transaction.support.TransactionTemplate template)
-
-
Method Details
-
save
-
saveAll
-
getDomainType
- Specified by:
getDomainType
in interfacecom.broadleafcommerce.common.extension.DomainTypeAware
-
readByIdAndArchivedNot
public Optional<D> readByIdAndArchivedNot(String id, boolean archived, boolean vendorNarrowing, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedChangeDeployRepository
TakesChangeDeploy.getArchived()
into account when retrieving a deployment with the given ID.- Specified by:
readByIdAndArchivedNot
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
id
- ID of the deployment to retrievearchived
-ChangeDeploy.getArchived()
value to not matchvendorNarrowing
- whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabledcontextInfo
- context information about sandboxing and multitenant state- Returns:
- A
ChangeDeploy
matching the given ID and not matching the given archived status
-
updateVals
public Optional<D> updateVals(@NonNull @NonNull String changeDeployId, @Nullable List<String> whereStates, @Nullable List<String> whereStatuses, @Nullable String notificationStateName, Map<String, Object> vals) Description copied from interface:CustomizedChangeDeployRepository
Update the fields for a record matching the id- Specified by:
updateVals
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
changeDeployId
- The id requested to mutatewhereStates
- TheChangeState
values for whichChangeDeploy.getState()
can matchwhereStatuses
- The list ofChangeStatusType
values for whichChangeDeploy.getStatus()
should match one or more of, can be emptynotificationStateName
- (optional) the name of the notification state that should be used to filter in the notification states array. This is relevant for update operations that want to modify a specific notification state with update values specified inupdateVals
vals
- Map of field to value changes to make to the ChangeSummaryGroup instance, cannot be empty- Returns:
- An
Optional
containing the updated record if an update was performed,Optional.empty()
otherwise
-
updateVals
public Optional<D> updateVals(@NonNull @NonNull String changeDeployId, @Nullable List<String> whereStates, @Nullable List<String> whereStatuses, @Nullable String notificationStateName, Map<String, Object> vals, boolean vendorNarrowing, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedChangeDeployRepository
Update the fields for a record matching the id
Calling this method is the same as calling
CustomizedChangeDeployRepository.updateVals(String, List, List, String, Map, boolean, boolean, ContextInfo)
, but with theinsertNotificationStateIfMissing
parameter set tofalse
.- Specified by:
updateVals
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
changeDeployId
- The id requested to mutatewhereStates
- TheChangeState
values for whichChangeDeploy.getState()
can matchwhereStatuses
- The list ofChangeStatusType
values for whichChangeDeploy.getStatus()
should match one or more of, can be emptynotificationStateName
- (optional) the name of the notification state that should be used to filter in the notification states array. This is relevant for update operations that want to modify a specific notification state with update values specified inupdateVals
vals
- Map of field to value changes to make to the ChangeSummaryGroup instance, cannot be emptyvendorNarrowing
- whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabledcontextInfo
- context information about sandboxing and multitenant state- Returns:
- An
Optional
containing the updated record if an update was performed,Optional.empty()
otherwise
-
updateVals
public Optional<D> updateVals(@NonNull @NonNull String changeDeployId, @Nullable List<String> whereStates, @Nullable List<String> whereStatuses, @Nullable String notificationStateName, Map<String, Object> vals, boolean vendorNarrowing, boolean insertNotificationStateIfMissing, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedChangeDeployRepository
Update the fields for a record matching the id- Specified by:
updateVals
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
changeDeployId
- The id requested to mutatewhereStates
- TheChangeState
values for whichChangeDeploy.getState()
can matchwhereStatuses
- The list ofChangeStatusType
values for whichChangeDeploy.getStatus()
should match one or more of, can be emptynotificationStateName
- (optional) the name of the notification state that should be used to filter in the notification states array. This is relevant for update operations that want to modify a specific notification state with update values specified inupdateVals
vals
- Map of field to value changes to make to the ChangeSummaryGroup instance, cannot be emptyvendorNarrowing
- whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabledinsertNotificationStateIfMissing
- ifvals
target a notification state andnotificationStateName
is provided, this flag determines whether the flow will newly insert the notification state if it does not already exist in the datastore. In other words, when this flag is false, the flow will only try to update an existing notification state with the provided details invals
. When this flag istrue
, if the update attempt is unsuccessful because the notification state is missing, the flow will attempt to newly insert that state into the datastore.contextInfo
- context information about sandboxing and multitenant state- Returns:
- An
Optional
containing the updated record if an update was performed,Optional.empty()
otherwise - See Also:
-
insertNotificationStateMatchingValues
-
setNotificationAcknowledged
public boolean setNotificationAcknowledged(Object nativeId, String messageType, int attemptCount, Class<?> entityType) - Specified by:
setNotificationAcknowledged
in interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
setFailedNotificationAttempt
public boolean setFailedNotificationAttempt(Object nativeId, String messageType, int attemptCount, Instant nextAttempt, Class<?> entityType, boolean stopped) - Specified by:
setFailedNotificationAttempt
in interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
findNotificationReadyMembers
public Stream<com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware> findNotificationReadyMembers(@Nullable Object lastProcessedNativeId, int pageSize, String messageType, Duration faultThreshold, Class<?> entityType) - Specified by:
findNotificationReadyMembers
in interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateRepository
-
readPageByApplicationAndStateAndArchivedNot
public org.springframework.data.domain.Page<D> readPageByApplicationAndStateAndArchivedNot(@Nullable String applicationId, @NonNull @NonNull String state, @Nullable Boolean archived, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable pageable) Description copied from interface:CustomizedChangeDeployRepository
Retrieve a page of records filtered by application and state- Specified by:
readPageByApplicationAndStateAndArchivedNot
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
applicationId
- TheChangeDeploy.getApplication()
valuke to filter results bystate
- TheChangeDeploy.getState()
value to filter results byarchived
-ChangeDeploy.getArchived()
value to not matchfilters
- the RSQLNode
used to restrict resultpageable
- The page setup information- Returns:
- The page of records
-
readPageBySandboxAndStateAndArchivedNot
public org.springframework.data.domain.Page<D> readPageBySandboxAndStateAndArchivedNot(@NonNull @NonNull String sandbox, @NonNull @NonNull String state, @Nullable Boolean archived, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, boolean vendorNarrowing, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedChangeDeployRepository
Retrieve a page of records filtered by sandbox and state- Specified by:
readPageBySandboxAndStateAndArchivedNot
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
sandbox
- TheChangeDeploy.getSandbox()
value to filter results bystate
- TheChangeDeploy.getState()
value to filter results byarchived
-ChangeDeploy.getArchived()
value to not matchfilters
- the RSQLNode
used to restrict resultpageable
- The page setup informationvendorNarrowing
- whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabledcontextInfo
- context information about sandboxing and multitenant state- Returns:
- The page of records
-
setAffectedVendors
@Transactional("sandboxTransactionManager") @Nullable public D setAffectedVendors(@NonNull @NonNull String deployId, boolean affectsNonVendorData, @NonNull @NonNull Set<String> affectedVendorRefs) Description copied from interface:CustomizedChangeDeployRepository
Atomically finds theChangeDeploy
with the givendeployId
and sets itsChangeDeploy.isAffectsNonVendorData()
andChangeDeploy.getAffectedVendorRefs()
to the provided values.Internally, this method should rely on data-store locking mechanisms to protect against concurrent mutations.
- Specified by:
setAffectedVendors
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
deployId
- the ID of the deploy to updateaffectsNonVendorData
- the new value to set forChangeDeploy.isAffectsNonVendorData()
affectedVendorRefs
- the new value to set forChangeDeploy.getAffectedVendorRefs()
. Cannot be null, but can be empty.- Returns:
- the updated deployment if the update was successful,
null
otherwise
-
removeFromAffectedVendors
@Transactional("sandboxTransactionManager") public boolean removeFromAffectedVendors(String deployId, String vendorRef) Description copied from interface:CustomizedChangeDeployRepository
Atomically removes the givenvendorRef
fromChangeDeploy.getAffectedVendorRefs()
of the givendeployId
if present.- Specified by:
removeFromAffectedVendors
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
deployId
- the ID of the deploy to updatevendorRef
- the vendor ref to remove fromChangeDeploy.getAffectedVendorRefs()
- Returns:
true
if the removal was successful,false
otherwise
-
cleanupBatch
public String cleanupBatch(@Nullable String startingId, List<ChangeStatusType> detectStatuses, List<ChangeState> detectStates, ChangeStatusType targetStatus, ChangeState targetState, List<ChangeStatusType> summaryDetectStatuses, List<ChangeState> summaryDetectStates, Object source) Description copied from interface:CustomizedChangeDeployRepository
Check a bag of ChangeDeploy entities for completion state. If complete, update status and state.- Specified by:
cleanupBatch
in interfaceCustomizedChangeDeployRepository<D extends JpaChangeDeploy>
- Parameters:
startingId
- The ChangeDeploy entity id that represents the start of the collection of entities to check. The size of the collection is determined byCompletionCleanupProperties.getCleanupBatchSize()
.detectStatuses
- The list of statuses to match. One of these statuses must match an entity status to be considered as part of the cleanup routine.detectStates
- The list of states to match. One of these statuses must match an entity state to be considered as part of the cleanup routine.targetStatus
- The status to set on one or more entities if determined to be completetargetState
- The state to set on one or more entities if determined to be completesummaryDetectStatuses
- The list of associated ChangeSummary statuses to NOT match. Associated ChangeSummary instances must not be in any of these statuses for the related ChangeDeploy to be considered complete.summaryDetectStates
- The list of associated ChangeSummary states to NOT match. Associated ChangeSummary instances must not be in any of these states for the related ChangeDeploy to be considered complete.source
- The specific cleanup service instance making the call- Returns:
- The last ChangeDeploy entity id used as part of the executed batch. This value is
interesting to provide as the
startingId
for subsequent calls to this method when performing a paged style execution approach. May be null if no values were found, or if fewer than the configured batch size were found.
-
getVendorNarrowingQueryCustomizer
-
buildUpdateValsPredicates
protected List<jakarta.persistence.criteria.Predicate> buildUpdateValsPredicates(String changeDeployId, @Nullable List<String> whereStates, @Nullable List<String> whereStatuses, jakarta.persistence.criteria.CriteriaQuery<?> criteria, jakarta.persistence.criteria.Root<D> root, jakarta.persistence.criteria.CriteriaBuilder builder, Map<String, Object> params, boolean vendorNarrowing, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
setVendorNarrowingQueryCustomizerProvider
@Autowired public void setVendorNarrowingQueryCustomizerProvider(org.springframework.beans.factory.ObjectProvider<JpaVendorNarrowingQueryCustomizer> vendorNarrowingQueryCustomizerProvider) If vendor processing is enabled, this bean will be injected and and used for vendor narrowing.We leverage
ObjectProvider
here since we want both optional and lazy injection. This is to avoid a situation where the query customizer creates a circular dependency. -
setJdbcTemplate
@Autowired @Qualifier("summaryCompletionJdbcTemplate") public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) -
setProperties
-
setEventPublisher
@Autowired public void setEventPublisher(@Nullable org.springframework.context.ApplicationEventPublisher eventPublisher) -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-