Class JpaCustomizedCatalogRepository<D extends JpaTenantCatalog>

java.lang.Object
com.broadleafcommerce.tenant.provider.jpa.repository.JpaCustomizedCatalogRepository<D>
All Implemented Interfaces:
CustomizedCatalogRepository, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedCatalogRepository<D extends JpaTenantCatalog> extends Object implements org.springframework.beans.factory.InitializingBean, CustomizedCatalogRepository
Fragment repository override to handle specialized persistence behavior for JpaTenantCatalog instances.
Author:
Jeff Fischer
  • Field Details

  • Constructor Details

    • JpaCustomizedCatalogRepository

      public JpaCustomizedCatalogRepository(com.broadleafcommerce.data.tracking.jpa.persistence.NativeSqlStrategyManager sqlStrategyManager, cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate,Class<?>> rsqlVisitor, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder builder)
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • setNotificationManager

      @Autowired public void setNotificationManager(@Nullable com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
    • setRepository

      @Autowired @Lazy public void setRepository(@Nullable JpaCatalogRepository<?> repository)
    • readCatalogRelationships

      @NonNull public List<String> readCatalogRelationships(@NonNull @NonNull @NonNull String catalogId)
      Description copied from interface: CustomizedCatalogRepository
      Given a catalog ID, read itself and all catalogs that are descendants (direct or indirect) of it. Order is not guaranteed.

      For example, given catalog IDs A, B, and C, and a catalog graph of A <- B <- C (with A being the parent of B and B the parent of C):

      • a query of 'A' will return A, B, and C
      • a query of 'B' will return B and C
      • a query of 'C' will return C
      Specified by:
      readCatalogRelationships in interface CustomizedCatalogRepository<D extends JpaTenantCatalog>
      Parameters:
      catalogId - The ID of the catalog for which to read descendants.
      Returns:
      A list of catalog IDs for which to read descendants
    • findAllByOwningApplicationIsNullAndHiddenNot

      @NonNull public org.springframework.data.domain.Page<D> findAllByOwningApplicationIsNullAndHiddenNot(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • findAllByContextIdInAndHiddenNot

      @NonNull public List<D> findAllByContextIdInAndHiddenNot(@NonNull List<String> catalogIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • findByTypeAndTenantIdAndOwningApplicationIsNull

      @NonNull public List<D> findByTypeAndTenantIdAndOwningApplicationIsNull(@NonNull String catalogType, @Nullable String tenantId)
      Description copied from interface: CustomizedCatalogRepository
      Finds all catalogs by type and tenant ID that do not belong to an application.
      Specified by:
      findByTypeAndTenantIdAndOwningApplicationIsNull in interface CustomizedCatalogRepository<D extends JpaTenantCatalog>
      Parameters:
      catalogType - the catalog type to filter on
      tenantId - the tenant ID to filter on
      Returns:
      all catalogs by type and tenant ID that do not belong to an application
    • save

      public com.broadleafcommerce.data.tracking.core.Trackable save(com.broadleafcommerce.data.tracking.core.Trackable catalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • saveAll

      public Iterable<com.broadleafcommerce.data.tracking.core.Trackable> saveAll(@NonNull Iterable<com.broadleafcommerce.data.tracking.core.Trackable> trackable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • bulkUpdateApplicationCatalogRefByCatalog

      @Transactional public void bulkUpdateApplicationCatalogRefByCatalog(@NonNull Catalog updatedCatalog)
      Description copied from interface: CustomizedCatalogRepository
      Bulk updates ApplicationCatalogRef.name for entries whose context id matches the given updated catalog id
      Specified by:
      bulkUpdateApplicationCatalogRefByCatalog in interface CustomizedCatalogRepository<D extends JpaTenantCatalog>
      Parameters:
      updatedCatalog - the updated catalog
    • updateChildLevels

      protected void updateChildLevels(D catalog)
      Increment the JpaTenantCatalog.getLevel() values for all children of the passed JpaTenantCatalog.
      Parameters:
      catalog - The parent catalog for whom all children should be update for level values. This includes deep children (i.e. children that are greater than immediate descendants).
    • updateBasedOnParents

      protected D updateBasedOnParents(D catalog, boolean isCreate)
      Update and persist the JpaTenantCatalog.getLevel() value for the passed JpaTenantCatalog by evaluating the JpaTenantCatalog.getParents() and their levels. Generally, this catalog's level should be incremented greater than the max level displayed in the parents.
      Parameters:
      catalog - The catalog whose level value should be updated
      isCreate - Whether or not the passed catalog is new
    • notify

      protected void notify(D catalog)
      Send a message covering the changed catalog state via the PersistenceProducer channel.
      Parameters:
      catalog - The changed catalog instance
    • processChild

      protected void processChild(Map<String,Long> levels, D deepChild)
      Update and persist the JpaTenantCatalog.getLevel() value for the passed JpaTenantCatalog by evaluating the JpaTenantCatalog.getParents() and their levels. Generally, this catalog's level should be incremented greater than the max level displayed in the parents. The passed catalog is considered a deep child of the originally changed catalog.
      Parameters:
      levels - Library of contextIds to levels. Generally used during review of the passed catalog's parents.
      deepChild - A child catalog of the originally changed catalog. This is possibly a deep child (i.e. not an immediate child of the original).