Class RelatedProductsCategoryContextContributor
java.lang.Object
com.broadleafcommerce.catalog.service.category.commerce.context.contributor.RelatedProductsCategoryContextContributor
- All Implemented Interfaces:
CategoryDetailsContextContributor
,org.springframework.core.Ordered
public class RelatedProductsCategoryContextContributor
extends Object
implements CategoryDetailsContextContributor
Contributes all of the related
Products
to the CategoryDetailsContext
.- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionRelatedProductsCategoryContextContributor
(CategoryProductService<CategoryProduct> categoryProductService, PromotionalCategoryProductService<PromotionalCategoryProduct> promoCategoryProductService, ProductService<Product> productService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) -
Method Summary
Modifier and TypeMethodDescriptioncontribute
(@NonNull CategoryDetailsContext categoryDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Contributes to the suppliedCategoryDetailsContext
.contributeOtherProductIds
(@NonNull CategoryDetailsContext categoryDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point for contributing other product IDs to the set.protected final CategoryDetailsContext
contributeRelatedCategoryProducts
(@NonNull CategoryDetailsContext categoryDetailsContext, @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductsMap) Contributes the related category products to theCategoryDetailsContext
.protected final CategoryDetailsContext
contributeRelatedProducts
(@NonNull CategoryDetailsContext categoryDetailsContext, @NonNull Set<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Fetches and contributes the related products to theCategoryDetailsContext
.protected final CategoryDetailsContext
contributeRelatedPromoProducts
(@NonNull CategoryDetailsContext categoryDetailsContext, @NonNull Collection<PromotionalCategoryProduct> promotionalProducts) Contributes thePromotionalProductSummaries
to the theCategoryDetailsContext
.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
getCategoryProductIdsToContribute
(@NonNull CategoryDetailsContext categoryDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Collects the IDs of all the products related to theresolved category
through related CategoryProducts.protected CategoryProductService<CategoryProduct>
int
getOrder()
protected ProductService<Product>
protected List<PromotionalCategoryProduct>
getPromotionalProductsToContribute
(@NonNull CategoryDetailsContext categoryDetailsContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Collects all of thePromotionalCategoryProducts
related to the resolved category.protected com.broadleafcommerce.common.extension.TypeFactory
void
setCacheByProductContributionKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductContributionKeyGen)
-
Field Details
-
CACHE_BY_PRODUCT_CONTRIBUTION
- See Also:
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER- See Also:
-
-
Constructor Details
-
RelatedProductsCategoryContextContributor
public RelatedProductsCategoryContextContributor(CategoryProductService<CategoryProduct> categoryProductService, PromotionalCategoryProductService<PromotionalCategoryProduct> promoCategoryProductService, ProductService<Product> productService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, @Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
contribute
public CategoryDetailsContext contribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CategoryDetailsContextContributor
Contributes to the suppliedCategoryDetailsContext
. This should not mutate the inputted context, but return a new one with the new contributions.- Specified by:
contribute
in interfaceCategoryDetailsContextContributor
- Parameters:
categoryDetailsContext
- The context to which to contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- A version of the supplied
CategoryDetailsContext
with the new contributions.
-
getPromotionalProductsToContribute
protected List<PromotionalCategoryProduct> getPromotionalProductsToContribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Collects all of thePromotionalCategoryProducts
related to the resolved category.- Parameters:
categoryDetailsContext
- The context to which to contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- all of the
PromotionalCategoryProducts
related to the resolved category.
-
getCategoryProductIdsToContribute
protected Map<String,org.springframework.data.domain.Page<String>> getCategoryProductIdsToContribute(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Collects the IDs of all the products related to theresolved category
through related CategoryProducts. Returns a map of the product IDs to the IDs of their Categories.Note that only the product IDs are hydrated onto the
CategoryProduct
so there's no point in saving the entire product ref here.- Parameters:
categoryDetailsContext
- The context to which to contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- a map of the product IDs to the IDs of their Categories.
-
contributeOtherProductIds
protected Set<String> contributeOtherProductIds(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point for contributing other product IDs to the set.- Parameters:
categoryDetailsContext
- The context to which to contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- A set of product IDs related to the
resolved category
.
-
contributeRelatedProducts
protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Fetches and contributes the related products to theCategoryDetailsContext
.- Parameters:
categoryDetailsContext
- The context to which to contributeproductIds
- Ids of the Products to fetch and contributecontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- A version of the supplied
CategoryDetailsContext
with the new contributions.
-
contributeRelatedCategoryProducts
protected final CategoryDetailsContext contributeRelatedCategoryProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductsMap) Contributes the related category products to theCategoryDetailsContext
.- Parameters:
categoryDetailsContext
- The context to which to contributecategoryProductsMap
- Map of category IDs to Product IDs for the CategoryProducts to contribute.- Returns:
- A version of the supplied
CategoryDetailsContext
with the new contributions.
-
contributeRelatedPromoProducts
protected final CategoryDetailsContext contributeRelatedPromoProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Collection<PromotionalCategoryProduct> promotionalProducts) Contributes thePromotionalProductSummaries
to the theCategoryDetailsContext
.- Parameters:
categoryDetailsContext
- The context to which to contributepromotionalProducts
-PromotionalCategoryProducts
related to the category- Returns:
- the
CategoryDetailsContext
withCategoryDetailsContext.getRelatedPromotionalProducts()
.
-
getCategoryProductService
-
getPromoCategoryProductService
protected PromotionalCategoryProductService<PromotionalCategoryProduct> getPromoCategoryProductService() -
getProductService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setCacheByProductContributionKeyGen
@Autowired @Qualifier("catalogCacheByProductContribution") public void setCacheByProductContributionKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductContributionKeyGen) - See Also:
-
getCacheByProductContributionKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByProductContributionKeyGen()- See Also:
-