Class DefaultProductDetailsService
java.lang.Object
com.broadleafcommerce.catalog.service.product.commerce.DefaultProductDetailsService
- All Implemented Interfaces:
ProductDetailsService
- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.EmptyNode -
Constructor Summary
ConstructorsConstructorDescriptionDefaultProductDetailsService(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) BuildsProductDetailsContextsin response toProductDetailsRequests.protected <T extends ProductDetailsContext>
ProductDetailsListbuildDetails(@NonNull Collection<T> detailsContexts, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out theProductDetailsin 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 theProductDetailsin response to aProductDetailsRequest.getAssetsForProducts(@NonNull Collection<String> productIds, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets theProductAssetsthat match theproductIdsprovided.protected List<ProductDetailsContextConsolidator>protected List<ProductDetailsContextContributor>protected List<ProductDetailsContributor>getDetailsForProducts(Collection<? extends Product> products, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets theProductDetailsListfor the providedproducts.protected ProductAssetService<ProductAsset>getProductDetailsForRequest(@NonNull ProductDetailsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets aProductDetailsfor 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 theProductTagsfor the givenproductIds.protected com.broadleafcommerce.common.extension.TypeFactoryprotected 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.
-
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:ProductDetailsServiceGets aProductDetailsfor theProductDetailsRequest.- Specified by:
getProductDetailsForRequestin interfaceProductDetailsService- Parameters:
request- theProductDetailsRequestwith 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:
ProductDetailsListfor 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:ProductDetailsServiceGets theProductAssetsthat match theproductIdsprovided. The results are mapped by the product ID.- Specified by:
getAssetsForProductsin interfaceProductDetailsService- Parameters:
productIds- IDs of theProductswhose assets to fetch.filters- additional filters to apply in the query.contextInfo- context information surrounding sandboxing/multitenant state.- Returns:
- the
ProductAssetsthat match theproductIdsprovided.
-
getDetailsForProducts
public ProductDetailsList getDetailsForProducts(Collection<? extends Product> products, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ProductDetailsServiceGets theProductDetailsListfor the providedproducts.- Specified by:
getDetailsForProductsin interfaceProductDetailsService- Parameters:
products-Productsfor which to get aProductDetailsList.contextInfo- context information surrounding sandboxing/multitenant state- Returns:
ProductDetailsListfor 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:ProductDetailsServiceGets theProductTagsfor the givenproductIds. The results are mapped by the owning product ID.- Specified by:
getTagDetailsForProductsin interfaceProductDetailsService- Parameters:
productIds- IDs of theProductswhose assets to fetch.filters- additional filters to apply in the query.contextInfo- context information surrounding sandboxing/multitenant state.- Returns:
- The
ProductTagsfor 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- TheProductDetailsRequeststo use to resolve the base productscontextInfo- context information surrounding sandboxing/multitenant state- Returns:
- the resolved base products
-
getProductsForUris
-
mergeProductsWithSameUris
If aSELECTORproduct and another product share the same URL, theSELECTORproduct replaces the other one. If more than oneSELECTORproduct 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) BuildsProductDetailsContextsin 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 addingProductAssetsto the relatedProductsusing theProductDetailsContextConsolidators.- Parameters:
detailsContexts- theProductDetailsContextwith the request context and resolved products populatedcontextInfo- context information surrounding sandboxing/multitenant state- Returns:
- a
ProductDetailsContextin 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 theProductDetailsin response to aProductDetailsRequest. It relies on all of theProductDetailsContributors.- Parameters:
detailsContexts- TheProductDetailsContextscreated 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
ProductDetailsin 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 theProductDetailsin response to aProductDetailsRequest. It relies on all of theProductDetailsContributors.- Parameters:
detailsContexts- TheProductDetailsContextscreated 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 any productscontextInfo- context information surrounding sandboxing/multitenant state- Returns:
- the
ProductDetailsin response to aProductDetailsRequest.
-
getDetailsContributors
-
getContextContributors
-
getContextConsolidators
-
getProductService
-
getProductAssetService
-
getProductTagService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-