Class DefaultProductHydrationService

java.lang.Object
com.broadleafcommerce.catalog.service.product.hydration.DefaultProductHydrationService
All Implemented Interfaces:
ProductHydrationService

public class DefaultProductHydrationService extends Object implements ProductHydrationService
Author:
Samarth Dhruva (samarthd)
  • Field Details

    • CHARACTERISTIC_VALUE_TRANSLATION_ENTITY_FIELD_PATTERN

      protected static final Pattern CHARACTERISTIC_VALUE_TRANSLATION_ENTITY_FIELD_PATTERN
  • Constructor Details

  • Method Details

    • hydrate

      public Product hydrate(@NonNull @NonNull Product unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService
      Gets the IDs of items that are referenced by the unhydrated product, finds the referenced items in the data store, and then replaces each item reference on the product with the fully-populated representation of the item.

      The class-level javadoc above describes the references which will be hydrated by default.

      Specified by:
      hydrate in interface ProductHydrationService
      Parameters:
      unhydrated - the unhydrated product whose references should be hydrated
      Returns:
      the product after applying the hydration
    • determineReferences

      protected void determineReferences(Product product, ProductReferences references)
      Traverses through the product and populates the references with each referenced ID.
      Parameters:
      product - the product whose references should be examined
      references - each item that the product makes a reference to will be added to this object
    • determineReferences

      protected void determineReferences(@Nullable DataDrivenEnum dataDrivenEnum, ProductReferences references)
    • determineReferences

      protected void determineReferences(IncludedProduct includedProduct, ProductReferences references)
    • determineReferences

      protected void determineReferences(ProductOption productOption, ProductReferences references)
    • determineReferences

      protected void determineReferences(ItemChoice itemChoice, ProductReferences references)
    • determineReferences

      protected void determineReferences(SpecificItemChoice specificChoice, ProductReferences references)
    • determineReferences

      protected void determineReferences(Characteristic characteristic, ProductReferences references)
    • findReferences

      protected ResolvedProductReferences findReferences(ProductReferences references, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Queries for all of the references in references and returns the results.
      Parameters:
      references - all of the references that need to be found in the data store
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the results of querying for the referenced items
    • findOptionTemplateReferences

      protected void findOptionTemplateReferences(ProductReferences references, ResolvedProductReferences resolved)
      Collects the ids of all products and variants referenced by an OptionTemplate. These ids are needed to resolve the products and variants that later will be hydrated onto the product option by applyHydration(SpecificItemChoice, ResolvedProductReferences). This method may resolve the appropriate ids once the ResolvedProductReferences.getOptionTemplatesById() have been resolved.
      Parameters:
      references - the product references to update
      resolved - the object containing the list of resolved option templates
    • findOptionTemplates

      protected void findOptionTemplates(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the OptionTemplates referenced by the product. This looks up templates by ID as specified in the references and populates the resolved object with the results.
      Parameters:
      references - the product references containing the option template IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findProducts

      protected void findProducts(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the Products referenced by the product. This includes products referenced as included products, default products in item choices, or specific item choices. The results are stored in the resolved object.
      Parameters:
      references - the product references containing the product IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findBusinessTypes

      protected void findBusinessTypes(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the BusinessTypes referenced by the product. This fetches the business types by their type key, including their ancestors, to support characteristic inheritance.
      Parameters:
      references - the product references containing the business type keys to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findVariants

      protected void findVariants(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the Variants referenced by the product. This includes variants referenced in included products or item choices.
      Parameters:
      references - the product references containing the variant IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findPrimaryAssets

      protected void findPrimaryAssets(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the primary ProductAssets for the products being hydrated. These assets are typically used to populate the primary asset field on the product.
      Parameters:
      references - the product references containing the product IDs to find primary assets for
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findPrimaryCategoryProducts

      @Nullable protected Map<String,CategoryProduct> findPrimaryCategoryProducts(ProductReferences references, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the primary CategoryProduct relationships for the products. This method also extracts the Category IDs from the found relationships and adds them to the references so the actual categories can be fetched in a subsequent step.
      Parameters:
      references - the product references containing the product IDs to find primary categories for
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a map of product ID to primary category product, or null if none found
    • findCategories

      protected void findCategories(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the Categories referenced by the product. This includes categories referenced in item choices as well as the primary categories identified via findPrimaryCategoryProducts(com.broadleafcommerce.catalog.service.product.hydration.ProductReferences, com.broadleafcommerce.data.tracking.core.context.ContextInfo).
      Parameters:
      references - the product references containing the category IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • resolvePrimaryCategories

      protected void resolvePrimaryCategories(ResolvedProductReferences resolved, @Nullable Map<String,CategoryProduct> primaryCategoryProductsByProductId)
      Resolves the actual Category entities for the products' primary categories. It uses the primaryCategoryProductsByProductId map to link products to their primary category ID, and then looks up the corresponding Category from the resolved categories.
      Parameters:
      resolved - the resolved product references to populate
      primaryCategoryProductsByProductId - the map of product ID to primary category product
    • findDataDrivenEnums

      protected void findDataDrivenEnums(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the DataDrivenEnums referenced by the product. These are typically referenced by custom fields or specific product properties.
      Parameters:
      references - the product references containing the data driven enum IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findProductCharacteristics

      protected void findProductCharacteristics(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the ProductCharacteristics for the products. This method groups the found characteristics by product ID. It also identifies the underlying Characteristic IDs and adds them to the references to be fetched. Additionally, it fetches the inheritance line for characteristics to support narrowing.
      Parameters:
      references - the product references containing the product IDs to find product characteristics for
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • findCharacteristics

      protected void findCharacteristics(ProductReferences references, ResolvedProductReferences resolved, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the Characteristics referenced by the product's ProductCharacteristics. These definitions are used to fully hydrate the product characteristics.
      Parameters:
      references - the product references containing the characteristic IDs to find
      resolved - the resolved product references to populate
      contextInfo - context information surrounding sandboxing and multitenant state
    • applyHydration

      protected Product applyHydration(Product product, ResolvedProductReferences foundItems, List<Variant> variants, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Traverses through the product and replaces each item reference with the fully-populated representation of the reference as found in foundItems. Also goes through the existing variants for the product and hydrates the ProductOptions with all possible option values.

      If a reference was not found, an error will be logged.

      For ProductCharacteristic hydration, this will set the associated Characteristic on any product characteristic already present on the product. It will also add any missing product characteristics based on the associated BusinessType.

      Default values can be synced via Bulk Operations allowing those changes to go through the typical sandboxing change and approval workflows.

      Parameters:
      product - the product whose references should be hydrated
      foundItems - the results of querying for references in the data store
      variants - all variants for under product
      Returns:
      the given product after hydrating its references
    • synchronizeCharacteristics

      protected void synchronizeCharacteristics(Product product)
      Synchronizes the product characteristics. This method encapsulates the logic for syncing configurable, enum type, and placeholder characteristics. This is intended to be called during the hydration process to ensure the in-memory representation of the product is consistent with any changes that have been made in its parent business type (and the business type characteristics) since the product was initially created.

      Note: This requires the product's characteristics to be hydrated, as well as their own ProductCharacteristic.getCharacteristic() property.

      Parameters:
      product - the product whose characteristics should be synchronized
    • synchronizeEnumTypeCharacteristics

      protected void synchronizeEnumTypeCharacteristics(ProductCharacteristic pc, Characteristic characteristic)
      Synchronizes the enum type characteristics for a given product characteristic. For any characteristic that is of an enum type, this method will ensure that the value stored on the characteristic is the actual enum value, along with setting the label and valueType appropriately.
      Parameters:
      pc - the product characteristic to synchronize
      characteristic - the characteristic definition
    • synchronizePlaceholderCharacteristics

      protected void synchronizePlaceholderCharacteristics(ProductCharacteristic pc, Characteristic characteristic)
      Synchronizes the placeholder characteristics for a given product characteristic. This is used when there are changes to the characteristic values on a placeholder characteristic and we need to ensure that the product characteristic values reflect those changes.
      Parameters:
      pc - the product characteristic to synchronize
      characteristic - the characteristic definition
    • hydrateMissingProductCharacteristics

      protected void hydrateMissingProductCharacteristics(Product product, ResolvedProductReferences foundItems, boolean initializeDefaultValues, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Handles hydrating ProductCharacteristics onto a Product. This will look up the Characteristics linked to the product's BusinessType and populate those that are missing.

      This is also responsible for hydrating any configurable product characteristics.

      If the initializeDefaultValues is set, then it will attempt to create ProductCharacteristicValues from the associated CharacteristicValue only if characteristic contains default values and there does not already exist a product characteristic value.

      Parameters:
      product - Product to hydrate
      initializeDefaultValues - whether or not to initialize default Characteristic Values
      foundItems - Related entities referenced by the product to be hydrated onto it.
      Since:
      Catalog Service 2.2.0, Release Train 2.2.0
    • hydrateMissingProductCharacteristics

      protected void hydrateMissingProductCharacteristics(Product product, Set<BusinessTypeCharacteristic> allCharacteristics, ResolvedProductReferences foundItems, boolean initializeDefaultValues, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • hydrateOrAddProductCharacteristic

      protected void hydrateOrAddProductCharacteristic(Product product, BusinessTypeCharacteristic busTypeChar, Set<BusinessTypeCharacteristic> allCharacteristics, ResolvedProductReferences foundItems, boolean initializeDefaultValues, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • deepCloneCharacteristic

      protected Characteristic deepCloneCharacteristic(Characteristic toClone)
    • hydrateExistingProductCharacteristic

      protected void hydrateExistingProductCharacteristic(Product product, Characteristic characteristic, Set<BusinessTypeCharacteristic> allCharacteristics, ResolvedProductReferences foundItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addNewProductCharacteristic

      protected void addNewProductCharacteristic(Product product, Characteristic characteristic, boolean initializeDefaultValues)
    • initializeDefaultCharacteristicValues

      protected void initializeDefaultCharacteristicValues(ProductCharacteristic productCharacteristic, Characteristic characteristic)
    • getProductCharacteristicValue

      protected ProductCharacteristicValue getProductCharacteristicValue(CharacteristicValue characteristicValue)
    • getOptionMatchingCharacteristic

      protected Optional<ProductOption> getOptionMatchingCharacteristic(@NonNull @NonNull Product product, @NonNull @NonNull Characteristic characteristic)
    • syncOptionForConfigurableProductCharacteristic

      protected void syncOptionForConfigurableProductCharacteristic(Product product, Characteristic characteristic)
      Synchronizes a ProductOption to represent a configurable Characteristic.

      If no matching option exists on the Product, a new one is generated. For existing options, this method ensures the underlying AttributeChoice type stays in sync with the characteristic's data type.

      Additionally, for choice-based types (e.g. SELECT, COLOR, SIZE), this will append any missing allowed values. For BOOLEAN types, allowed values are only populated during initial instantiation and are not appended subsequently. For placeholder characteristics, these allowed values are sourced directly from the product's ProductCharacteristicValues rather than the global definition.

      Parameters:
      product - The parent Product whose options should be mutated
      characteristic - The discovered Characteristic from which to sync the ProductOption.
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • shouldAddAllowedValuesToProductOptionFromCharacteristics

      protected boolean shouldAddAllowedValuesToProductOptionFromCharacteristics(String valueChoiceType, AttributeChoice attributeChoice, Characteristic characteristic)
    • getCharacteristicValues

      protected List<CharacteristicValue> getCharacteristicValues(Product product, Characteristic characteristic)
      Retrieves the list of CharacteristicValues to use for generating the AttributeChoiceValues of a ProductOption for a Characteristic. If the characteristic is a placeholder, then the values will be sourced from the ProductCharacteristic on the product instead of the CharacteristicValues on the characteristic.
      Parameters:
      product - The parent Product containing the ProductCharacteristics
      characteristic - The source Characteristic from which to retrieve the CharacteristicValues.
      Returns:
      The list of CharacteristicValues to use for generating AttributeChoiceValues.
      Since:
      Catalog Services 2.3.0, Release Train 2.3.0
    • getProductOptionTypeFromCharacteristic

      protected String getProductOptionTypeFromCharacteristic(@NonNull @NonNull Characteristic characteristic)
      Determines ProductOption type to represent the configurable Characteristic.
      Parameters:
      characteristic - The source configurable Characteristic to generate a ProductOption from.
      Returns:
      The option type to use.
      Since:
      Catalog Service 2.2.0, Release Train 2.2.0
      See Also:
    • getAttributeChoiceTypeFromCharacteristic

      protected String getAttributeChoiceTypeFromCharacteristic(@NonNull @NonNull Characteristic characteristic)
      Determines the AttributeChoice type from the configurable Characteristic.
      Parameters:
      characteristic - The source configurable Characteristic to generate a ProductOption from.
      Returns:
      The choice type to use.
      Since:
      Catalog Service 2.2.0, Release Train 2.2.0
      See Also:
    • getAttributeChoiceValueType

      @Nullable protected String getAttributeChoiceValueType(@NonNull @NonNull String valueType)
      Determines the AttributeChoice.getType() from the CharacteristicValue value type.

      This method is used to handle special cases when the characteristic's value's value type indicates a special type such as COLOR or SIZE.

      Parameters:
      valueType - The source value type to evaluate.
      Returns:
      The choice value type to use, or null if no special type is applicable.
    • setAllowedValueFromCharacteristicValue

      protected void setAllowedValueFromCharacteristicValue(@NonNull @NonNull AttributeChoiceValue allowedValue, @NonNull @NonNull CharacteristicValue characteristicValue, @NonNull @NonNull Characteristic characteristic)
      Extension point for converting complex Characteristic values to strings, which AttributeChoice values require. This is only applicable for configurable Characteristics of type VARIANT_OPTION.
      Parameters:
      allowedValue - The AttributeChoiceValue created to represent the characteristicValue for a configurable Characteristic.
      characteristicValue - The source CharacteristicValue to be converted to a ProductOption's allowedValue.
      characteristic - The parent Characteristic of the characteristicValue.
      Since:
      Catalog Service 2.2.0, Release Train 2.2.0
      See Also:
    • setProductPrimaryAssetIfFound

      protected void setProductPrimaryAssetIfFound(Product product, ResolvedProductReferences foundItems)
    • setProductPrimaryCategoryIfFound

      protected void setProductPrimaryCategoryIfFound(Product product, ResolvedProductReferences foundItems)
    • setProductDataDrivenEnumFieldsIfFound

      protected void setProductDataDrivenEnumFieldsIfFound(Product product, ResolvedProductReferences foundItems)
    • setProductCharacteristicsIfFound

      protected void setProductCharacteristicsIfFound(Product product, ResolvedProductReferences foundItems)
      Sets the ProductCharacteristics on the product if they were found in the foundItems.

      This method filters the found characteristics against the BusinessType associated with the product. Only characteristics that are defined on the business type (or its ancestors) are retained. This ensures that stale or invalid characteristics are not hydrated onto the product.

      Parameters:
      product - the product to set characteristics on
      foundItems - the resolved references containing the found product characteristics and business types
    • handleMultipleProdCharsFoundForSameFieldName

      protected ProductCharacteristic handleMultipleProdCharsFoundForSameFieldName(ProductCharacteristic pc1, ProductCharacteristic pc2, Product product, ResolvedProductReferences foundItems)

      Called in setProductCharacteristicsIfFound(Product, ResolvedProductReferences) to resolve a scenario where the query for product characteristics of a product actually produced multiple results for the same ProductCharacteristic.getFieldName().

      This scenario should not arise at this stage in the flow, since whatever mechanism is responsible for populating ResolvedProductReferences.getProductCharacteristicsByProductId() should have already handled edge cases with deduplicating by field name. See ProductCharacteristicService.readAllByProductContextIdIn(Collection, boolean, ContextInfo) for details on the edge case that can produce this scenario and how it is handled.

      Parameters:
      pc1 - a ProductCharacteristic instance for the same product with the same field name as pc2
      pc2 - a ProductCharacteristic instance for the same product with the same field name as pc1
      product - the product for which these characteristics were found
      foundItems - all found items for the current hydration attempt
      Returns:
      the product characteristic instance to prefer for the current request
    • applyHydration

      protected void applyHydration(ProductCharacteristic productCharacteristic, ResolvedProductReferences foundItems)
    • applyHydration

      protected void applyHydration(@Nullable DataDrivenEnum dataDrivenEnum, String hydrationTarget, ResolvedProductReferences foundItems)
    • applyHydration

      protected void applyHydration(IncludedProduct includedProduct, ResolvedProductReferences foundItems)
    • applyHydration

      @Deprecated protected ProductOption applyHydration(ProductOption option, ResolvedProductReferences foundItems)
    • applyHydration

      protected ProductOption applyHydration(ProductOption option, ResolvedProductReferences foundItems, List<Variant> variants)
      Traverses through the option and replaces each item reference with the fully-populated representation of the reference as found in foundItems.

      If a reference was not found, an error will be logged.

      Parameters:
      option - the product option whose references should be hydrated
      foundItems - the results of querying for references in the data store
      Returns:
      the given option after hydrating its references
    • hydrateAllowedValues

      protected void hydrateAllowedValues(AttributeChoice attributeChoice, Map<String,Set<String>> allOptionValues)
    • applyHydration

      protected void applyHydration(ItemChoice itemChoice, ResolvedProductReferences foundItems)
    • applyHydration

      protected void applyHydration(SpecificItemChoice specificChoice, ResolvedProductReferences foundItems)
    • hydrate

      public org.springframework.data.domain.Page<Product> hydrate(@NonNull @NonNull org.springframework.data.domain.Page<Product> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService
      Gets the IDs of items that are referenced by each product, finds the referenced items in the data store, and then replaces each item reference on the product with the fully-populated representation of the item.

      A page of those hydrated products is then returned.

      The class-level javadoc above describes the references which will be hydrated by default.

      Specified by:
      hydrate in interface ProductHydrationService
      Parameters:
      unhydrated - the page of unhydrated products whose references should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a page of the hydrated products
    • hydratePrimaryAssets

      public org.springframework.data.domain.Page<Product> hydratePrimaryAssets(org.springframework.data.domain.Page<Product> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService
      Specifically finds and hydrates the Product.primaryAsset of each product in the given page.
      Specified by:
      hydratePrimaryAssets in interface ProductHydrationService
      Parameters:
      unhydrated - the page of unhydrated products whose primary assets should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a page of the hydrated products
    • hydrate

      public ProductOption hydrate(ProductOption unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService
      Gets the IDs of items that are referenced by the unhydrated option, finds the referenced items in the data store, and then replaces each item reference on the option with the fully-populated representation of the item.

      The class-level javadoc above describes the references which will be hydrated by default.

      Specified by:
      hydrate in interface ProductHydrationService
      Parameters:
      unhydrated - the unhydrated option whose references should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the option after applying the hydration
    • hydrateCharacteristics

      public <T extends Product> List<T> hydrateCharacteristics(List<T> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService
      Specifically finds and hydrates the Product.getCharacteristics() of each product in the given list, including any default values. By default, the hydration logic is complex,and involves populating missing product characteristics, modifying product options, and performing value narrowing on characteristics.
      Specified by:
      hydrateCharacteristics in interface ProductHydrationService
      Parameters:
      unhydrated - the list of unhydrated products whose characteristics should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a list of the hydrated products
      See Also:
    • applyCharacteristicHydration

      public <T extends Product> List<T> applyCharacteristicHydration(List<T> unhydrated, ResolvedProductReferences resolvedProductReferences, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ProductHydrationService

      This is essentially the same as ProductHydrationService.hydrateCharacteristics(List, ContextInfo), but the caller is able to provide their own pre-fetched data to use for the complex hydration rather than having this service do the fetching. This can be particularly helpful in non-narrowed context environments like search reindexing, where the typical queries run by the hydration service will fail.

      Specified by:
      applyCharacteristicHydration in interface ProductHydrationService
      Parameters:
      unhydrated - the list of unhydrated products whose characteristics should be hydrated
      resolvedProductReferences - the pre-fetched data that should be used for hydration. At a minimum, this must include: ResolvedProductReferences.getProductCharacteristicsByProductId() (for all the product characteristics), ResolvedProductReferences.getBusinessTypeByTypeKey() (for all the product business types), ResolvedProductReferences.getCharacteristicsById() (the base characteristic for each product characteristic), and ResolvedProductReferences.getProductCharacteristicsFromInheritanceLineByProductId() (for all the product characteristics).
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a list of the hydrated products
      See Also:
    • computeCharacteristicsOverriddenHint

      protected void computeCharacteristicsOverriddenHint(Product productWithChars, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Parameters:
      productWithChars - the product instance with product characteristics already hydrated
      contextInfo - the current context info
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
      See Also:
    • isAnyProdCharsOverriddenInCurrentCatalogContext

      protected boolean isAnyProdCharsOverriddenInCurrentCatalogContext(Product productWithChars, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Reports whether any of the Product.getCharacteristics() have been overridden directly in the current ContextRequest. This is particularly relevant to drive Product.getCharacteristicsOverriddenHint().
      Parameters:
      productWithChars - the product with characteristics already hydrated
      contextInfo - the current context against which to evaluate override state
      Returns:
      whether any of the product's characteristics are directly overridden in the current catalog context
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • containsAnyProductionLevelFieldChanges

      protected boolean containsAnyProductionLevelFieldChanges(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      Parameters:
      contextState - the context state of an entity
      Returns:
      whether the entity contains any production-level field changes that would indicate it is a production-level override record
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • isOverrideDefinedInCurrentCatalogContext

      protected boolean isOverrideDefinedInCurrentCatalogContext(ProductCharacteristic pcToEvaluate, Product parentProduct, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Parameters:
      pcToEvaluate - the product characteristic whose override state should be evaluated. This should already have been validated as being a record that contains production-level field changes.
      parentProduct - the parent product for which this characteristic was loaded
      contextInfo - the current context against which to evaluate override state
      Returns:
      whether the pcToEvaluate has been directly overridden in the current catalog context (as opposed to being inherited from a parent catalog)
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • getOverrideOrBaseCatalogId

      protected String getOverrideOrBaseCatalogId(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      Parameters:
      contextState - the context state to extract catalog information from
      Returns:
      the ContextState.getOverrideCatalogId() if set, else ContextState.getCatalog() ID. This allows us to clearly identify the catalog in which the entity actually resides. See ContextStateBuilder to understand where these fields come from
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • isOverrideCatalogAtLeafLevelInCurrentAppContext

      protected boolean isOverrideCatalogAtLeafLevelInCurrentAppContext(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest appContextRequest)
      Parameters:
      contextState - entity context state that's already validated as having a value for ContextState.getOverrideCatalogId()
      appContextRequest - application context request
      Returns:
      whether ContextState.getOverrideCatalogId() matches one of the application's implicit catalogs
      Since:
      Catalog Service 2.3.0, Release Train 2.3.0
    • getAllCharacteristicsForBusinessType

      protected Set<BusinessTypeCharacteristic> getAllCharacteristicsForBusinessType(@Nullable BusinessType businessType)
      Gathers all unique BusinessTypeCharacteristic from a given BusinessType and all of its ancestors. Note - the input to this method should have already been appropriately hydrated with its ancestor characteristics - see ResolvedProductReferences.getBusinessTypeByTypeKey() and how it is computed. As a result, this method simply grabs the values from BusinessType.getCharacteristics() directly and converts them to a Set representation.
      Parameters:
      businessType - the business type to process
      Returns:
      a set of all characteristics for the business type hierarchy
    • hydrateDefaultVariant

      protected void hydrateDefaultVariant(ResolvedProductReferences foundItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getProductIds

      protected Set<String> getProductIds(List<Map.Entry<String,String>> partition)
    • getSkus

      protected Set<String> getSkus(List<Map.Entry<String,String>> partition)
    • buildSkuAndProductIdKey

      protected String buildSkuAndProductIdKey(String productId, String sku)
    • getProductService

      protected ProductService<Product> getProductService()
    • getProductAssetService

      protected ProductAssetService<ProductAsset> getProductAssetService()
    • getVariantService

      protected VariantService<Variant> getVariantService()
    • getCategoryService

      protected CategoryService<Category> getCategoryService()
    • getCategoryProductService

      protected CategoryProductService<CategoryProduct> getCategoryProductService()
    • getDataDrivenEnumService

      protected DataDrivenEnumService<DataDrivenEnum> getDataDrivenEnumService()
    • getTypeFactory

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

      protected OptionTemplateService<OptionTemplate> getOptionTemplateService()
    • setOptionTemplateService

      @Autowired public void setOptionTemplateService(OptionTemplateService<OptionTemplate> optionTemplateService)
    • getBusinessTypeService

      protected BusinessTypeService<BusinessType> getBusinessTypeService()
    • setBusinessTypeService

      @Autowired public void setBusinessTypeService(BusinessTypeService<BusinessType> businessTypeService)
    • getCharacteristicService

      protected CharacteristicService<Characteristic> getCharacteristicService()
    • setCharacteristicService

      @Autowired public void setCharacteristicService(CharacteristicService<Characteristic> characteristicService)
    • getCharacteristicHydrationService

      protected CharacteristicHydrationService getCharacteristicHydrationService()
    • setCharacteristicHydrationService

      @Autowired public void setCharacteristicHydrationService(CharacteristicHydrationService characteristicHydrationService)
    • getSkuGenerationService

      protected SkuGenerationService<Variant> getSkuGenerationService()
    • setSkuGenerationService

      @Autowired public void setSkuGenerationService(SkuGenerationService<Variant> skuGenerationService)
    • setTranslationEntityService

      @Autowired public void setTranslationEntityService(com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> translationEntityService)
    • getTranslationEntityService

      protected com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> getTranslationEntityService()
    • setProductCharacteristicService

      @Autowired public void setProductCharacteristicService(ProductCharacteristicService<ProductCharacteristic> productCharacteristicService)
    • getProductCharacteristicService

      protected ProductCharacteristicService<ProductCharacteristic> getProductCharacteristicService()
    • setObjectDeepCopyUtility

      @Autowired public void setObjectDeepCopyUtility(ObjectDeepCopyUtility objectDeepCopyUtility)
    • getObjectDeepCopyUtility

      protected ObjectDeepCopyUtility getObjectDeepCopyUtility()
    • setCharacteristicsTranslationService

      @Autowired public void setCharacteristicsTranslationService(CharacteristicsTranslationService characteristicsTranslationService)
    • getCharacteristicsTranslationService

      protected CharacteristicsTranslationService getCharacteristicsTranslationService()