public class DefaultBundleCommerceRuleService extends java.lang.Object implements BundleRuleService
BundleRuleService. It searches for the the lowest price
(based on bundle price rules) for a product that is a part of a bundle.| Constructor and Description |
|---|
DefaultBundleCommerceRuleService() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkBundleRuleForConditionalProduct(AbstractBundleRuleModel bundleRule,
java.util.Set<ProductModel> otherProductsInSameBundle,
ProductModel product)
Applies the check logic for disable product rules to test if the given
bundleRule meets the
requirements. |
protected boolean |
checkBundleRuleForTargetProduct(AbstractBundleRuleModel rule,
java.util.Set<ProductModel> otherProductsInSameBundle)
Applies the rules for conditional products to check if the given
rule meets the requirements. |
protected boolean |
checkRuleIsFulfilled(AbstractBundleRuleModel bundleRule,
ProductModel product,
java.util.Set<ProductModel> otherProductsInSameBundle) |
java.lang.String |
createMessageForDisableRule(DisableProductBundleRuleModel disableRule,
ProductModel product)
Generates the message explaining why given product is disabled with specific rule.
|
protected AbstractBundleRuleModel |
evaluateBundleRules(java.util.List<AbstractBundleRuleModel> bundleRules,
ProductModel product,
java.util.Set<ProductModel> otherProductsInSameBundle)
Evaluates if any of the given
bundleRules is applicable for the given |
protected BundleTemplateService |
getBundleTemplateService() |
protected OrderEntryDao |
getCartEntryDao() |
protected java.util.Set<ProductModel> |
getCartProductsInSameBundle(AbstractOrderModel order,
ProductModel product,
EntryGroup bundleEntryGroup)
Returns a list of of products that belong to the same bundle entry group in the given multi-cart as the given
product |
protected java.util.Set<ProductModel> |
getCartProductsInSameBundle(AbstractOrderModel masterAbstractOrder,
ProductModel product,
int bundleNo)
Deprecated.
since 6.5 - bundleNo is deprecated, use
getCartProductsInSameBundle(AbstractOrderModel, ProductModel, EntryGroup) |
ChangeProductPriceBundleRuleModel |
getChangePriceBundleRule(AbstractOrderModel masterAbstractOrder,
BundleTemplateModel bundleTemplate,
ProductModel targetProduct,
int bundleNo)
Returns a
ChangeProductPriceBundleRuleModel valid for the given targetProduct. |
ChangeProductPriceBundleRuleModel |
getChangePriceBundleRule(BundleTemplateModel targetComponent,
ProductModel targetProduct,
ProductModel conditionalProduct,
CurrencyModel currency)
Returns a
ChangeProductPriceBundleRuleModel valid for the given targetProduct. |
ChangeProductPriceBundleRuleModel |
getChangePriceBundleRuleForOrderEntry(AbstractOrderEntryModel entry)
Returns a
ChangeProductPriceBundleRuleModel valid for the given orderEntryModel. |
ChangeProductPriceBundleRuleModel |
getChangePriceBundleRuleWithLowestPrice(ProductModel targetProduct,
CurrencyModel currency)
Searches for the lowest price
ChangeProductPriceBundleRuleModel of the given targetProduct in
any bundle package |
protected ChangeProductPriceBundleRuleDao |
getChangeProductPriceBundleRuleDao() |
protected BundleRuleDao |
getDisableProductBundleRuleDao() |
java.util.List<DisableProductBundleRuleModel> |
getDisableProductBundleRules(ProductModel product,
EntryGroup entryGroup,
AbstractOrderModel order)
|
DisableProductBundleRuleModel |
getDisableRuleForBundleProduct(AbstractOrderModel masterAbstractOrder,
ProductModel product,
BundleTemplateModel bundleTemplate,
int bundleNo,
boolean ignoreCurrentProducts)
Returns a
DisableProductBundleRuleModel valid for the given product ignoring products
ignoreProducts in the cart. |
DisableProductBundleRuleModel |
getDisableRuleForBundleProduct(BundleTemplateModel bundleTemplate,
ProductModel product1,
ProductModel product2)
Returns a
DisableProductBundleRuleModel which does not allow that the given products product1
and product2 are added together to a bundle. |
protected EntryGroupService |
getEntryGroupService() |
protected L10NService |
getL10NService() |
protected ChangeProductPriceBundleRuleModel |
getLowestPriceForTargetProductAndTemplate(BundleTemplateModel bundleTemplate,
ProductModel targetProduct,
CurrencyModel currency,
java.util.Set<ProductModel> otherProductsInSameBundle)
Finds the
ChangeProductPriceBundleRuleModel with the lowest price for the given targetProduct
. |
protected ModelService |
getModelService() |
protected SearchRestrictionService |
getSearchRestrictionService() |
protected SessionService |
getSessionService() |
void |
setBundleTemplateService(BundleTemplateService bundleTemplateService) |
void |
setCartEntryDao(OrderEntryDao cartEntryDao) |
void |
setChangeProductPriceBundleRuleDao(ChangeProductPriceBundleRuleDao changeProductPriceBundleRuleDao) |
void |
setDisableProductBundleRuleDao(BundleRuleDao disableProductBundleRuleDao) |
void |
setEntryGroupService(EntryGroupService entryGroupService) |
void |
setL10NService(L10NService l10nService) |
void |
setModelService(ModelService modelService) |
void |
setSearchRestrictionService(SearchRestrictionService searchRestrictionService) |
void |
setSessionService(SessionService sessionService) |
protected <A extends ItemModel,R> |
unrestricted(A model,
java.util.function.Function<A,R> getter)
Executes
getter in search-restrictions-off context. |
public ChangeProductPriceBundleRuleModel getChangePriceBundleRuleForOrderEntry(AbstractOrderEntryModel entry)
BundleRuleServiceChangeProductPriceBundleRuleModel valid for the given orderEntryModel. The method
calculates the lowest product price for the product in the given orderEntryModel which is added to a
bundle. The calculation is based on the entry's bundle template and the other products in the same bundle
(conditional products)getChangePriceBundleRuleForOrderEntry in interface BundleRuleServiceentry - entry that is added to the cart as part of a bundleChangeProductPriceBundleRuleModel if existing or nullpublic java.util.List<DisableProductBundleRuleModel> getDisableProductBundleRules(ProductModel product, EntryGroup entryGroup, AbstractOrderModel order)
BundleRuleServiceDisableProductBundleRuleModel valid for the given product in the given
order. The method searches for DisableProductBundleRuleModels that can
be applied if the given product is or would be added to the given order in the context
of the given entryGroup .getDisableProductBundleRules in interface BundleRuleServiceproduct - product that is or shall be added to the bundle and for which applicable
DisableProductBundleRuleModels are searchedentryGroup - entry group representing a bundle to which the product is or shall be addedorder - the cart/order to which the given product is addedDisableProductBundleRuleModel which are blocking adding product cannot be
added to the bundle in the cart.public ChangeProductPriceBundleRuleModel getChangePriceBundleRule(BundleTemplateModel targetComponent, ProductModel targetProduct, ProductModel conditionalProduct, CurrencyModel currency)
BundleRuleServiceChangeProductPriceBundleRuleModel valid for the given targetProduct. The method
calculates (forecasts) the lowest product price for the given targetProduct which shall be added to a
bundle based on the given bundle template (targetComponent) in combination with the given
conditionalProduct. The bundle or a cart to which the given products should be added may or may not
yet exist. The method just forecasts the possible price for the given combination of input parameters.getChangePriceBundleRule in interface BundleRuleServicetargetComponent - bundle template based on which the given targetProduct is or shall be added to a bundletargetProduct - product that is added to a bundle and for which the product price is calculatedconditionalProduct - second product that is added to the same bundle as the given targetProduct and that is the
condition for a ChangeProductPriceBundleRuleModel to be selectedcurrency - the currency the ChangeProductPriceBundleRuleModel must match to be selectedChangeProductPriceBundleRuleModel if existing or nullpublic ChangeProductPriceBundleRuleModel getChangePriceBundleRule(AbstractOrderModel masterAbstractOrder, BundleTemplateModel bundleTemplate, ProductModel targetProduct, int bundleNo)
BundleRuleServiceChangeProductPriceBundleRuleModel valid for the given targetProduct. The method
calculates (forecasts) the lowest product price for the given targetProduct which shall be added to a
bundle based on the given bundle template (targetComponent). The price is retrieved from the
ChangeProductPriceBundleRuleModels that can be applied based on the other products in the same bundle. The
method just forecasts the possible price for the given combination of input parameters.getChangePriceBundleRule in interface BundleRuleServicemasterAbstractOrder - the master cart/order to which the given targetProduct shall be addedbundleTemplate - bundle template based on which the given targetProduct shall be added to the bundletargetProduct - product that shall be added to the bundle and for which applicable DisableProductBundleRuleModel
's are searchedbundleNo - the number of the bundle to which the targetProduct shall be addedChangeProductPriceBundleRuleModel if existing or nullpublic ChangeProductPriceBundleRuleModel getChangePriceBundleRuleWithLowestPrice(ProductModel targetProduct, CurrencyModel currency)
BundleRuleServiceChangeProductPriceBundleRuleModel of the given targetProduct in
any bundle packagegetChangePriceBundleRuleWithLowestPrice in interface BundleRuleServicetargetProduct - the product for which the lowest bundle price is searchedcurrency - the currency the ChangeProductPriceBundleRuleModel must match to be selectedChangeProductPriceBundleRuleModel if existing or nullprotected ChangeProductPriceBundleRuleModel getLowestPriceForTargetProductAndTemplate(BundleTemplateModel bundleTemplate, ProductModel targetProduct, CurrencyModel currency, java.util.Set<ProductModel> otherProductsInSameBundle)
ChangeProductPriceBundleRuleModel with the lowest price for the given targetProduct
. All ChangeProductPriceBundleRuleModels which are assigned to the given bundleTemplate and
have the given targetProduct as target product and meet the requirements for conditional products are
selected. The prices of these rules are then evaluated: The ChangeProductPriceBundleRuleModel that matches
the given currency and has the lowest price, is returned.public DisableProductBundleRuleModel getDisableRuleForBundleProduct(AbstractOrderModel masterAbstractOrder, ProductModel product, BundleTemplateModel bundleTemplate, int bundleNo, boolean ignoreCurrentProducts)
BundleRuleServiceDisableProductBundleRuleModel valid for the given product ignoring products
ignoreProducts in the cart. The method searches for DisableProductBundleRuleModel's that can
be applied if the given product is or would be added to the given masterAbstractOrder in
the context of the given bundleNo and bundleTemplate.getDisableRuleForBundleProduct in interface BundleRuleServicemasterAbstractOrder - the master cart/order to which the given product is addedproduct - product that is or shall be added to the bundle and for which applicable
DisableProductBundleRuleModel's are searchedbundleTemplate - bundle template based on which the given product is or shall be added to the bundlebundleNo - the number of the bundle to which the product is or shall be added to a bundleignoreCurrentProducts - if the products in the current bundletemplate should be ignoredDisableProductBundleRuleModel that is found which means that the given
product cannot be added to the bundle in the cart. null if no
DisableProductBundleRuleModel applies and the product can be added to the bundle.public DisableProductBundleRuleModel getDisableRuleForBundleProduct(BundleTemplateModel bundleTemplate, ProductModel product1, ProductModel product2)
BundleRuleServiceDisableProductBundleRuleModel which does not allow that the given products product1
and product2 are added together to a bundle. In case no such disable rule exists null is
returned.getDisableRuleForBundleProduct in interface BundleRuleServicebundleTemplate - bundle template based on which the given targetProduct and conditionalProduct
shall be added to the bundleproduct1 - first product that shall be added to the bundleproduct2 - second product that shall be added to the bundleDisableProductBundleRuleModel that is found which means that the given
product1 and product2 cannot be added together to the bundle in the cart.
null if no DisableProductBundleRuleModel applies and the products can be added to the
bundle.protected AbstractBundleRuleModel evaluateBundleRules(java.util.List<AbstractBundleRuleModel> bundleRules, ProductModel product, java.util.Set<ProductModel> otherProductsInSameBundle)
bundleRules is applicable for the given product in
the context of the list of other products that are already in the same bundle. Depending on whether the given
product is a target or a conditional product of the bundleRule the check itself is done either in
method checkBundleRuleForTargetProduct or method checkBundleRuleForConditionalProduct.@Deprecated protected java.util.Set<ProductModel> getCartProductsInSameBundle(AbstractOrderModel masterAbstractOrder, ProductModel product, int bundleNo)
getCartProductsInSameBundle(AbstractOrderModel, ProductModel, EntryGroup)productprotected java.util.Set<ProductModel> getCartProductsInSameBundle(AbstractOrderModel order, ProductModel product, EntryGroup bundleEntryGroup)
productprotected boolean checkBundleRuleForTargetProduct(AbstractBundleRuleModel rule, java.util.Set<ProductModel> otherProductsInSameBundle)
rule meets the requirements. Returns
true if the given list of products otherProductsInSameBundle matches the list of
conditional products of the given rule, otherwise false.protected boolean checkBundleRuleForConditionalProduct(AbstractBundleRuleModel bundleRule, java.util.Set<ProductModel> otherProductsInSameBundle, ProductModel product)
bundleRule meets the
requirements. Returns true if the given bundleRule is of type "ALL" and the given
product is listed as a conditional product, all other conditional products and at least one of the
target products are already added to the bundle in the cart. It also returns true if the given
bundleRule is of type "ANY" and the given product is listed as a conditional product and
at least one of the target products is already added to the bundle in the cart. In all other cases it returns
false. It is assumed that the given product is in the list of conditional products of
the given bundleRule.protected boolean checkRuleIsFulfilled(AbstractBundleRuleModel bundleRule, ProductModel product, java.util.Set<ProductModel> otherProductsInSameBundle)
protected <A extends ItemModel,R> R unrestricted(A model, java.util.function.Function<A,R> getter)
getter in search-restrictions-off context.A - type of the objectR - type of the datamodel - persistent object to get data fromgetter - data obtaining logicpublic java.lang.String createMessageForDisableRule(DisableProductBundleRuleModel disableRule, ProductModel product)
BundleRuleServicecreateMessageForDisableRule in interface BundleRuleServicedisableRule - DisableProductBundleRuleModel which disabled given product for specific conditional productsproduct - Disabled productprotected BundleTemplateService getBundleTemplateService()
public void setBundleTemplateService(BundleTemplateService bundleTemplateService)
protected ChangeProductPriceBundleRuleDao getChangeProductPriceBundleRuleDao()
public void setChangeProductPriceBundleRuleDao(ChangeProductPriceBundleRuleDao changeProductPriceBundleRuleDao)
protected BundleRuleDao getDisableProductBundleRuleDao()
public void setDisableProductBundleRuleDao(BundleRuleDao disableProductBundleRuleDao)
protected OrderEntryDao getCartEntryDao()
public void setCartEntryDao(OrderEntryDao cartEntryDao)
protected SearchRestrictionService getSearchRestrictionService()
public void setSearchRestrictionService(SearchRestrictionService searchRestrictionService)
protected ModelService getModelService()
public void setModelService(ModelService modelService)
protected SessionService getSessionService()
public void setSessionService(SessionService sessionService)
protected EntryGroupService getEntryGroupService()
public void setEntryGroupService(EntryGroupService entryGroupService)
protected L10NService getL10NService()
public void setL10NService(L10NService l10nService)
Copyright © 2018 SAP SE. All Rights Reserved.