Interface ProductHydrationService

All Known Implementing Classes:
DefaultProductHydrationService

public interface ProductHydrationService
Responsible for performing simple hydration of references within Products by querying for those references and populating their full values.

By default, the following references will be hydrated in hydrate(Product, ContextInfo) and hydrate(Page, ContextInfo):

For a much more comprehensive and deeper aggregation of product data, see ProductConsolidationService.

Author:
Samarth Dhruva (samarthd)
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Product>
    List<T>
    applyCharacteristicHydration(List<T> unhydrated, ResolvedProductReferences resolvedProductReferences, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    This is essentially the same as 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.
    hydrate(ProductOption unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    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.
    hydrate(Product unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    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.
    org.springframework.data.domain.Page<Product>
    hydrate(org.springframework.data.domain.Page<Product> unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    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.
    <T extends Product>
    List<T>
    hydrateCharacteristics(List<T> unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Specifically finds and hydrates the Product.getCharacteristics() of each product in the given list, including any default values.
    org.springframework.data.domain.Page<Product>
    hydratePrimaryAssets(org.springframework.data.domain.Page<Product> unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Specifically finds and hydrates the Product.primaryAsset of each product in the given page.
  • Method Details

    • hydrate

      Product hydrate(Product unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      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.

      Parameters:
      unhydrated - the unhydrated product whose references should be hydrated
      Returns:
      the product after applying the hydration
    • hydrate

      org.springframework.data.domain.Page<Product> hydrate(org.springframework.data.domain.Page<Product> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      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.

      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

      org.springframework.data.domain.Page<Product> hydratePrimaryAssets(org.springframework.data.domain.Page<Product> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specifically finds and hydrates the Product.primaryAsset of each product in the given page.
      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

      ProductOption hydrate(ProductOption unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      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.

      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

      <T extends Product> List<T> hydrateCharacteristics(List<T> unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      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.
      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

      <T extends Product> List<T> applyCharacteristicHydration(List<T> unhydrated, ResolvedProductReferences resolvedProductReferences, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)

      This is essentially the same as 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.

      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
      Since:
      Catalog Services 2.3.0, Release Train 2.3.0
      See Also: