Class DefaultPromotionEngineResultService
java.lang.Object
de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultPromotionEngineResultService
- All Implemented Interfaces:
PromotionResultService
Default implementation of PromotionResultService
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(PromotionResultModel promotionResult) Apply all of the actions that this promotion generated to the order.protected CommonI18NServicelonggetConsumedCount(PromotionResultModel promotionResult, boolean paramBoolean) Get the total number of items consumed by this promotion.booleangetCouldFire(PromotionResultModel promotionResult) Is this a potential result.protected CouponCodeRetrievalStrategygetCouponCodesFromPromotion(PromotionResultModel promotionResult) Return give way coupon code for promotion.protected DefaultPromotionResultServicegetDescription(PromotionResultModel promotionResult) Get the description of this promotion result.getDescription(PromotionResultModel promotionResult, Locale locale) Get the description of this promotion result.booleangetFired(PromotionResultModel promotionResult) Returns true if the promotion fired and has produced a result.getFiredOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Return a list of results for promotions that fired and did not consume products.getFiredProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Return a list of results for promotions that fired and consumed products.protected StringgetMessageWithResolvedParameters(PromotionResultModel promotionResult, Locale locale, String messageFiredPositional, List<RuleParameterData> parameters) Formats message by resolving placeholders defined in the message.protected ModelServicegetPotentialOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Return a list of results for potential promotions that fired and did not consume products and have been applied.getPotentialProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Return a list of results for potential promotions that fired and consumed products and have been applied.protected Map<String,PromotionMessageParameterResolutionStrategy> protected RuleParametersServicedoublegetTotalDiscount(PromotionResultModel promotionResult) Get the total value of all discounts in this result.booleanisApplied(PromotionResultModel promotionResult) Returns true if the promotion fired and all of its actions have been applied to the order.booleanisAppliedToOrder(PromotionResultModel promotionResult) Returns true if the promotion fired and all of its actions have been applied to the order.protected booleanisRuleBasedPromotion(AbstractPromotionModel abstractPromotion) protected voidlogMissingParametersResolutionStrategies(List<RuleParameterData> parameters, Map<String, Object> messageActionValues) protected voidlogUnresolvedPlaceholder(PromotionResultModel promotionResult, String resolvedMessage) protected RuleParameterDatareplaceRuleParameterValue(PromotionResultModel promotionResult, Map<String, Object> messageActionValues, RuleParameterData parameter) protected ObjectresolveParameterValue(RuleParameterData parameter, PromotionResultModel promotionResult, Locale locale) voidsetCommonI18NService(CommonI18NService commonI18NService) voidsetCouponCodeRetrievalStrategy(CouponCodeRetrievalStrategy couponCodeRetrievalStrategy) voidsetDefaultPromotionResultService(DefaultPromotionResultService defaultPromotionResultService) voidsetModelService(ModelService modelService) voidsetResolutionStrategies(Map<String, PromotionMessageParameterResolutionStrategy> resolutionStrategies) voidsetRuleParametersService(RuleParametersService ruleParametersService) booleanundo(PromotionResultModel promotionResult) Undo all of the changes that this promotion made to the order.
-
Field Details
-
EMPTY_VALUE
- See Also:
-
LIST_PATTERN
-
MAP_PATTERN
-
-
Constructor Details
-
DefaultPromotionEngineResultService
public DefaultPromotionEngineResultService()
-
-
Method Details
-
getDescription
Description copied from interface:PromotionResultServiceGet the description of this promotion result. This method uses the default locale (Locale.getDefault())- Specified by:
getDescriptionin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- A description of the promotion result
- See Also:
-
apply
Description copied from interface:PromotionResultServiceApply all of the actions that this promotion generated to the order.- Specified by:
applyin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- true if calculateTotals() should be called to update the order totals.
-
getConsumedCount
Description copied from interface:PromotionResultServiceGet the total number of items consumed by this promotion.- Specified by:
getConsumedCountin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModelparamBoolean- include could fire promotions- Returns:
- The total number of items consumed
-
getCouldFire
Description copied from interface:PromotionResultServiceIs this a potential result. Returns true if the promotion believes it has a chance of firing, for instance if it requires 3 qualifying products but can only find 1.- Specified by:
getCouldFirein interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion could fire
-
getDescription
Description copied from interface:PromotionResultServiceGet the description of this promotion result. Gets the description for this promotion result. This description is based on the state of the result, the promotion that generated the result and the user supplied formatting strings. TheLocalespecified is used to format any numbers, dates or currencies for display to the user. It is important that this locale best represents the formatting options appropriate for display to the user. The default currency for the locale is ignored. The currency is always explicitly taken from theGeneratedAbstractOrder.getCurrency(). The currency is then formatted appropriately in the locale specified. For example, this does mean that values in the EURO currency will be formatted differently depending on the locale specified as each locale can specify currency specific formatting. The currency formatting is part of the Java VM configuration to support multiple locales. If the formatting is incorrect check your VM configuration for the locale and currency combination.- Specified by:
getDescriptionin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModellocale- The locale to use to format the messages. This locale must support currency formatting, i.e. this should be a region specific local. e.g de_DE, en_US, en_GB- Returns:
- A description of the promotion result
-
logMissingParametersResolutionStrategies
protected void logMissingParametersResolutionStrategies(List<RuleParameterData> parameters, Map<String, Object> messageActionValues) -
isRuleBasedPromotion
-
replaceRuleParameterValue
protected RuleParameterData replaceRuleParameterValue(PromotionResultModel promotionResult, Map<String, Object> messageActionValues, RuleParameterData parameter) -
getMessageWithResolvedParameters
protected String getMessageWithResolvedParameters(PromotionResultModel promotionResult, Locale locale, String messageFiredPositional, List<RuleParameterData> parameters) Formats message by resolving placeholders defined in the message. In case a placeholder cannot be evaluated the placeholder key is preserved in the message- Parameters:
promotionResult-locale-messageFiredPositional-parameters-- Returns:
- formatted message with resolved parameters
-
logUnresolvedPlaceholder
protected void logUnresolvedPlaceholder(PromotionResultModel promotionResult, String resolvedMessage) -
resolveParameterValue
protected Object resolveParameterValue(RuleParameterData parameter, PromotionResultModel promotionResult, Locale locale) -
getFired
Description copied from interface:PromotionResultServiceReturns true if the promotion fired and has produced a result.- Specified by:
getFiredin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion fired
-
getTotalDiscount
Description copied from interface:PromotionResultServiceGet the total value of all discounts in this result. This result will be the same regardless of the applied state of this result, i.e. if not applied this is the discount value that would be applied, if it is applied then it is the value of the discount.- Specified by:
getTotalDiscountin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- The double value for the total discount value
-
isApplied
Description copied from interface:PromotionResultServiceReturns true if the promotion fired and all of its actions have been applied to the order.- Specified by:
isAppliedin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion has been applied
-
isAppliedToOrder
Description copied from interface:PromotionResultServiceReturns true if the promotion fired and all of its actions have been applied to the order. This method checks that all the actions are still applied to the order.- Specified by:
isAppliedToOrderin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion has been applied
-
undo
Description copied from interface:PromotionResultServiceUndo all of the changes that this promotion made to the order.- Specified by:
undoin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- true if calculateTotals() should be called to update the order totals.
-
getPotentialProductPromotions
public List<PromotionResultModel> getPotentialProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Description copied from interface:PromotionResultServiceReturn a list of results for potential promotions that fired and consumed products and have been applied.- Specified by:
getPotentialProductPromotionsin interfacePromotionResultService- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of product promotions that fired and applied
-
getPotentialOrderPromotions
public List<PromotionResultModel> getPotentialOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Description copied from interface:PromotionResultServiceReturn a list of results for potential promotions that fired and did not consume products and have been applied.- Specified by:
getPotentialOrderPromotionsin interfacePromotionResultService- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of order promotions that fired and applied
-
getFiredProductPromotions
public List<PromotionResultModel> getFiredProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Description copied from interface:PromotionResultServiceReturn a list of results for promotions that fired and consumed products.- Specified by:
getFiredProductPromotionsin interfacePromotionResultService- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of product promotions that fired
-
getFiredOrderPromotions
public List<PromotionResultModel> getFiredOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion) Description copied from interface:PromotionResultServiceReturn a list of results for promotions that fired and did not consume products.- Specified by:
getFiredOrderPromotionsin interfacePromotionResultService- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of promotions that fired
-
getCouponCodesFromPromotion
Description copied from interface:PromotionResultServiceReturn give way coupon code for promotion.- Specified by:
getCouponCodesFromPromotionin interfacePromotionResultService- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Optional Set of String containing give way coupon code
-
getDefaultPromotionResultService
-
setDefaultPromotionResultService
public void setDefaultPromotionResultService(DefaultPromotionResultService defaultPromotionResultService) -
getCommonI18NService
-
setCommonI18NService
-
getResolutionStrategies
-
setResolutionStrategies
public void setResolutionStrategies(Map<String, PromotionMessageParameterResolutionStrategy> resolutionStrategies) -
getRuleParametersService
-
setRuleParametersService
-
getCouponCodeRetrievalStrategy
-
setCouponCodeRetrievalStrategy
-
getModelService
-
setModelService
-