Class OptionTemplateProductConsolidationContributor
java.lang.Object
com.broadleafcommerce.catalog.service.product.consolidation.ContextualProductConsolidationContributor<OptionTemplate>
com.broadleafcommerce.catalog.service.product.consolidation.OptionTemplateProductConsolidationContributor
- All Implemented Interfaces:
ProductConsolidationContributor
public class OptionTemplateProductConsolidationContributor
extends ContextualProductConsolidationContributor<OptionTemplate>
Contributor responsible for consolidating
OptionTemplates referenced by
Products' Options.- Author:
- Susana Cruz (susanaccruz)
-
Field Summary
FieldsFields inherited from class com.broadleafcommerce.catalog.service.product.consolidation.ContextualProductConsolidationContributor
IGNORE_ARCHIVED_FILTER, typeFactory -
Constructor Summary
ConstructorsConstructorDescriptionOptionTemplateProductConsolidationContributor(com.broadleafcommerce.common.extension.TypeFactory typeFactory, OptionTemplateService<OptionTemplate> optionTemplateService, com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> translationEntityService) -
Method Summary
Modifier and TypeMethodDescriptionbuildProductIdToOptionTemplateIdMap(@NonNull List<ConsolidatedProduct> products) Builds a map ofOptionTemplateids mapped to the ids ofProductsthat reference them via them ownProductOptions.protected Map<String,List<OptionTemplate>> buildProductIdToOptionTemplates(@NonNull Map<String, Set<String>> optionTemplateIdsToProductId, @NonNull List<OptionTemplate> objectsToConsolidate) Builds a map ofOptionTemplatesmapped by the ids ofProductsthat reference them via them ownProductOptions.protected voidconsolidateOptionTemplates(@NonNull List<ConsolidatedProduct> products, @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull Map<String, List<ConsolidatedProduct>> productsById, @NonNull Map<String, List<OptionTemplate>> objectsToConsolidateByProductId) Consolidates theOptionTemplatesonto the relatedConsolidatedProducts.voidconsolidateProducts(@NonNull Set<String> productIds, @NonNull List<ConsolidatedProduct> products, @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Consolidate products with their related domain and translations.protected voidconsolidateTranslations(@NonNull List<ConsolidatedProduct> products, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieves and adds option template translations to the consolidated products.protected List<OptionTemplate>getObjectsToConsolidate(@NonNull Set<String> optionTemplateIds, @NonNull List<ConsolidatedProduct> products, @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieve the full list of domain objects of this type to be consolidated into the products.protected List<ProductOption>getOptionsFromTemplates(@NonNull Collection<? extends OptionTemplate> optionTemplates) protected OptionTemplateService<OptionTemplate>protected com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation>protected List<com.broadleafcommerce.translation.domain.Translation>getTranslations(List<String> entityIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Function<OptionTemplate,String> idGetter()Defines the function which retrieves the contextId of the domain object in order to recognize it in different contexts.protected Function<OptionTemplate,String> Defines the function which retrieves the Product ID from the domain object to consolidate, in order to group it with the appropriate product for processing.protected voidsetOptions(@NonNull ConsolidatedProduct product, @NonNull List<? extends OptionTemplate> optionTemplates) protected BiConsumer<ConsolidatedProduct,List<OptionTemplate>> setter()Defines the function which should be used to set the domain objects on the consolidated product.booleanshouldConsolidate(Set<String> productIds, List<ConsolidatedProduct> products, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Determines whether this contributor should be executed based on the given parameters and context.Methods inherited from class com.broadleafcommerce.catalog.service.product.consolidation.ContextualProductConsolidationContributor
consolidateRelations, contextCompositeKey, contextCompositeKey, contextStatesMatch, createOverrideProductForContext, findImplicitMatches, getCloneMapper, getInheritanceLevel, getMostSpecificCatalogId, getProductConsolidationRequest, getRsqlParser, getTypeFactory, ignoreArchived, isInheriting, setListValue, setSingleValue
-
Field Details
-
OPTION_TRANSLATION_HINT
- See Also:
-
-
Constructor Details
-
OptionTemplateProductConsolidationContributor
public OptionTemplateProductConsolidationContributor(com.broadleafcommerce.common.extension.TypeFactory typeFactory, OptionTemplateService<OptionTemplate> optionTemplateService, com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> translationEntityService)
-
-
Method Details
-
shouldConsolidate
public boolean shouldConsolidate(Set<String> productIds, List<ConsolidatedProduct> products, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductConsolidationContributorDetermines whether this contributor should be executed based on the given parameters and context.Returns true by default.
- Parameters:
productIds- the IDs of the products to consolidateproducts- the product in all explicit context statesinheritanceLines- the catalog inheritance lines top-down from all of the productscontext- context information surrounding sandboxing/multitenant state
-
consolidateProducts
public void consolidateProducts(@NonNull @NonNull Set<String> productIds, @NonNull @NonNull List<ConsolidatedProduct> products, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:ProductConsolidationContributorConsolidate products with their related domain and translations. This includes both hydratingProductfields and combining external references likeCategoryProduct. Any catalog or sandbox overrides made to external references for non-overridden products will generate new placeholder products to store those overrides.- Specified by:
consolidateProductsin interfaceProductConsolidationContributor- Overrides:
consolidateProductsin classContextualProductConsolidationContributor<OptionTemplate>- Parameters:
productIds- the IDs of the products to consolidateproducts- the product in all explicit context statesinheritanceLines- the catalog inheritance lines top-down from all of the productscontext- context information surrounding sandboxing/multitenant state
-
getObjectsToConsolidate
protected List<OptionTemplate> getObjectsToConsolidate(@NonNull @NonNull Set<String> optionTemplateIds, @NonNull @NonNull List<ConsolidatedProduct> products, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from class:ContextualProductConsolidationContributorRetrieve the full list of domain objects of this type to be consolidated into the products.- Specified by:
getObjectsToConsolidatein classContextualProductConsolidationContributor<OptionTemplate>- Parameters:
optionTemplateIds- the IDs of the products to consolidateproducts- the products in all explicit context statesinheritanceLines- the catalog inheritance lines top-down from all of the productscontext- context information surrounding sandboxing/multitenant state- Returns:
- all domain objects of this type to consolidate into the products
-
productIdGetter
Description copied from class:ContextualProductConsolidationContributorDefines the function which retrieves the Product ID from the domain object to consolidate, in order to group it with the appropriate product for processing.- Specified by:
productIdGetterin classContextualProductConsolidationContributor<OptionTemplate>- Returns:
- function to retrieve Product ID of the domain object
-
setter
Description copied from class:ContextualProductConsolidationContributorDefines the function which should be used to set the domain objects on the consolidated product.- Specified by:
setterin classContextualProductConsolidationContributor<OptionTemplate>- Returns:
- function to set domain objects on the consolidated product
-
idGetter
Description copied from class:ContextualProductConsolidationContributorDefines the function which retrieves the contextId of the domain object in order to recognize it in different contexts.- Specified by:
idGetterin classContextualProductConsolidationContributor<OptionTemplate>- Returns:
- function to retrieve contextId of the domain object
-
buildProductIdToOptionTemplateIdMap
protected Map<String,Set<String>> buildProductIdToOptionTemplateIdMap(@NonNull @NonNull List<ConsolidatedProduct> products) Builds a map ofOptionTemplateids mapped to the ids ofProductsthat reference them via them ownProductOptions.- Parameters:
products- Products to consolidate- Returns:
- A map of
OptionTemplateids mapped to theProductsthat reference them via them ownProductOptions.
-
buildProductIdToOptionTemplates
protected Map<String,List<OptionTemplate>> buildProductIdToOptionTemplates(@NonNull @NonNull Map<String, Set<String>> optionTemplateIdsToProductId, @NonNull @NonNull List<OptionTemplate> objectsToConsolidate) Builds a map ofOptionTemplatesmapped by the ids ofProductsthat reference them via them ownProductOptions.- Parameters:
optionTemplateIdsToProductId- Map of Product ids to the ids of option templates that they referenceobjectsToConsolidate- Option Templates referenced by the products to consolidate that need to be added to the map.- Returns:
- A map of
OptionTemplatesmapped by the ids ofProductsthat reference them via them ownProductOptions.
-
setOptions
protected void setOptions(@NonNull @NonNull ConsolidatedProduct product, @NonNull @NonNull List<? extends OptionTemplate> optionTemplates) -
getOptionsFromTemplates
protected List<ProductOption> getOptionsFromTemplates(@NonNull @NonNull Collection<? extends OptionTemplate> optionTemplates) -
consolidateOptionTemplates
protected void consolidateOptionTemplates(@NonNull @NonNull List<ConsolidatedProduct> products, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, @NonNull @NonNull Map<String, List<ConsolidatedProduct>> productsById, @NonNull @NonNull Map<String, List<OptionTemplate>> objectsToConsolidateByProductId) Consolidates theOptionTemplatesonto the relatedConsolidatedProducts.- Parameters:
products- Products to be consolidatedinheritanceLines- Catalog inheritance linesproductsById- Map of products by their idsobjectsToConsolidateByProductId- Map of option templates by their related product's id
-
consolidateTranslations
protected void consolidateTranslations(@NonNull @NonNull List<ConsolidatedProduct> products, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieves and adds option template translations to the consolidated products.- Parameters:
products- Products to be consolidatedcontext- Additional tenant and sandbox info
-
getTranslations
-
getOptionTemplateService
-
getTranslationEntityService
protected com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> getTranslationEntityService()
-