Class MerchIndexingListener

  • All Implemented Interfaces:
    IndexerBatchListener, IndexerListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware

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

      • MerchIndexingListener

        public MerchIndexingListener()
    • Method Detail

      • isToSynchronize

        protected boolean isToSynchronize​(java.util.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​(java.util.Map<java.lang.String,​java.lang.Object> product)
        Sanitise fields is a method for URL encoding specific fields of a product.
        Parameters:
        product - the product to sanitise (as a Map).
      • createIndexedPropertiesMapping

        protected java.util.Map<java.lang.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 java.util.Map<java.lang.String,​java.lang.String> createMerchPropertiesMapping​(java.util.List<MerchPropertyModel> merchProperties,
                                                                                                      java.util.Map<java.lang.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 java.util.Map<java.lang.String,​java.lang.String> createMerchImagePropertiesMapping​(java.util.List<MerchImagePropertyModel> merchImageProperties,
                                                                                                           java.util.Map<java.lang.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 java.lang.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 java.lang.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 java.util.Map<java.lang.String,​FacetField> createMerchFacetPropertiesMapping​(IndexerBatchContext batchContext,
                                                                                                     SearchQuery searchQuery,
                                                                                                     java.util.Map<java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.String,​java.lang.Object> product,
                                               InputDocument document,
                                               java.util.Map<java.lang.String,​java.lang.String> merchPropertiesMapping,
                                               java.util.Map<java.lang.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​(java.util.Map<java.lang.String,​java.lang.Object> product,
                                                     InputDocument document,
                                                     java.util.Map<java.lang.String,​java.lang.String> merchImagesPropertiesMapping,
                                                     java.util.Map<java.lang.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​(java.util.Map<java.lang.String,​java.lang.Object> product,
                                                    InputDocument document,
                                                    java.util.Map<java.lang.String,​FacetField> merchFacetPropertiesMapping,
                                                    java.util.Map<java.lang.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 java.util.List<java.util.Map<java.lang.Object,​java.lang.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 java.lang.Object resolveFacetValuesDisplayNameProvider​(java.lang.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 java.lang.String resolveFacetValueDisplayName​(SearchQuery searchQuery,
                                                                IndexedProperty indexedProperty,
                                                                java.lang.Object facetDisplayNameProvider,
                                                                java.lang.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 java.util.Map<java.lang.Object,​java.lang.Object> createFacetValueMapping​(java.lang.Object fieldValue,
                                                                                                 SearchQuery query,
                                                                                                 IndexedProperty indexedProperty,
                                                                                                 java.lang.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 java.lang.String translateField​(SearchQuery query,
                                                  java.lang.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 java.lang.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​(java.util.Optional<MerchIndexingConfigModel> merchIdxConf)
      • 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
      • setFacetSearchService

        public void setFacetSearchService​(FacetSearchService facetSearchService)
      • setFieldNameTranslator

        public void setFieldNameTranslator​(FieldNameTranslator fieldNameTranslator)
      • setMerchCatalogServiceClient

        public void setMerchCatalogServiceClient​(MerchCatalogServiceClient merchCatalogServiceClient)
      • setMerchIndexingConfigService

        public void setMerchIndexingConfigService​(MerchIndexingConfigService merchIndexingConfigService)
      • setSessionService

        public void setSessionService​(SessionService sessionService)
      • setCommonI18NService

        public void setCommonI18NService​(CommonI18NService commonI18NService)
      • setMerchCategoryExporter

        public void setMerchCategoryExporter​(MerchCategoryExporter merchCategoryExporter)