Class DefaultConsolidatedProductPostProcessor

java.lang.Object
com.broadleafcommerce.catalog.service.product.consolidation.DefaultConsolidatedProductPostProcessor
All Implemented Interfaces:
ConsolidatedProductPostProcessor

public class DefaultConsolidatedProductPostProcessor extends Object implements ConsolidatedProductPostProcessor
Author:
Jeff Fischer
  • Constructor Details

    • DefaultConsolidatedProductPostProcessor

      public DefaultConsolidatedProductPostProcessor(List<ConsolidatedProduct> products, ProductService<Product> productService, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, Map<String,Set<String>> marketplaceApplicationsForCatalogs, Map<String,Set<String>> pendingMarketplaceApplicationsForCatalogs)
  • Method Details

    • process

      public void process(ConsolidatedProduct product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      process in interface ConsolidatedProductPostProcessor
    • addFromInheritanceLines

      protected void addFromInheritanceLines(ConsolidatedProduct product, String productCatalog, Map<String,Set<String>> applicationsForCatalogs, Set<String> applicationsToAdd)
    • isSandboxOverride

      protected boolean isSandboxOverride(ConsolidatedProduct reference, ConsolidatedProduct candidate)
      Determine if the candidate product is a more close sandbox version than the reference.
      Parameters:
      reference - The production or sandbox version to use as a base reference
      candidate - The candidate sandbox version to compare against the reference for closeness
      Returns:
      Whether or not the candidate is a closer sandbox version
    • createSandboxOverrideValue

      protected String createSandboxOverrideValue(ConsolidatedProduct override)

      Create the sandbox override value to store as part of ConsolidatedProduct.getSandboxOverrides().

      Note - in this flow, we are expecting ConsolidatedProduct.getSandboxOwner() to only have a value set if it's a USER level change. This would be a deviation from what is stored in the actual entity database table's trk_sandbox_owner column, since that value is always set for all non-production level records.

      Our reasoning is like so:

      • A higher-than-user-level sandbox change (ex: promoted) should be visible to all users, and thus the sandboxOverride value to indicate the presence of such a record should just contain the sandboxId.
      • A user-level sandbox change should only be visible to that specific user, and thus the sandboxOverride value to indicate the presence of such a record should be a combination of sandboxId,userChangeSandboxOwner.

      In the Solr query, we will leverage this information to ensure the overridden (base) record will be excluded if there is either a higher-than-user-level override for it, _or_ there is a user-level override by the current user for it.

      Parameters:
      override - The sandbox overriding product
      Returns:
      a value that can be placed in the overridden (base) record's sandboxOverrides field to indicate the presence of this override record
    • isInheriting

      protected boolean isInheriting(String reference, String candidate)
      Determine if the candidate catalog id represents a catalog that inherits from a catalog represented by the reference catalog id.
      Parameters:
      reference - The id of the reference catalog
      candidate - The id of the candidate catalog
      Returns:
      Whether or not the candidate inherits from the reference
    • isActiveSandboxMember

      protected static boolean isActiveSandboxMember(ConsolidatedProduct member)
    • isSameSandboxContext

      protected boolean isSameSandboxContext(ConsolidatedProduct reference, ConsolidatedProduct candidate)
    • getAllCatalogsById

      protected Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getAllCatalogsById()
      A map of pre-fetched Catalog instances mapped by ID. This should contain all the ContextState.getBaseCatalogId() and ContextState.getOverrideCatalogId() values obtained from products.
    • setAllCatalogsById

      public void setAllCatalogsById(Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> allCatalogsById)
      A map of pre-fetched Catalog instances mapped by ID. This should contain all the ContextState.getBaseCatalogId() and ContextState.getOverrideCatalogId() values obtained from products.