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 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

      @Transactional("sandboxTransactionManager") public Object save(Object entity)
    • saveAll

      @Transactional("sandboxTransactionManager") public List<Object> saveAll(@NonNull @NonNull Iterable<?> entities)
    • getDomainType

      public Class<D> getDomainType()
      Specified by:
      getDomainType in interface com.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
      Takes ChangeDeploy.getArchived() into account when retrieving a deployment with the given ID.
      Specified by:
      readByIdAndArchivedNot in interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      id - ID of the deployment to retrieve
      archived - ChangeDeploy.getArchived() value to not match
      vendorNarrowing - whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabled
      contextInfo - 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 interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      changeDeployId - The id requested to mutate
      whereStates - The ChangeState values for which ChangeDeploy.getState() can match
      whereStatuses - The list of ChangeStatusType values for which ChangeDeploy.getStatus() should match one or more of, can be empty
      notificationStateName - (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 in updateVals
      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 the insertNotificationStateIfMissing parameter set to false.

      Specified by:
      updateVals in interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      changeDeployId - The id requested to mutate
      whereStates - The ChangeState values for which ChangeDeploy.getState() can match
      whereStatuses - The list of ChangeStatusType values for which ChangeDeploy.getStatus() should match one or more of, can be empty
      notificationStateName - (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 in updateVals
      vals - Map of field to value changes to make to the ChangeSummaryGroup instance, cannot be empty
      vendorNarrowing - whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabled
      contextInfo - 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 interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      changeDeployId - The id requested to mutate
      whereStates - The ChangeState values for which ChangeDeploy.getState() can match
      whereStatuses - The list of ChangeStatusType values for which ChangeDeploy.getStatus() should match one or more of, can be empty
      notificationStateName - (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 in updateVals
      vals - Map of field to value changes to make to the ChangeSummaryGroup instance, cannot be empty
      vendorNarrowing - whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabled
      insertNotificationStateIfMissing - if vals target a notification state and notificationStateName 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 in vals. When this flag is true, 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

      protected void insertNotificationStateMatchingValues(@NonNull @NonNull String containerId, @NonNull @NonNull String name, @NonNull @NonNull Class<?> entityType, @NonNull @NonNull Map<String,Object> values)
    • setNotificationAcknowledged

      public boolean setNotificationAcknowledged(Object nativeId, String messageType, int attemptCount, Class<?> entityType)
      Specified by:
      setNotificationAcknowledged in interface com.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 interface com.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 interface com.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 interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      applicationId - The ChangeDeploy.getApplication() valuke to filter results by
      state - The ChangeDeploy.getState() value to filter results by
      archived - ChangeDeploy.getArchived() value to not match
      filters - the RSQL Node used to restrict result
      pageable - 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 interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      sandbox - The ChangeDeploy.getSandbox() value to filter results by
      state - The ChangeDeploy.getState() value to filter results by
      archived - ChangeDeploy.getArchived() value to not match
      filters - the RSQL Node used to restrict result
      pageable - The page setup information
      vendorNarrowing - whether or not to filter results based on the current authentication's vendor restrictions if vendor processing is enabled
      contextInfo - 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 the ChangeDeploy with the given deployId and sets its ChangeDeploy.isAffectsNonVendorData() and ChangeDeploy.getAffectedVendorRefs() to the provided values.

      Internally, this method should rely on data-store locking mechanisms to protect against concurrent mutations.

      Specified by:
      setAffectedVendors in interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      deployId - the ID of the deploy to update
      affectsNonVendorData - the new value to set for ChangeDeploy.isAffectsNonVendorData()
      affectedVendorRefs - the new value to set for ChangeDeploy.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 given vendorRef from ChangeDeploy.getAffectedVendorRefs() of the given deployId if present.
      Specified by:
      removeFromAffectedVendors in interface CustomizedChangeDeployRepository<D extends JpaChangeDeploy>
      Parameters:
      deployId - the ID of the deploy to update
      vendorRef - the vendor ref to remove from ChangeDeploy.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 interface CustomizedChangeDeployRepository<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 by CompletionCleanupProperties.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 complete
      targetState - The state to set on one or more entities if determined to be complete
      summaryDetectStatuses - 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

      @Nullable protected JpaVendorNarrowingQueryCustomizer 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

      @Autowired public void setProperties(CompletionCleanupProperties properties)
    • 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)