Class DefaultProductConsolidationService

java.lang.Object
com.broadleafcommerce.catalog.service.product.consolidation.DefaultProductConsolidationService
All Implemented Interfaces:
ProductConsolidationService

public class DefaultProductConsolidationService extends Object implements ProductConsolidationService
  • Field Details

  • Constructor Details

    • DefaultProductConsolidationService

      public DefaultProductConsolidationService(List<ProductConsolidationContributor> productConsolidationContributors, ProductService<Product> productSvc, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService, @Nullable com.broadleafcommerce.data.tracking.core.marketplace.service.CommonMarketplaceApplicationCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.MarketplaceApplicationCatalog> marketplaceApplicationCatalogService, cz.jirutka.rsql.parser.RSQLParser rsqlParser)
  • Method Details

    • readAllConsolidatedProducts

      public List<ConsolidatedProduct> readAllConsolidatedProducts(@NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ProductConsolidationService
      Read and consolidate products with their related domain.
      Specified by:
      readAllConsolidatedProducts in interface ProductConsolidationService
      Parameters:
      filters - the RSQL Node used to restrict results, must not be null
      context - context information around sandboxing and multitenant state
      Returns:
      list of products consolidated with relations
    • getBaseCatalogIds

      protected Set<String> getBaseCatalogIds(List<Product> products)
    • getOverrideCatalogIds

      protected Set<String> getOverrideCatalogIds(List<Product> products)
    • consolidateProducts

      protected List<ConsolidatedProduct> consolidateProducts(List<Product> products, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> baseCatalogsById, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Consolidate products with their related domain and translations. This includes both hydrating Product fields and combining external references like CategoryProduct. Any catalog or sandbox overrides made to external references for non-overridden products will generate new placeholder products to store those overrides.
      Parameters:
      products - the products in all explicit context states
      inheritanceLines - the catalog inheritance lines top-down from all of the products
      baseCatalogsById - the map of the found base catalogs with the catalog id as a key
      context - context information surrounding sandboxing/multitenant state
      Returns:
      A list of products combined with all relations including every overridden state
    • processSandboxOwner

      protected void processSandboxOwner(ConsolidatedProduct product)
      Populate the sandbox owner of the product, if in a user sandbox context.
      Parameters:
      product - the ConsolidatedProduct on which to populate the sandbox owner
    • processVendorRef

      protected void processVendorRef(ConsolidatedProduct consolidatedProduct, Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> baseCatalogsById)
      Populate the vendor ref from the Product's catalog.
      Parameters:
      consolidatedProduct - the ConsolidatedProduct on which to populate the vendor ref
      baseCatalogsById - the map of the found base catalogs with the catalog id as a key
    • readMarketplaceApplicationsForCatalogs

      protected List<com.broadleafcommerce.data.tracking.core.tenant.domain.MarketplaceApplicationCatalog> readMarketplaceApplicationsForCatalogs(Set<String> catalogs, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • mapMarketplaceApplicationsByImplicitCatalogsForStatus

      protected Map<String,Set<String>> mapMarketplaceApplicationsByImplicitCatalogsForStatus(List<com.broadleafcommerce.data.tracking.core.tenant.domain.MarketplaceApplicationCatalog> marketplaceApplicationCatalogs, com.broadleafcommerce.data.tracking.core.type.CatalogStatus catalogStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • createPostProcessor

      protected ConsolidatedProductPostProcessor createPostProcessor(List<ConsolidatedProduct> products, 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, Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> allCatalogsById)
    • cleanConsolidatedProductFields

      public void cleanConsolidatedProductFields(List<ConsolidatedProduct> toClean)
      Description copied from interface: ProductConsolidationService
      ConsolidatedProduct consists of many fields, each potentially containing a lot of data. This data is not necessarily always relevant, and can lead to large, bloated API responses. This method is intended to be called as a last-step before returning to the API caller. It takes a fully formed list of ConsolidatedProduct and nullifies or trims any fields that are known to be irrelevant to the caller. This will result in those fields either being omitted in the final JSON output, or greatly reduced in size.
      Specified by:
      cleanConsolidatedProductFields in interface ProductConsolidationService
      Parameters:
      toClean - the instances to clean the fields of
    • cleanConsolidatedProductFields

      protected void cleanConsolidatedProductFields(ConsolidatedProduct toClean)
    • cleanAttributesFields

      protected void cleanAttributesFields(ConsolidatedProduct toClean)
    • cleanProductCharacteristicsFields

      protected void cleanProductCharacteristicsFields(ConsolidatedProduct toClean)
    • cleanProductCharacteristicFields

      protected void cleanProductCharacteristicFields(ProductCharacteristic pc)
    • cleanProductCharacteristicValues

      protected void cleanProductCharacteristicValues(ProductCharacteristic pc)
      In ConsolidatedProduct, we almost never need the full values from the base Characteristic, so we exclude them by default. The only time the base values are relevant are when Characteristic.isConfigurable() is 'true', but even then, we expect that hydration has updated Product.getOptions() to contain an option matching the configurable characteristic, so the data about those values should be available there.
      Parameters:
      pc - the product characteristic whose value-related fields should be cleaned
    • getProductConsolidationContributors

      protected List<ProductConsolidationContributor> getProductConsolidationContributors()
    • getProductSvc

      protected ProductService<Product> getProductSvc()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getCatalogService

      protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getCatalogService()
    • getMarketplaceApplicationCatalogService

      @Nullable protected com.broadleafcommerce.data.tracking.core.marketplace.service.CommonMarketplaceApplicationCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.MarketplaceApplicationCatalog> getMarketplaceApplicationCatalogService()
    • getRsqlParser

      protected cz.jirutka.rsql.parser.RSQLParser getRsqlParser()