Class DefaultPromotionEngineResultService
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultPromotionEngineResultService
-
- All Implemented Interfaces:
PromotionResultService
public class DefaultPromotionEngineResultService extends java.lang.Object implements PromotionResultService
Default implementation of PromotionResultService
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringEMPTY_VALUEprotected static java.util.regex.PatternLIST_PATTERNprotected static java.util.regex.PatternMAP_PATTERN
-
Constructor Summary
Constructors Constructor Description DefaultPromotionEngineResultService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(PromotionResultModel promotionResult)Apply all of the actions that this promotion generated to the order.protected CommonI18NServicegetCommonI18NService()longgetConsumedCount(PromotionResultModel promotionResult, boolean paramBoolean)Get the total number of items consumed by this promotion.booleangetCouldFire(PromotionResultModel promotionResult)Is this a potential result.protected CouponCodeRetrievalStrategygetCouponCodeRetrievalStrategy()java.util.Optional<java.util.Set<java.lang.String>>getCouponCodesFromPromotion(PromotionResultModel promotionResult)Return give way coupon code for promotion.protected DefaultPromotionResultServicegetDefaultPromotionResultService()java.lang.StringgetDescription(PromotionResultModel promotionResult)Get the description of this promotion result.java.lang.StringgetDescription(PromotionResultModel promotionResult, java.util.Locale locale)Get the description of this promotion result.booleangetFired(PromotionResultModel promotionResult)Returns true if the promotion fired and has produced a result.java.util.List<PromotionResultModel>getFiredOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for promotions that fired and did not consume products.java.util.List<PromotionResultModel>getFiredProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for promotions that fired and consumed products.protected java.lang.StringgetMessageWithResolvedParameters(PromotionResultModel promotionResult, java.util.Locale locale, java.lang.String messageFiredPositional, java.util.List<RuleParameterData> parameters)Formats message by resolving placeholders defined in the message.protected ModelServicegetModelService()java.util.List<PromotionResultModel>getPotentialOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for potential promotions that fired and did not consume products and have been applied.java.util.List<PromotionResultModel>getPotentialProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for potential promotions that fired and consumed products and have been applied.protected java.util.Map<java.lang.String,PromotionMessageParameterResolutionStrategy>getResolutionStrategies()protected RuleParametersServicegetRuleParametersService()doublegetTotalDiscount(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(java.util.List<RuleParameterData> parameters, java.util.Map<java.lang.String,java.lang.Object> messageActionValues)protected voidlogUnresolvedPlaceholder(PromotionResultModel promotionResult, java.lang.String resolvedMessage)protected RuleParameterDatareplaceRuleParameterValue(PromotionResultModel promotionResult, java.util.Map<java.lang.String,java.lang.Object> messageActionValues, RuleParameterData parameter)protected java.lang.ObjectresolveParameterValue(RuleParameterData parameter, PromotionResultModel promotionResult, java.util.Locale locale)voidsetCommonI18NService(CommonI18NService commonI18NService)voidsetCouponCodeRetrievalStrategy(CouponCodeRetrievalStrategy couponCodeRetrievalStrategy)voidsetDefaultPromotionResultService(DefaultPromotionResultService defaultPromotionResultService)voidsetModelService(ModelService modelService)voidsetResolutionStrategies(java.util.Map<java.lang.String,PromotionMessageParameterResolutionStrategy> resolutionStrategies)voidsetRuleParametersService(RuleParametersService ruleParametersService)booleanundo(PromotionResultModel promotionResult)Undo all of the changes that this promotion made to the order.
-
-
-
Field Detail
-
EMPTY_VALUE
protected static final java.lang.String EMPTY_VALUE
- See Also:
- Constant Field Values
-
LIST_PATTERN
protected static final java.util.regex.Pattern LIST_PATTERN
-
MAP_PATTERN
protected static final java.util.regex.Pattern MAP_PATTERN
-
-
Method Detail
-
getDescription
public java.lang.String getDescription(PromotionResultModel promotionResult)
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:
PromotionResultService.getDescription(PromotionResultModel, java.util.Locale)
-
apply
public boolean apply(PromotionResultModel promotionResult)
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
public long getConsumedCount(PromotionResultModel promotionResult, boolean paramBoolean)
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
public boolean getCouldFire(PromotionResultModel promotionResult)
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
public java.lang.String getDescription(PromotionResultModel promotionResult, java.util.Locale locale)
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(java.util.List<RuleParameterData> parameters, java.util.Map<java.lang.String,java.lang.Object> messageActionValues)
-
isRuleBasedPromotion
protected boolean isRuleBasedPromotion(AbstractPromotionModel abstractPromotion)
-
replaceRuleParameterValue
protected RuleParameterData replaceRuleParameterValue(PromotionResultModel promotionResult, java.util.Map<java.lang.String,java.lang.Object> messageActionValues, RuleParameterData parameter)
-
getMessageWithResolvedParameters
protected java.lang.String getMessageWithResolvedParameters(PromotionResultModel promotionResult, java.util.Locale locale, java.lang.String messageFiredPositional, java.util.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, java.lang.String resolvedMessage)
-
resolveParameterValue
protected java.lang.Object resolveParameterValue(RuleParameterData parameter, PromotionResultModel promotionResult, java.util.Locale locale)
-
getFired
public boolean getFired(PromotionResultModel promotionResult)
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
public double getTotalDiscount(PromotionResultModel promotionResult)
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
public boolean isApplied(PromotionResultModel promotionResult)
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
public boolean isAppliedToOrder(PromotionResultModel promotionResult)
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
public boolean undo(PromotionResultModel promotionResult)
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 java.util.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 java.util.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 java.util.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 java.util.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
public java.util.Optional<java.util.Set<java.lang.String>> getCouponCodesFromPromotion(PromotionResultModel promotionResult)
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
protected DefaultPromotionResultService getDefaultPromotionResultService()
-
setDefaultPromotionResultService
public void setDefaultPromotionResultService(DefaultPromotionResultService defaultPromotionResultService)
-
getCommonI18NService
protected CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
getResolutionStrategies
protected java.util.Map<java.lang.String,PromotionMessageParameterResolutionStrategy> getResolutionStrategies()
-
setResolutionStrategies
public void setResolutionStrategies(java.util.Map<java.lang.String,PromotionMessageParameterResolutionStrategy> resolutionStrategies)
-
getRuleParametersService
protected RuleParametersService getRuleParametersService()
-
setRuleParametersService
public void setRuleParametersService(RuleParametersService ruleParametersService)
-
getCouponCodeRetrievalStrategy
protected CouponCodeRetrievalStrategy getCouponCodeRetrievalStrategy()
-
setCouponCodeRetrievalStrategy
public void setCouponCodeRetrievalStrategy(CouponCodeRetrievalStrategy couponCodeRetrievalStrategy)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
-