Class DefaultMerchCatalogService
- java.lang.Object
-
- com.hybris.merchandising.service.impl.DefaultMerchCatalogService
-
- All Implemented Interfaces:
MerchCatalogService
public class DefaultMerchCatalogService extends java.lang.Object implements MerchCatalogService
DefaultMerchCatalogService is a default implementation ofMerchCatalogService, used to make catalog requests for Merch v2 support.
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseSiteServicebaseSiteServiceprotected static java.lang.StringCATALOG_IDprotected static java.lang.StringCATALOG_VERSIONprotected AbstractUrlResolver<CategoryModel>categoryUrlResolverprotected static java.lang.StringDEFAULT_QUERY_TEMPLATEprotected static java.lang.StringEXECUTEprotected FacetSearchServicefacetSearchServiceprotected FieldNameTranslatorfieldNameTranslatorprotected Converter<ProductIndexContainer,Product>merchProductConverterprotected SearchQueryCurrencyResolversearchQueryCurrencyResolverprotected SearchQueryLanguageResolversearchQueryLanguageResolver
-
Constructor Summary
Constructors Constructor Description DefaultMerchCatalogService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringcreateActionForIndexOperation(IndexOperation indexOperation)createActionForIndexOperation is a method for retrieving the action to use when sending to Merchandising for a givenIndexOperation.protected java.util.Map<java.lang.String,IndexedPropertyInfo>createIndexedPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery)Method used to retrieve a map of configured key value pairs for handling mapping between Solr internal data modelprotected IndexedPropertyInfocreateIndexedPropertyInfo(SearchQuery searchQuery, IndexedProperty indexedProperty)Helper method to populate IndexedPropertyInfo based on configured underprotected java.util.Map<java.lang.String,FacetField>createMerchFacetPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery)createMerchFacetPropertiesMapping is a method for mapping facets to output for consumption by Merchandising.protected java.util.Map<java.lang.String,java.lang.String>createMerchPropertiesMapping(java.util.List<MerchPropertyModel> merchProperties, java.util.Map<java.lang.String,IndexedPropertyInfo> indexedPropertiesMapping)createMerchPropertiesMapping is a method for mapping from the configured list ofMerchPropertyModelto the indexed properties within Solr.protected SearchQuerycreateSearchQuery(IndexerBatchContext indexerBatchContext, MerchProductDirectoryConfigModel productDirectory)Method is used to generate an instance ofSearchQueryto query Solr to retrieve updated product information.protected java.lang.StringextractPropName(AbstractMerchPropertyModel merchProp)protected java.lang.StringextractPropTranslatedName(AbstractMerchPropertyModel merchProp)protected BaseSiteServicegetBaseSiteService()Gets the configuredBaseSiteService, used to set the current site for the request.java.util.List<CategoryHierarchy>getCategories(MerchProductDirectoryConfigModel config)Retrieves a list ofCategoryHierarchyobjects representing the category hierarchy.java.util.List<CategoryHierarchy>getCategories(java.lang.String baseSite, java.lang.String catalogId, java.lang.String catalogVersionId, java.lang.String baseCatalogPageUrl)getCategories is a method for retrieving the category hierarchy (including subcategories).AbstractUrlResolver<CategoryModel>getCategoryUrlResolver()Retrieves the configured URL resolver forCategoryModel.java.util.List<Product>getProducts(IndexerBatchContext indexerBatchContext, MerchProductDirectoryConfigModel merchProductDirectoryConfigModel)Method to retrieve all the associated toIndexerBatchContext.protected java.lang.StringgetTranslatedFieldName(SearchQuery searchQuery, IndexedProperty indexedProperty)protected java.lang.StringgetUrl(CategoryModel category, java.lang.String baseCategoryUrl)getUrl resolves the URL for a providedCategoryModel.protected booleanisToSynchronize(java.util.List<CatalogVersionModel> catalogVersionsToExport, InputDocument document)Method to determine whether a given document is for the Online or Staging catalog.protected voidprocessSubCategories(CategoryHierarchy toPopulate, CategoryModel category, boolean root, java.lang.String categoryUrl)processSubCategories is a method for taking a category model and recursively processing its sub categories.voidsetBaseSiteService(BaseSiteService baseSiteService)Sets the configuredBaseSiteService, used to set the current site for the request.voidsetCategoryUrlResolver(AbstractUrlResolver<CategoryModel> categoryUrlResolver)Sets the configured URL resolver forCategoryModel.voidsetFacetSearchService(FacetSearchService facetSearchService)voidsetFieldNameTranslator(FieldNameTranslator fieldNameTranslator)voidsetMerchProductConverter(Converter<ProductIndexContainer,Product> merchProductConverter)voidsetSearchQueryCurrencyResolver(SearchQueryCurrencyResolver searchQueryCurrencyResolver)voidsetSearchQueryLanguageResolver(SearchQueryLanguageResolver searchQueryLanguageResolver)
-
-
-
Field Detail
-
DEFAULT_QUERY_TEMPLATE
protected static final java.lang.String DEFAULT_QUERY_TEMPLATE
- See Also:
- Constant Field Values
-
EXECUTE
protected static final java.lang.String EXECUTE
- See Also:
- Constant Field Values
-
CATALOG_VERSION
protected static final java.lang.String CATALOG_VERSION
- See Also:
- Constant Field Values
-
CATALOG_ID
protected static final java.lang.String CATALOG_ID
- See Also:
- Constant Field Values
-
facetSearchService
protected FacetSearchService facetSearchService
-
fieldNameTranslator
protected FieldNameTranslator fieldNameTranslator
-
searchQueryLanguageResolver
protected SearchQueryLanguageResolver searchQueryLanguageResolver
-
searchQueryCurrencyResolver
protected SearchQueryCurrencyResolver searchQueryCurrencyResolver
-
baseSiteService
protected BaseSiteService baseSiteService
-
categoryUrlResolver
protected AbstractUrlResolver<CategoryModel> categoryUrlResolver
-
merchProductConverter
protected Converter<ProductIndexContainer,Product> merchProductConverter
-
-
Method Detail
-
getCategories
public java.util.List<CategoryHierarchy> getCategories(java.lang.String baseSite, java.lang.String catalogId, java.lang.String catalogVersionId, java.lang.String baseCatalogPageUrl)
getCategories is a method for retrieving the category hierarchy (including subcategories).- Specified by:
getCategoriesin interfaceMerchCatalogService- Parameters:
baseSite- the base site we wish to retrieve the category hierarchy for.catalogId- the catalog we wish to retrieve the category hierarchy from.catalogVersionId- the catalog version we wish to retrieve the category hierarchy for.- Returns:
- a List of
CategoryHierarchyrepresenting the categories.
-
getProducts
public java.util.List<Product> getProducts(IndexerBatchContext indexerBatchContext, MerchProductDirectoryConfigModel merchProductDirectoryConfigModel) throws IndexerException
Description copied from interface:MerchCatalogServiceMethod to retrieve all the associated toIndexerBatchContext.- Specified by:
getProductsin interfaceMerchCatalogService- Parameters:
indexerBatchContext- represents a context valid for the duration of an indexer batch.merchProductDirectoryConfigModel- the config model being used to retrieve products for.- Returns:
- List of that represents the merchandising properties
- Throws:
IndexerException- in case of errors.
-
getCategories
public java.util.List<CategoryHierarchy> getCategories(MerchProductDirectoryConfigModel config) throws IndexerException
Retrieves a list ofCategoryHierarchyobjects representing the category hierarchy.- Specified by:
getCategoriesin interfaceMerchCatalogService- Parameters:
config- - theMerchProductDirectoryConfigModelto retrieve categories for.- Returns:
- a List representing the category hierarchy.
- Throws:
IndexerException- in case of errors.
-
createSearchQuery
protected SearchQuery createSearchQuery(IndexerBatchContext indexerBatchContext, MerchProductDirectoryConfigModel productDirectory)
Method is used to generate an instance ofSearchQueryto query Solr to retrieve updated product information.- Parameters:
indexerBatchContext- represents a context valid for the duration of an indexer batch.productDirectory- - this is the product directory we wish to export products for.- Returns:
- SearchQuery
-
createIndexedPropertiesMapping
protected java.util.Map<java.lang.String,IndexedPropertyInfo> createIndexedPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery)
Method used to retrieve a map of configured key value pairs for handling mapping between Solr internal data model- Parameters:
batchContext- indexerBatchContext represents a context valid for the duration of an indexer batch.searchQuery-- Returns:
-
isToSynchronize
protected boolean isToSynchronize(java.util.List<CatalogVersionModel> catalogVersionsToExport, InputDocument document)
Method to determine whether a given document is for the Online or Staging catalog.- Parameters:
catalogVersionsToExport-document-- Returns:
-
createIndexedPropertyInfo
protected IndexedPropertyInfo createIndexedPropertyInfo(SearchQuery searchQuery, IndexedProperty indexedProperty)
Helper method to populate IndexedPropertyInfo based on configured under- Parameters:
searchQuery-indexedProperty-- Returns:
-
getTranslatedFieldName
protected java.lang.String getTranslatedFieldName(SearchQuery searchQuery, IndexedProperty indexedProperty)
-
createMerchFacetPropertiesMapping
protected java.util.Map<java.lang.String,FacetField> createMerchFacetPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery) throws IndexerException
createMerchFacetPropertiesMapping is a method for mapping facets to output for consumption by Merchandising.- Parameters:
batchContext-searchQuery-- Returns:
- Throws:
IndexerException
-
createMerchPropertiesMapping
protected java.util.Map<java.lang.String,java.lang.String> createMerchPropertiesMapping(java.util.List<MerchPropertyModel> merchProperties, java.util.Map<java.lang.String,IndexedPropertyInfo> indexedPropertiesMapping)
createMerchPropertiesMapping is a method for mapping from the configured list ofMerchPropertyModelto the indexed properties within Solr.- Parameters:
merchProperties-indexedPropertiesMapping-- Returns:
-
extractPropName
protected java.lang.String extractPropName(AbstractMerchPropertyModel merchProp)
-
extractPropTranslatedName
protected java.lang.String extractPropTranslatedName(AbstractMerchPropertyModel merchProp)
-
processSubCategories
protected void processSubCategories(CategoryHierarchy toPopulate, CategoryModel category, boolean root, java.lang.String categoryUrl)
processSubCategories is a method for taking a category model and recursively processing its sub categories.- Parameters:
toPopulate- theCategoryHierarchywe wish to populate.category- theCategoryModelrepresenting the hierarchy.root- whether the category is a root category or not.categoryUrl- the URL to prefix the category with.
-
createActionForIndexOperation
protected java.lang.String createActionForIndexOperation(IndexOperation indexOperation)
createActionForIndexOperation is a method for retrieving the action to use when sending to Merchandising for a givenIndexOperation.- Parameters:
indexOperation- the operation to retrieve the value for.- Returns:
- the action to use.
-
getUrl
protected java.lang.String getUrl(CategoryModel category, java.lang.String baseCategoryUrl)
getUrl resolves the URL for a providedCategoryModel.- Parameters:
category- the category model to retrieve the URL for.- Returns:
- a String containing the URL.
-
getBaseSiteService
protected BaseSiteService getBaseSiteService()
Gets the configuredBaseSiteService, used to set the current site for the request.- Returns:
- the injected base site service to use.
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
Sets the configuredBaseSiteService, used to set the current site for the request.- Parameters:
baseSiteService- the injected base site service to use.
-
getCategoryUrlResolver
public AbstractUrlResolver<CategoryModel> getCategoryUrlResolver()
Retrieves the configured URL resolver forCategoryModel.- Returns:
- the configured resolver.
-
setCategoryUrlResolver
public void setCategoryUrlResolver(AbstractUrlResolver<CategoryModel> categoryUrlResolver)
Sets the configured URL resolver forCategoryModel.- Parameters:
categoryUrlResolver- the resolver to return.
-
setFacetSearchService
public void setFacetSearchService(FacetSearchService facetSearchService)
-
setSearchQueryLanguageResolver
public void setSearchQueryLanguageResolver(SearchQueryLanguageResolver searchQueryLanguageResolver)
-
setSearchQueryCurrencyResolver
public void setSearchQueryCurrencyResolver(SearchQueryCurrencyResolver searchQueryCurrencyResolver)
-
setFieldNameTranslator
public void setFieldNameTranslator(FieldNameTranslator fieldNameTranslator)
-
setMerchProductConverter
public void setMerchProductConverter(Converter<ProductIndexContainer,Product> merchProductConverter)
-
-