Class ExternalCatalogSearchProvider<T extends Product>
- java.lang.Object
-
- com.broadleafcommerce.catalogbrowse.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.catalogbrowse.service.provider.external.search.ExternalCatalogSearchProvider<T>
-
- All Implemented Interfaces:
CatalogSearchProvider<T>
@ConfigurationProperties("broadleaf.catalogbrowse.catalogsearchprovider") public class ExternalCatalogSearchProvider<T extends Product> extends AbstractExternalProvider implements CatalogSearchProvider<T>- Author:
- Nathan Moore (nathandmoore)
-
-
Constructor Summary
Constructors Constructor Description ExternalCatalogSearchProvider(org.springframework.web.reactive.function.client.WebClient catalogSearchWebClient, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PricingProvider browsePricingProvider, CatalogProvider browseCatalogProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Map<String,Object>>convertSuggestionsToMap(@NonNull List<T> suggestions)protected List<T>convertSuggestionsToProducts(@NonNull List<Map<String,Object>> suggestions)protected PricingProvidergetBrowsePricingProvider()protected CatalogProvidergetCatalogProvider()protected org.springframework.web.reactive.function.client.WebClientgetCatalogSearchWebClient()protected List<Map<String,Object>>getHydratedProductSuggestionsPricing(@NonNull List<Map<String,Object>> suggestions, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Hydrates pricing on product type-ahead suggetsions.SearchResponse<T>getSearchResults(@NonNull CatalogSearchRequest request)Performs a search for the provided request.StringgetSearchUri()The context path to the catalog search endpointStringgetServiceClient()The service client to use when calling search.TypeAheadResponsegetSuggestions(@NonNull CatalogTypeAheadRequest request)Gets suggestions for a search typeahead component based on the request.StringgetSuggestUri()The context path to the catalog search suggestions endpointprotected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()StringgetUrl()The base url for an external search service:https://localhost:8447/search.protected voidhydrateProductAssets(@NonNull Collection<T> products, org.springframework.util.MultiValueMap<String,String> parameters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Makes an additional call to theCatalogProviderto hydrateAssetsfor the search results.protected voidhydrateProductPricing(@NonNull Collection<T> products, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Hydrates pricing onto the results of a search request.protected voidhydrateProductTags(@NonNull Collection<T> products, org.springframework.util.MultiValueMap<String,String> parameters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Makes an additional call to theCatalogProviderto hydrateProductTagsfor the search results.booleanisHydrateAssets()Determines whether an additional call to Catalog Services should be made to hydrate the search results with additional product assets.voidsetHydrateAssets(boolean hydrateAssets)Determines whether an additional call to Catalog Services should be made to hydrate the search results with additional product assets.protected voidsetProductPriceInfos(@NonNull Collection<T> products, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Ensures that allProductswith simple prices have those replaced with aPriceInfo.voidsetSearchUri(String searchUri)The context path to the catalog search endpointvoidsetServiceClient(String serviceClient)The service client to use when calling search.voidsetSuggestUri(String suggestUri)The context path to the catalog search suggestions endpointvoidsetUrl(String url)The base url for an external search service:https://localhost:8447/search.-
Methods inherited from class com.broadleafcommerce.catalogbrowse.service.provider.external.AbstractExternalProvider
getHeaders, getMapper
-
-
-
-
Constructor Detail
-
ExternalCatalogSearchProvider
public ExternalCatalogSearchProvider(@Qualifier("catalogSearchWebClient") org.springframework.web.reactive.function.client.WebClient catalogSearchWebClient, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PricingProvider browsePricingProvider, CatalogProvider browseCatalogProvider)
-
-
Method Detail
-
getSearchResults
public SearchResponse<T> getSearchResults(@NonNull @NonNull CatalogSearchRequest request)
Description copied from interface:CatalogSearchProviderPerforms a search for the provided request.- Specified by:
getSearchResultsin interfaceCatalogSearchProvider<T extends Product>- Parameters:
request- All of the relevant information to be used to retrieve search results.- Returns:
- The
SearchResponsewith results for the request.
-
getSuggestions
public TypeAheadResponse getSuggestions(@NonNull @NonNull CatalogTypeAheadRequest request)
Description copied from interface:CatalogSearchProviderGets suggestions for a search typeahead component based on the request.- Specified by:
getSuggestionsin interfaceCatalogSearchProvider<T extends Product>- Parameters:
request- All of the relevant information to be used to retrieve type-ahead suggestions.- Returns:
- The
TypeAheadResponsewith the results for the request.
-
getHydratedProductSuggestionsPricing
protected List<Map<String,Object>> getHydratedProductSuggestionsPricing(@NonNull @NonNull List<Map<String,Object>> suggestions, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Hydrates pricing on product type-ahead suggetsions.- Parameters:
suggestions- Suggestions to be hydratedpriceContext-PriceContextfrom the original request containing general pricing infopriceInfoContext-PriceInfoContextfrom the original request containing info specific for gettingPriceInfossuch as prefetchedPriceLists.contextInfo-ContextInfofrom the original request containing tenant and sandbox info- Returns:
- Hydrated product suggestions
-
hydrateProductPricing
protected void hydrateProductPricing(@NonNull @NonNull Collection<T> products, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Hydrates pricing onto the results of a search request.- Parameters:
products- The products from theSearchResponseto be hydratedpriceContext-PriceContextfrom the original request containing general pricing infopriceInfoContext-PriceInfoContextfrom the original request containing info specific for gettingPriceInfossuch as prefetchedPriceLists.contextInfo-ContextInfofrom the original request containing tenant and sandbox info
-
setProductPriceInfos
protected void setProductPriceInfos(@NonNull @NonNull Collection<T> products, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Ensures that allProductswith simple prices have those replaced with aPriceInfo.- Parameters:
products- Search results whose contents to ensure to have aPriceInfosinstead of simple prices.
-
hydrateProductAssets
protected void hydrateProductAssets(@NonNull @NonNull Collection<T> products, @Nullable org.springframework.util.MultiValueMap<String,String> parameters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Makes an additional call to theCatalogProviderto hydrateAssetsfor the search results.This hydration is gated by
isHydrateAssets().- Parameters:
products- The search results.parameters- Additional parameters to include the request like filterscontextInfo- Additional sandbox and multitenant state.
-
hydrateProductTags
protected void hydrateProductTags(@NonNull @NonNull Collection<T> products, @Nullable org.springframework.util.MultiValueMap<String,String> parameters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Makes an additional call to theCatalogProviderto hydrateProductTagsfor the search results.- Parameters:
products- The search results.parameters- Additional parameters to include the request like filterscontextInfo- Additional sandbox and multitenant state.
-
convertSuggestionsToProducts
protected List<T> convertSuggestionsToProducts(@NonNull @NonNull List<Map<String,Object>> suggestions)
-
convertSuggestionsToMap
protected List<Map<String,Object>> convertSuggestionsToMap(@NonNull @NonNull List<T> suggestions)
-
getCatalogSearchWebClient
protected org.springframework.web.reactive.function.client.WebClient getCatalogSearchWebClient()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
getBrowsePricingProvider
protected PricingProvider getBrowsePricingProvider()
-
getCatalogProvider
protected CatalogProvider getCatalogProvider()
-
getUrl
public String getUrl()
The base url for an external search service:https://localhost:8447/search.
-
setUrl
public void setUrl(String url)
The base url for an external search service:https://localhost:8447/search.
-
getSearchUri
public String getSearchUri()
The context path to the catalog search endpoint
-
setSearchUri
public void setSearchUri(String searchUri)
The context path to the catalog search endpoint
-
getSuggestUri
public String getSuggestUri()
The context path to the catalog search suggestions endpoint
-
setSuggestUri
public void setSuggestUri(String suggestUri)
The context path to the catalog search suggestions endpoint
-
isHydrateAssets
public boolean isHydrateAssets()
Determines whether an additional call to Catalog Services should be made to hydrate the search results with additional product assets.
-
setHydrateAssets
public void setHydrateAssets(boolean hydrateAssets)
Determines whether an additional call to Catalog Services should be made to hydrate the search results with additional product assets.
-
getServiceClient
public String getServiceClient()
The service client to use when calling search. Default is "catalogbrowseclient"
-
setServiceClient
public void setServiceClient(String serviceClient)
The service client to use when calling search. Default is "catalogbrowseclient"
-
-