Class DefaultProductHydrationService
java.lang.Object
com.broadleafcommerce.catalog.service.product.hydration.DefaultProductHydrationService
- All Implemented Interfaces:
ProductHydrationService
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultProductHydrationService(ProductService<Product> productService, ProductAssetService<ProductAsset> productAssetService, VariantService<Variant> variantService, CategoryService<Category> categoryService, CategoryProductService<CategoryProduct> categoryProductService, DataDrivenEnumService<DataDrivenEnum> dataDrivenEnumService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyHydration(DataDrivenEnum dataDrivenEnum, String hydrationTarget, ResolvedProductReferences foundItems) protected voidapplyHydration(IncludedProduct includedProduct, ResolvedProductReferences foundItems) protected voidapplyHydration(ItemChoice itemChoice, ResolvedProductReferences foundItems) protected ProductOptionapplyHydration(ProductOption option, ResolvedProductReferences foundItems) Traverses through theoptionand replaces each item reference with the fully-populated representation of the reference as found infoundItems.protected voidapplyHydration(SpecificItemChoice specificChoice, ResolvedProductReferences foundItems) protected ProductapplyHydration(Product product, ResolvedProductReferences foundItems) Traverses through theproductand replaces each item reference with the fully-populated representation of the reference as found infoundItems.protected voiddetermineReferences(DataDrivenEnum dataDrivenEnum, ProductReferences references) protected voiddetermineReferences(IncludedProduct includedProduct, ProductReferences references) protected voiddetermineReferences(ItemChoice itemChoice, ProductReferences references) protected voiddetermineReferences(ProductOption productOption, ProductReferences references) protected voiddetermineReferences(SpecificItemChoice specificChoice, ProductReferences references) protected voiddetermineReferences(Product product, ProductReferences references) Traverses through theproductand populates thereferenceswith each referenced ID.protected ResolvedProductReferencesfindReferences(ProductReferences references, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Queries for all of the references inreferencesand returns the results.protected CategoryProductService<CategoryProduct>protected CategoryService<Category>protected DataDrivenEnumService<DataDrivenEnum>protected ProductAssetService<ProductAsset>protected ProductService<Product>protected com.broadleafcommerce.common.extension.TypeFactoryprotected VariantService<Variant>hydrate(@NonNull Product unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the IDs of items that are referenced by theunhydratedproduct, 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(@NonNull 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.hydrate(ProductOption unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the IDs of items that are referenced by theunhydratedoption, 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.protected voidhydrateDefaultVariant(ResolvedProductReferences foundItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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 theProduct.primaryAssetof each product in the given page.protected voidsetProductDataDrivenEnumFieldsIfFound(Product product, ResolvedProductReferences foundItems) protected voidsetProductPrimaryAssetIfFound(Product product, ResolvedProductReferences foundItems) protected voidsetProductPrimaryCategoryIfFound(Product product, ResolvedProductReferences foundItems)
-
Constructor Details
-
DefaultProductHydrationService
public DefaultProductHydrationService(ProductService<Product> productService, ProductAssetService<ProductAsset> productAssetService, VariantService<Variant> variantService, CategoryService<Category> categoryService, CategoryProductService<CategoryProduct> categoryProductService, DataDrivenEnumService<DataDrivenEnum> dataDrivenEnumService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
hydrate
public Product hydrate(@NonNull @NonNull Product unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductHydrationServiceGets the IDs of items that are referenced by theunhydratedproduct, 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:
hydratein interfaceProductHydrationService- Parameters:
unhydrated- the unhydrated product whose references should be hydrated- Returns:
- the product after applying the hydration
-
determineReferences
Traverses through theproductand populates thereferenceswith each referenced ID.- Parameters:
product- the product whose references should be examinedreferences- each item that theproductmakes a reference to will be added to this object
-
determineReferences
protected void determineReferences(@Nullable DataDrivenEnum dataDrivenEnum, ProductReferences references) -
determineReferences
-
determineReferences
-
determineReferences
-
determineReferences
-
findReferences
protected ResolvedProductReferences findReferences(ProductReferences references, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Queries for all of the references inreferencesand returns the results.- Parameters:
references- all of the references that need to be found in the data storecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the results of querying for the referenced items
-
applyHydration
Traverses through theproductand replaces each item reference with the fully-populated representation of the reference as found infoundItems.If a reference was not found, an error will be logged.
- Parameters:
product- the product whose references should be hydratedfoundItems- the results of querying for references in the data store- Returns:
- the given
productafter hydrating its references
-
setProductPrimaryAssetIfFound
-
setProductPrimaryCategoryIfFound
protected void setProductPrimaryCategoryIfFound(Product product, ResolvedProductReferences foundItems) -
setProductDataDrivenEnumFieldsIfFound
protected void setProductDataDrivenEnumFieldsIfFound(Product product, ResolvedProductReferences foundItems) -
applyHydration
protected void applyHydration(@Nullable DataDrivenEnum dataDrivenEnum, String hydrationTarget, ResolvedProductReferences foundItems) -
applyHydration
protected void applyHydration(IncludedProduct includedProduct, ResolvedProductReferences foundItems) -
applyHydration
Traverses through theoptionand replaces each item reference with the fully-populated representation of the reference as found infoundItems.If a reference was not found, an error will be logged.
- Parameters:
option- the product option whose references should be hydratedfoundItems- the results of querying for references in the data store- Returns:
- the given
optionafter hydrating its references
-
applyHydration
-
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:ProductHydrationServiceGets 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:
hydratein interfaceProductHydrationService- Parameters:
unhydrated- the page of unhydrated products whose references should be hydratedcontextInfo- 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:ProductHydrationServiceSpecifically finds and hydrates theProduct.primaryAssetof each product in the given page.- Specified by:
hydratePrimaryAssetsin interfaceProductHydrationService- Parameters:
unhydrated- the page of unhydrated products whose primary assets should be hydratedcontextInfo- 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:ProductHydrationServiceGets the IDs of items that are referenced by theunhydratedoption, 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:
hydratein interfaceProductHydrationService- Parameters:
unhydrated- the unhydrated option whose references should be hydratedcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the option after applying the hydration
-
hydrateDefaultVariant
protected void hydrateDefaultVariant(ResolvedProductReferences foundItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getProductService
-
getProductAssetService
-
getVariantService
-
getCategoryService
-
getCategoryProductService
-
getDataDrivenEnumService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-