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, @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Fetches and contributes the related products to theCategoryDetailsContext
.protected final CategoryDetailsContext
contributeRelatedProducts
(@NonNull CategoryDetailsContext categoryDetailsContext, @NonNull Set<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.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.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.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser
protected Map<String,
ProductSummary> getRuleBaseProducts
(@NonNull CategoryDetailsContext categoryDetailsContext, @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the resolvedCategory
isCategoryProductMembershipType.RULE_BASED
, then this method fetches all theProducts
that match the rule.protected com.broadleafcommerce.common.extension.TypeFactory
void
setCacheByProductContributionKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByProductContributionKeyGen) void
setCacheByRuleProductContributionKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByRuleProductContributionKeyGen) void
setRsqlFilterParser
(com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser rsqlFilterParser)
-
Field Details
-
CACHE_BY_PRODUCT_CONTRIBUTION
- See Also:
-
CACHE_BY_RULE_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 Category IDs to a page of product IDs.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
@Deprecated protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
contributeRelatedProducts
protected final CategoryDetailsContext contributeRelatedProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Set<String> productIds, @NonNull @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductIds, @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 contributecategoryProductIds
- Mapping of Category Ids to a page of ProductscontextInfo
- 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()
.
-
getRuleBaseProducts
protected Map<String,ProductSummary> getRuleBaseProducts(@NonNull @NonNull CategoryDetailsContext categoryDetailsContext, @NonNull @NonNull Map<String, org.springframework.data.domain.Page<String>> categoryProductIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the resolvedCategory
isCategoryProductMembershipType.RULE_BASED
, then this method fetches all theProducts
that match the rule.- Parameters:
categoryDetailsContext
- The contexts to which to contributecontextInfo
- Additional sandbox and tenancy info- Returns:
- A mapping of the related products by their ids.
-
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() -
setRsqlFilterParser
@Autowired public void setRsqlFilterParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser rsqlFilterParser) -
getRsqlFilterParser
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.RSQLFilterParser getRsqlFilterParser() -
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:
-
setCacheByRuleProductContributionKeyGen
@Autowired @Qualifier("catalogCacheByRuleProductContribution") public void setCacheByRuleProductContributionKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByRuleProductContributionKeyGen) - See Also:
-
getCacheByRuleProductContributionKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByRuleProductContributionKeyGen()- See Also:
-
contributeRelatedProducts(CategoryDetailsContext, Set, Map, ContextInfo)
.