Class DefaultProductDetailsService
java.lang.Object
com.broadleafcommerce.catalog.service.product.commerce.DefaultProductDetailsService
- All Implemented Interfaces:
ProductDetailsService
- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.EmptyNode
-
Constructor Summary
ConstructorDescriptionDefaultProductDetailsService
(List<ProductDetailsContributor> detailsContributors, List<ProductDetailsContextContributor> contextContributors, List<ProductDetailsContextConsolidator> contextConsolidators, ProductService<Product> productService, ProductAssetService<ProductAsset> productAssetService, ProductTagService<ProductTag> productTagService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends ProductDetailsContext>
Collection<T>buildContexts
(@NonNull Collection<T> detailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) BuildsProductDetailsContexts
in response toProductDetailsRequests
.protected <T extends ProductDetailsContext>
ProductDetailsListbuildDetails
(@NonNull Collection<T> detailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out theProductDetails
in response to aProductDetailsRequest
.protected <T extends ProductDetailsContext>
ProductDetailsListbuildDetails
(@NonNull Collection<T> detailsContexts, Set<String> productIdsNotFound, Set<String> productUrisNotFound, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out theProductDetails
in response to aProductDetailsRequest
.getAssetsForProducts
(@NonNull Collection<String> productIds, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets theProductAssets
that match theproductIds
provided.protected List<ProductDetailsContextConsolidator>
protected List<ProductDetailsContextContributor>
protected List<ProductDetailsContributor>
getDetailsForProducts
(Collection<? extends Product> products, Set<String> productIdsNotFound, Set<String> productUrisNotFound, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets theProductDetailsList
for the providedproducts
.protected ProductAssetService<ProductAsset>
getProductDetailsForRequest
(@NonNull ProductDetailsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets aProductDetails
for theProductDetailsRequest
.protected ProductService<Product>
getProductsForUris
(Set<String> productUris, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected ProductTagService<ProductTag>
getTagDetailsForProducts
(Collection<String> productIds, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets theProductTags
for the givenproductIds
.protected com.broadleafcommerce.common.extension.TypeFactory
protected BinaryOperator<Product>
mergeProductsWithSameUris
(List<Product> products) resolveProducts
(@NonNull ProductDetailsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Resolves the base product for the given requests.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.catalog.service.product.commerce.ProductDetailsService
getDetailsForProducts
-
Field Details
-
EMPTY_NODE
protected static final com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.EmptyNode EMPTY_NODE
-
-
Constructor Details
-
DefaultProductDetailsService
public DefaultProductDetailsService(List<ProductDetailsContributor> detailsContributors, List<ProductDetailsContextContributor> contextContributors, List<ProductDetailsContextConsolidator> contextConsolidators, ProductService<Product> productService, ProductAssetService<ProductAsset> productAssetService, ProductTagService<ProductTag> productTagService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
getProductDetailsForRequest
public Optional<ProductDetailsList> getProductDetailsForRequest(@NonNull @NonNull ProductDetailsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsService
Gets aProductDetails
for theProductDetailsRequest
.- Specified by:
getProductDetailsForRequest
in interfaceProductDetailsService
- Parameters:
request
- theProductDetailsRequest
with additional request context for identifying the products for which to retrieve details and defining the how much detail to go into.contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
ProductDetailsList
for theProductDetailsRequests
.
-
getAssetsForProducts
public Map<String,List<ProductAsset>> getAssetsForProducts(@NonNull @NonNull Collection<String> productIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsService
Gets theProductAssets
that match theproductIds
provided. The results are mapped by the product ID.- Specified by:
getAssetsForProducts
in interfaceProductDetailsService
- Parameters:
productIds
- IDs of theProducts
whose assets to fetch.filters
- additional filters to apply in the query.contextInfo
- context information surrounding sandboxing/multitenant state.- Returns:
- the
ProductAssets
that match theproductIds
provided.
-
getDetailsForProducts
public ProductDetailsList getDetailsForProducts(Collection<? extends Product> products, Set<String> productIdsNotFound, Set<String> productUrisNotFound, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsService
Gets theProductDetailsList
for the providedproducts
.- Specified by:
getDetailsForProducts
in interfaceProductDetailsService
- Parameters:
products
-Products
for which to get aProductDetailsList
.productIdsNotFound
- Set of IDs in the request that did not match any productsproductUrisNotFound
- Set of URIs in the request that did not match any productscontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
ProductDetailsList
for theproducts
.
-
getTagDetailsForProducts
public Map<String,List<ProductTagDetail>> getTagDetailsForProducts(Collection<String> productIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsService
Gets theProductTags
for the givenproductIds
. The results are mapped by the owning product ID.- Specified by:
getTagDetailsForProducts
in interfaceProductDetailsService
- Parameters:
productIds
- IDs of theProducts
whose assets to fetch.filters
- additional filters to apply in the query.contextInfo
- context information surrounding sandboxing/multitenant state.- Returns:
- The
ProductTags
for the givenproductIds
.
-
resolveProducts
protected Set<Product> resolveProducts(@NonNull @NonNull ProductDetailsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Resolves the base product for the given requests.- Parameters:
request
- TheProductDetailsRequests
to use to resolve the base productscontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- the resolved base products
-
getProductsForUris
-
mergeProductsWithSameUris
If aSELECTOR
product and another product share the same URL, theSELECTOR
product replaces the other one. If more than oneSELECTOR
product has the same URI it returns the first one.- Parameters:
products
- the list of products to merge- Returns:
- the merged list of products
-
mergeProductsWithSameUris
-
buildContexts
protected <T extends ProductDetailsContext> Collection<T> buildContexts(@NonNull @NonNull Collection<T> detailsContexts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) BuildsProductDetailsContexts
in response toProductDetailsRequests
. This facilitates gathering all of the related catalog entities to the requested products all at once to allow fewer DB calls throughout the process of buildingProductDetails
. It first gathers all of the context info using all of theProductDetailsContextContributors
. Then, it consolidates the context info onto the related entities such as addingProductAssets
to the relatedProducts
using theProductDetailsContextConsolidators
.- Parameters:
detailsContexts
- theProductDetailsContext
with the request context and resolved products populatedcontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- a
ProductDetailsContext
in response to aProductDetailsRequest
.
-
buildDetails
protected <T extends ProductDetailsContext> ProductDetailsList buildDetails(@NonNull @NonNull Collection<T> detailsContexts, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out theProductDetails
in response to aProductDetailsRequest
. It relies on all of theProductDetailsContributors
.- Parameters:
detailsContexts
- TheProductDetailsContexts
created in response to theProductDetailsRequests
. This contains context information and all of the catalog entities related to the requested product pre-fetched and consolidated.contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- the
ProductDetails
in response to aProductDetailsRequest
.
-
buildDetails
protected <T extends ProductDetailsContext> ProductDetailsList buildDetails(@NonNull @NonNull Collection<T> detailsContexts, Set<String> productIdsNotFound, Set<String> productUrisNotFound, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out theProductDetails
in response to aProductDetailsRequest
. It relies on all of theProductDetailsContributors
.- Parameters:
detailsContexts
- TheProductDetailsContexts
created in response to theProductDetailsRequests
. This contains context information and all of the catalog entities related to the requested product pre-fetched and consolidated.productIdsNotFound
- Set of IDs in the request that did not match any productsproductUrisNotFound
- Set of URIs in the request that did not match any productscontextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- the
ProductDetails
in response to aProductDetailsRequest
.
-
getDetailsContributors
-
getContextContributors
-
getContextConsolidators
-
getProductService
-
getProductAssetService
-
getProductTagService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-