Class DefaultConsolidatedProductPostProcessor
java.lang.Object
com.broadleafcommerce.catalog.service.product.consolidation.DefaultConsolidatedProductPostProcessor
- All Implemented Interfaces:
ConsolidatedProductPostProcessor
public class DefaultConsolidatedProductPostProcessor
extends Object
implements ConsolidatedProductPostProcessor
Default implementation of
ConsolidatedProductPostProcessor. Focuses on adding data for
ConsolidatedProduct.getCatalogOverrides(),
ConsolidatedProduct.getSandboxAwareCatalogOverrides(),
ConsolidatedProduct.getSandboxOverrides(),
ConsolidatedProduct.getCatalogAwareSandboxOverrides(), and
ConsolidatedProduct.getCatalogOmissions().- Author:
- Jeff Fischer
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultConsolidatedProductPostProcessor(List<ConsolidatedProduct> products, ProductService<Product> productService, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, Map<String, Set<String>> marketplaceApplicationsForCatalogs, Map<String, Set<String>> pendingMarketplaceApplicationsForCatalogs) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFromInheritanceLines(ConsolidatedProduct product, String productCatalog, Map<String, Set<String>> applicationsForCatalogs, Set<String> applicationsToAdd) protected StringCreate the sandbox override value to store as part ofConsolidatedProduct.getSandboxOverrides().A map of pre-fetchedCataloginstances mapped by ID.protected static booleanprotected booleanisInheriting(String reference, String candidate) Determine if the candidate catalog id represents a catalog that inherits from a catalog represented by the reference catalog id.protected booleanisSameSandboxContext(ConsolidatedProduct reference, ConsolidatedProduct candidate) protected booleanisSandboxOverride(ConsolidatedProduct reference, ConsolidatedProduct candidate) Determine if the candidate product is a more close sandbox version than the reference.voidprocess(ConsolidatedProduct product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetAllCatalogsById(Map<String, com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> allCatalogsById) A map of pre-fetchedCataloginstances mapped by ID.
-
Constructor Details
-
DefaultConsolidatedProductPostProcessor
public DefaultConsolidatedProductPostProcessor(List<ConsolidatedProduct> products, ProductService<Product> productService, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.tenant.domain.InheritanceLines inheritanceLines, Map<String, Set<String>> marketplaceApplicationsForCatalogs, Map<String, Set<String>> pendingMarketplaceApplicationsForCatalogs)
-
-
Method Details
-
process
public void process(ConsolidatedProduct product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
processin interfaceConsolidatedProductPostProcessor
-
addFromInheritanceLines
-
isSandboxOverride
Determine if the candidate product is a more close sandbox version than the reference.- Parameters:
reference- The production or sandbox version to use as a base referencecandidate- The candidate sandbox version to compare against the reference for closeness- Returns:
- Whether or not the candidate is a closer sandbox version
-
createSandboxOverrideValue
Create the sandbox override value to store as part of
ConsolidatedProduct.getSandboxOverrides().Note - in this flow, we are expecting
ConsolidatedProduct.getSandboxOwner()to only have a value set if it's a USER level change. This would be a deviation from what is stored in the actual entity database table's trk_sandbox_owner column, since that value is always set for all non-production level records.Our reasoning is like so:
- A higher-than-user-level sandbox change (ex: promoted) should be visible to all users, and thus the sandboxOverride value to indicate the presence of such a record should just contain the sandboxId.
- A user-level sandbox change should only be visible to that specific user, and thus the sandboxOverride value to indicate the presence of such a record should be a combination of sandboxId,userChangeSandboxOwner.
In the Solr query, we will leverage this information to ensure the overridden (base) record will be excluded if there is either a higher-than-user-level override for it, _or_ there is a user-level override by the current user for it.
- Parameters:
override- The sandbox overriding product- Returns:
- a value that can be placed in the overridden (base) record's sandboxOverrides field to indicate the presence of this override record
-
isInheriting
Determine if the candidate catalog id represents a catalog that inherits from a catalog represented by the reference catalog id.- Parameters:
reference- The id of the reference catalogcandidate- The id of the candidate catalog- Returns:
- Whether or not the candidate inherits from the reference
-
isActiveSandboxMember
-
isSameSandboxContext
protected boolean isSameSandboxContext(ConsolidatedProduct reference, ConsolidatedProduct candidate) -
getAllCatalogsById
protected Map<String,com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getAllCatalogsById()A map of pre-fetchedCataloginstances mapped by ID. This should contain all theContextState.getBaseCatalogId()andContextState.getOverrideCatalogId()values obtained fromproducts. -
setAllCatalogsById
public void setAllCatalogsById(Map<String, com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> allCatalogsById) A map of pre-fetchedCataloginstances mapped by ID. This should contain all theContextState.getBaseCatalogId()andContextState.getOverrideCatalogId()values obtained fromproducts.
-