Class BreadcrumbsProductDetailsContributor
java.lang.Object
com.broadleafcommerce.catalog.service.product.commerce.contributor.BreadcrumbsProductDetailsContributor
- All Implemented Interfaces:
ProductDetailsContributor
,org.springframework.core.Ordered
public class BreadcrumbsProductDetailsContributor
extends Object
implements ProductDetailsContributor
This contributor is responsible for the
ProductDetails'
breadcrumbs
.- Author:
- Nathan Moore (nathandmoore), Samarth Dhruva (samarthd)
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionBreadcrumbsProductDetailsContributor
(CategoryProductService<CategoryProduct> categoryProductService, CategoryService<Category> categoryService, CategoryAncestryHydrationService categoryAncestryHydrationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<Breadcrumb>
buildBreadcrumbsForProductWithPrimaryCategory
(@NonNull ProductDetails product, @NonNull CategoryAncestorList primaryCategoryAndAncestry) Generates the expected list ofBreadcrumbs
for a product which was found to have a primary category.<D extends ProductDetails,
C extends ProductDetailsContext>
Collection<D>contribute
(@NonNull Collection<D> productDetailsList, @NonNull Collection<C> productDetailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Contributes to the suppliedProductDetails
.protected Breadcrumb
createCrumbForCategory
(Category ancestor) protected Breadcrumb
createCrumbForProduct
(ProductDetails product) protected Map<String,
CategoryAncestorList> getAncestriesByCategoryId
(Collection<String> categoryIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of category ids, finds those categories and their entire ancestries in the data store.protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected CategoryAncestryHydrationService
protected CategoryProductService<CategoryProduct>
protected CategoryService<Category>
int
getOrder()
protected Map<String,
CategoryAncestorList> getPrimaryCategoryAncestryByProductId
(Set<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of product ids, finds the primary category of each product along with that category's ancestors.getPrimaryCategoryIdsByProductId
(Set<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of product ids, finds the id of the primary category for each product.protected com.broadleafcommerce.common.extension.TypeFactory
void
setCacheByBreadcrumbProductContributionKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByBreadcrumbProductContributionKeyGen)
-
Field Details
-
CACHE_BY_BREADCRUMB_PRODUCT_CONTRIBUTION
- See Also:
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER- See Also:
-
-
Constructor Details
-
BreadcrumbsProductDetailsContributor
public BreadcrumbsProductDetailsContributor(CategoryProductService<CategoryProduct> categoryProductService, CategoryService<Category> categoryService, CategoryAncestryHydrationService categoryAncestryHydrationService, 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 <D extends ProductDetails,C extends ProductDetailsContext> Collection<D> contribute(@NonNull @NonNull Collection<D> productDetailsList, @NonNull @NonNull Collection<C> productDetailsContexts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsContributor
Contributes to the suppliedProductDetails
. This should not mutate the inputted details, but return a new one with the new contributions.- Specified by:
contribute
in interfaceProductDetailsContributor
- Parameters:
productDetailsList
- The details to which to contributeproductDetailsContexts
- The context containing information that may be important for contributors such as active price lists.contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- An version of the supplied
ProductDetails
with the new contributions.
-
getPrimaryCategoryAncestryByProductId
protected Map<String,CategoryAncestorList> getPrimaryCategoryAncestryByProductId(Set<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of product ids, finds the primary category of each product along with that category's ancestors.- Parameters:
productIds
- the ids of products whose primary category and ancestors should be foundcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a map from product id to a
CategoryAncestorList
object containing its primary category and that category's ancestors. If a product did not have a designated primary category, the referenced category was not found in the data store, or there was an error fetching the category's ancestry, there will not be an entry for it in the result map.
-
getPrimaryCategoryIdsByProductId
protected Map<String,String> getPrimaryCategoryIdsByProductId(Set<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of product ids, finds the id of the primary category for each product.- Parameters:
productIds
- the ids of products whose primary category id should be found in the data storecontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a map from product id to the id of its primary category. If a product did not have a designated primary category, there will not be an entry for it in the result map.
-
getAncestriesByCategoryId
protected Map<String,CategoryAncestorList> getAncestriesByCategoryId(Collection<String> categoryIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a collection of category ids, finds those categories and their entire ancestries in the data store.- Parameters:
categoryIds
- the ids of categories to find (along with their ancestors)contextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a map from category id to a
CategoryAncestorList
object containing the hydrated category itself and its ancestors. If a category was not found in the data store or there was an error fetching its ancestry, there will not be an entry for it in the result map. - See Also:
-
buildBreadcrumbsForProductWithPrimaryCategory
protected List<Breadcrumb> buildBreadcrumbsForProductWithPrimaryCategory(@NonNull @NonNull ProductDetails product, @NonNull @NonNull CategoryAncestorList primaryCategoryAndAncestry) Generates the expected list ofBreadcrumbs
for a product which was found to have a primary category.- Parameters:
product
- the product for which breadcrumbs are being createdprimaryCategoryAndAncestry
- the primary category of the product along with its ancestors- Returns:
- a list of breadcrumbs starting with the top-level category ancestor and ending with the primary category followed by the product itself
-
createCrumbForProduct
-
createCrumbForCategory
-
getCategoryProductService
-
getCategoryService
-
getCategoryAncestryHydrationService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setCacheByBreadcrumbProductContributionKeyGen
@Autowired @Qualifier("catalogCacheByBreadcrumbProductContribution") public void setCacheByBreadcrumbProductContributionKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen cacheByBreadcrumbProductContributionKeyGen) - See Also:
-
getCacheByBreadcrumbProductContributionKeyGen
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getCacheByBreadcrumbProductContributionKeyGen()- See Also:
-