Class ProductTranslationSolrDocumentContributor

  • All Implemented Interfaces:
    com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>, com.broadleafcommerce.search.index.core.document.IndexableTypeDocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>

    public class ProductTranslationSolrDocumentContributor
    extends com.broadleafcommerce.search.index.solr.document.TranslationSolrDocumentBuilderContributor
    implements com.broadleafcommerce.search.index.core.document.IndexableTypeDocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
    Contributes translations for nested objects inside of Product, which aren't included by default due to being different entities and therefore having a different root for translating fields.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProductTranslationSolrDocumentContributor​(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService, com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper documentBuilderHelper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.search.index.core.service.IndexerTenantService tenantService)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected List<String> getAdvancedTagJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)  
      protected List<String> getCategoryJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
      Get the paths to the roots for translating fields for a particular category translation.
      protected List<String> getDataDrivenEnumJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
      Get the paths to the roots for translating fields for a particular data driven enum translation.
      com.broadleafcommerce.search.api.type.IndexableType getIndexableType()  
      protected Collection<String> getJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
      Get the JSONPath string which corresponds to the translation field's path in the indexable JSON payload.
      protected String getProductAssetJsonPath()
      Get the path to the root for translating primary asset fields.
      protected String getVariantJsonPath​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
      Get the path to the root for translating fields for a particular variant translation.
      protected String transformToJsonTranslationPath​(com.broadleafcommerce.search.api.domain.translation.Translation translation, String rootPath)
      Transform the provided path to the root object into a JSON path for the specific field to apply the translation on.
      • Methods inherited from class com.broadleafcommerce.search.index.solr.document.TranslationSolrDocumentBuilderContributor

        applyTranslation, attachTranslationsForLocale, canHandle, contributeInternal, filterTranslationsForLocale, getCloneMapper, getDocumentBuilderHelper, getObjectMapper, getSolrFieldService, getTenantService, getTypeFactory, translateIndexableJson
      • Methods inherited from interface com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor

        contribute, contributeInternal
      • Methods inherited from interface com.broadleafcommerce.search.index.core.document.IndexableTypeDocumentBuilderContributor

        canHandle
    • Constructor Detail

      • ProductTranslationSolrDocumentContributor

        public ProductTranslationSolrDocumentContributor​(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService,
                                                         com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper documentBuilderHelper,
                                                         com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                                         com.broadleafcommerce.search.index.core.service.IndexerTenantService tenantService)
    • Method Detail

      • getJsonPaths

        protected Collection<String> getJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
        Get the JSONPath string which corresponds to the translation field's path in the indexable JSON payload.

        If the translation is of a type other than product, set the root as the correct object within the indexable.

        Overrides:
        getJsonPaths in class com.broadleafcommerce.search.index.solr.document.TranslationSolrDocumentBuilderContributor
        Parameters:
        translation - translation to create JSONPath for
        Returns:
        JSONPaths for the translation in the indexable JSON
      • transformToJsonTranslationPath

        protected String transformToJsonTranslationPath​(com.broadleafcommerce.search.api.domain.translation.Translation translation,
                                                        String rootPath)
        Transform the provided path to the root object into a JSON path for the specific field to apply the translation on.
        Parameters:
        translation - translation to create JSONPath for
        rootPath - path to the root object
        Returns:
        JSONPath for the translation in the indexable JSON
      • getProductAssetJsonPath

        protected String getProductAssetJsonPath()
        Get the path to the root for translating primary asset fields.
        Returns:
        path to the root for translating primary asset fields
      • getVariantJsonPath

        protected String getVariantJsonPath​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
        Get the path to the root for translating fields for a particular variant translation.
        Parameters:
        translation - the translation to get the root for
        Returns:
        the root for the translation on a particular variant
      • getCategoryJsonPaths

        protected List<String> getCategoryJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
        Get the paths to the roots for translating fields for a particular category translation.

        This includes the paths for product's primary category, explicit categories, and other categories.

        Parameters:
        translation - the translation to get the root for
        Returns:
        the root for the translation on a particular category
      • getDataDrivenEnumJsonPaths

        protected List<String> getDataDrivenEnumJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
        Get the paths to the roots for translating fields for a particular data driven enum translation.

        This includes the paths for product's brand, merchandising type, and target demographic.

        Parameters:
        translation - the translation to get the root for
        Returns:
        the root for the translation on a particular product
      • getAdvancedTagJsonPaths

        protected List<String> getAdvancedTagJsonPaths​(com.broadleafcommerce.search.api.domain.translation.Translation translation)
      • getIndexableType

        public com.broadleafcommerce.search.api.type.IndexableType getIndexableType()
        Specified by:
        getIndexableType in interface com.broadleafcommerce.search.index.core.document.IndexableTypeDocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>