Class MerchIndexingListener

java.lang.Object
com.hybris.merchandising.indexer.listeners.MerchIndexingListener
All Implemented Interfaces:
IndexerBatchListener, IndexerListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware

public class MerchIndexingListener extends Object implements IndexerBatchListener, org.springframework.beans.factory.BeanFactoryAware, IndexerListener
MerchIndexingListener is a listener for carrying out actions following a Solr index.
  • Field Details

  • Constructor Details

    • MerchIndexingListener

      public MerchIndexingListener()
  • Method Details

    • afterBatch

      public void afterBatch(IndexerBatchContext batchContext) throws IndexerException
      Handles a notification that the processing for a particular IndexerBatchContext has just been completed.
      Specified by:
      afterBatch in interface IndexerBatchListener
      Parameters:
      batchContext - - the IndexerBatchContext
      Throws:
      IndexerException - if an error occurs
    • isToSynchronize

      protected boolean isToSynchronize(List<CatalogVersionModel> catalogVersionsToExport, InputDocument document)
      isToSynchonize is a method for determining whether a given document is for the Online or Staging catalog.
      Parameters:
      catalogVersionsToExport - a list of configured catalog versions for synchronizing with Merchandising.
      document - the InputDocument which has been indexed.
      Returns:
      true if the catalog / catalog version are to be synchronized, false otherwise.
    • sanitiseFields

      protected void sanitiseFields(Map<String,Object> product)
      Sanitise fields is a method for URL encoding specific fields of a product.
      Parameters:
      product - the product to sanitise (as a Map).
    • createSearchQuery

      protected SearchQuery createSearchQuery(IndexerBatchContext batchContext, MerchIndexingConfigModel merchIndexingConfig) throws IndexerException
      createSearchQuery is used to generate an instance of SearchQuery to query Solr to retrieve updated product information.
      Parameters:
      batchContext - the IndexerBatchContext representing the indexer batch.
      merchIndexingConfig - the MerchIndexingConfigModel representing the config we are using for the indexing.
      Returns:
      an SearchQuery to use with the search.
      Throws:
      IndexerException - in case of error.
    • createIndexedPropertiesMapping

      protected Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> createIndexedPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery)
      createIndexedPropertiesMapping is a method for retrieving a map of configured key value pairs for handling mapping between Solr internal data model and what to export.
      Parameters:
      batchContext - the IndexerBatchContext to retrieve from.
      searchQuery - the SearchQuery used to create the indexed property with.
      Returns:
      a Map containing key value pairs for the mapping.
    • createIndexedPropertyInfo

      protected com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo createIndexedPropertyInfo(SearchQuery searchQuery, IndexedProperty indexedProperty)
      createIndexedPropertyInfo is a method for returning an MerchIndexingListener.IndexedPropertyInfo representing a mapping from the Solr output to the configured Merchandising specific output.
      Parameters:
      searchQuery - the SearchQuery being used to retrieve the value from.
      indexedProperty - the IndexedProperty being used for the query.
      Returns:
      an IndexedPropertyInfo representing the mapping.
    • createMerchPropertiesMapping

      protected Map<String,String> createMerchPropertiesMapping(List<MerchPropertyModel> merchProperties, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping)
      createMerchPropertiesMapping is a method for mapping from the configured list of MerchPropertyModel to the indexed properties within Solr.
      Parameters:
      merchProperties - the mapping we wish to use for the output.
      indexedPropertiesMapping - the Solr mapping.
      Returns:
      a Map containing the mapped output.
    • createMerchImagePropertiesMapping

      protected Map<String,String> createMerchImagePropertiesMapping(List<MerchImagePropertyModel> merchImageProperties, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping)
      createMerchImagePropertiesMapping is an image specific method from mapping from a configured list of MerchImagePropertyModel to the indexed properties within Solr.
      Parameters:
      merchImageProperties - the mapping we wish to use for the image output.
      indexedPropertiesMapping - the Solr mapping.
      Returns:
      a Map containing the mapped output.
    • extractPropName

      protected String extractPropName(AbstractMerchPropertyModel merchProp)
      extractPropName is a method for retrieving the name of an indexed property.
      Parameters:
      merchProp - an AbstractMerchPropertyModel we wish to retrieve the name of.
      Returns:
      a String containing the name.
    • extractPropTranslatedName

      protected String extractPropTranslatedName(AbstractMerchPropertyModel merchProp)
      extractPropTranslatedName is a method for retrieving the mapped name of an indexed property. If not present, we default to the name of the indexed property.
      Parameters:
      merchProp - the AbstractMerchPropertyModel we wish to retrieve the name of.
      Returns:
      a String containing the name.
    • createMerchFacetPropertiesMapping

      protected Map<String,FacetField> createMerchFacetPropertiesMapping(IndexerBatchContext batchContext, SearchQuery searchQuery, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping)
      createMerchFacetPropertiesMapping is a method for mapping facets to output for consumption by Merchandising.
      Parameters:
      batchContext - the IndexerBatchContext representing the indexer batch.
      searchQuery - the SearchQuery used for the request.
      indexedPropertiesMapping - the mapping used for the request.
      Returns:
      a Map containing key -> facet pairs.
    • populateBasicProperties

      protected void populateBasicProperties(Map<String,Object> product, IndexerBatchContext batchContext)
      populateBasicProperties is used to retrieve a value from the IndexerBatchContext and update it in the provided output map.
      Parameters:
      product - a Map representing the product output.
      batchContext - an IndexerBatchContext to retrieve product details from.
    • populateMerchProperties

      protected void populateMerchProperties(Map<String,Object> product, InputDocument document, Map<String,String> merchPropertiesMapping, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel indexConfig)
      populateMerchProperties is a method for retrieving values from the provided InputDocument.
      Parameters:
      product - a Map representing the product output.
      document - the InputDocument representing the search result.
      merchPropertiesMapping - a key -> value pair mapping for mapping to Merchandising output.
      indexedPropertiesMapping - a map containing indexed properties.
      indexConfig - an instance of MerchIndexingConfigModel containing the configuration being used for this indexing.
    • populateMerchImagesProperties

      protected void populateMerchImagesProperties(Map<String,Object> product, InputDocument document, Map<String,String> merchImagesPropertiesMapping, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, MerchIndexingConfigModel merchIndexingConfig)
      populateMerchImagesProperties is a method for retrieving values from the provided InputDocument.
      Parameters:
      product - a Map representing the product output.
      document - the InputDocument representing the search result.
      merchImagesPropertiesMapping - a key -> value pair mapping for mapping to Merchandising output.
      indexedPropertiesMapping - a map containing indexed properties.
      merchIndexingConfig - an instance of MerchIndexingConfigModel containing the configuration being used for this indexing.
    • populateMerchFacetProperties

      protected void populateMerchFacetProperties(Map<String,Object> product, InputDocument document, Map<String,FacetField> merchFacetPropertiesMapping, Map<String,com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo> indexedPropertiesMapping, SearchQuery searchQuery)
      populateMerchFacetProperties is a method for populating facet information in the mapping to Merchandising.
      Parameters:
      product - a Map representing the product output.
      document - the InputDocument representing the search result.
      merchFacetPropertiesMapping - a key -> value pair mapping for mapping to Merchandising output.
      indexedPropertiesMapping - a map containing indexed properties.
      searchQuery - the SearchQuery being used to retrieve facets from.
    • createMerchFacetValues

      protected List<Map<Object,Object>> createMerchFacetValues(FacetField facet, SearchQuery query, IndexedProperty indexedProperty, InputDocument document, com.hybris.merchandising.indexer.listeners.MerchIndexingListener.IndexedPropertyInfo indexedPropertyInfo)
      createMerchFacetValues is a method for retrieving the values for a provided facet.
      Parameters:
      facet - the FacetField we are retrieving values for.
      query - the SearchQuery to retrieve values using.
      indexedProperty - the IndexedProperty representing the value we wish to retrieve.
      indexedPropertyInfo - the MerchIndexingListener.IndexedPropertyInfo representing the field to retrieve.
      Returns:
      a Map containing the facet mapping.
    • resolveFacetValuesDisplayNameProvider

      protected Object resolveFacetValuesDisplayNameProvider(String beanName)
      resolveFacetValuesDisplayNameProvider is a utility method for retrieving a bean from the configured bean factory.
      Parameters:
      beanName - the bean to retrieve.
      Returns:
      an Object representing the bean if found, null otherwise.
    • resolveFacetValueDisplayName

      protected String resolveFacetValueDisplayName(SearchQuery searchQuery, IndexedProperty indexedProperty, Object facetDisplayNameProvider, String facetValue)
      resolveFacetValueDisplayName is a method for retrieving the display name for a given facet.
      Parameters:
      searchQuery - the SearchQuery we are using for the retrieval.
      indexedProperty - the IndexedProperty we are retrieving.
      facetDisplayNameProvider - the value provider for the display name.
      facetValue - the value we wish to retrieve.
      Returns:
      the display name for the facet.
    • createFacetValueMapping

      protected Map<Object,Object> createFacetValueMapping(Object fieldValue, SearchQuery query, IndexedProperty indexedProperty, Object displayNameProvider)
      createFacetValueMapping creates a map of key -> value pairs for a given facet.
      Parameters:
      fieldValue - the value of the facet to use.
      query - the SearchQuery being used to resolve the display name from.
      indexedProperty - the IndexedProperty being used to resolve the display name from.
      displayNameProvider - the configured display name provider.
      Returns:
      a Map containing facet value mapping.
    • translateField

      protected String translateField(SearchQuery query, String field)
      translateField returns the translated value for a given query and field.
      Parameters:
      query - the SearchQuery we are using to retrieve the translated value from.
      field - the query's field to retrieve.
      Returns:
      a String containing the translated field.
    • createActionForIndexOperation

      protected String createActionForIndexOperation(IndexOperation indexOperation)
      createActionForIndexOperation is a method for retrieving the action to use when sending to Merchandising for a given IndexOperation.
      Parameters:
      indexOperation - the operation to retrieve the value for.
      Returns:
      the action to use.
    • isMerchIndexingEnabled

      protected boolean isMerchIndexingEnabled(Optional<MerchIndexingConfigModel> merchIdxConf)
    • afterIndex

      public void afterIndex(IndexerContext context) throws IndexerException
      Handles a notification that the indexing for a particular IndexerContext has just been completed.
      Specified by:
      afterIndex in interface IndexerListener
      Parameters:
      context - - the IndexerContext
      Throws:
      IndexerException - if an error occurs
    • beforeBatch

      public void beforeBatch(IndexerBatchContext batchContext) throws IndexerException
      Handles a notification that the processing for a particular IndexerBatchContext is about to begin.
      Specified by:
      beforeBatch in interface IndexerBatchListener
      Parameters:
      batchContext - - the IndexerBatchContext
      Throws:
      IndexerException - if an error occurs
    • afterBatchError

      public void afterBatchError(IndexerBatchContext batchContext) throws IndexerException
      Handles a notification that the processing for a particular IndexerBatchContext failed.
      Specified by:
      afterBatchError in interface IndexerBatchListener
      Parameters:
      batchContext - - the IndexerBatchContext
      Throws:
      IndexerException - if an error occurs
    • beforeIndex

      public void beforeIndex(IndexerContext context) throws IndexerException
      Handles a notification that the indexing for a particular IndexerContext is about to begin.
      Specified by:
      beforeIndex in interface IndexerListener
      Parameters:
      context - - the IndexerContext
      Throws:
      IndexerException - if an error occurs
    • afterIndexError

      public void afterIndexError(IndexerContext context) throws IndexerException
      Handles a notification that the indexing for a particular IndexerContext failed.
      Specified by:
      afterIndexError in interface IndexerListener
      Parameters:
      context - - the IndexerContext
      Throws:
      IndexerException - if an error occurs
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • getFacetSearchService

      public FacetSearchService getFacetSearchService()
    • setFacetSearchService

      public void setFacetSearchService(FacetSearchService facetSearchService)
    • getFieldNameTranslator

      public FieldNameTranslator getFieldNameTranslator()
    • setFieldNameTranslator

      public void setFieldNameTranslator(FieldNameTranslator fieldNameTranslator)
    • getMerchCatalogServiceClient

      public MerchCatalogServiceClient getMerchCatalogServiceClient()
    • setMerchCatalogServiceClient

      public void setMerchCatalogServiceClient(MerchCatalogServiceClient merchCatalogServiceClient)
    • getMerchIndexingConfigService

      protected MerchIndexingConfigService getMerchIndexingConfigService()
    • setMerchIndexingConfigService

      public void setMerchIndexingConfigService(MerchIndexingConfigService merchIndexingConfigService)
    • getSessionService

      protected SessionService getSessionService()
    • setSessionService

      public void setSessionService(SessionService sessionService)
    • getCommonI18NService

      protected CommonI18NService getCommonI18NService()
    • setCommonI18NService

      public void setCommonI18NService(CommonI18NService commonI18NService)
    • getMerchCategoryExporter

      protected MerchCategoryExporter getMerchCategoryExporter()
    • setMerchCategoryExporter

      public void setMerchCategoryExporter(MerchCategoryExporter merchCategoryExporter)