Class ProductTranslationSolrDocumentContributor
- java.lang.Object
-
- com.broadleafcommerce.search.index.solr.document.TranslationSolrDocumentBuilderContributor
-
- com.broadleafcommerce.search.index.catalog.solr.document.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 ofProduct
, which aren't included by default due to being different entities and therefore having a different root for translating fields.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CATEGORY
static String
DATA_DRIVEN_ENUM
protected static String
PRIMARY_ASSET_PATH
static String
PRODUCT_ASSET
static String
PRODUCT_TAG
static String
VARIANT
-
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
PRIMARY_ASSET_PATH
protected static final String PRIMARY_ASSET_PATH
- See Also:
- Constant Field Values
-
VARIANT
public static final String VARIANT
- See Also:
- Constant Field Values
-
PRODUCT_ASSET
public static final String PRODUCT_ASSET
- See Also:
- Constant Field Values
-
CATEGORY
public static final String CATEGORY
- See Also:
- Constant Field Values
-
DATA_DRIVEN_ENUM
public static final String DATA_DRIVEN_ENUM
- See Also:
- Constant Field Values
-
PRODUCT_TAG
public static final String PRODUCT_TAG
- See Also:
- Constant Field Values
-
-
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 classcom.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 forrootPath
- 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 interfacecom.broadleafcommerce.search.index.core.document.IndexableTypeDocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
-
-