Class AbstractRuleActionStrategy<A extends AbstractRuleBasedPromotionActionModel>
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.action.impl.AbstractRuleActionStrategy<A>
-
- All Implemented Interfaces:
RuleActionStrategy
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
- Direct Known Subclasses:
DefaultAddCouponActionStrategy
,DefaultAddProductToCartActionStrategy
,DefaultOrderAdjustTotalActionStrategy
,DefaultOrderEntryAdjustActionStrategy
,DefaultPotentialPromotionMessageActionStrategy
,DefaultShippingActionStrategy
public abstract class AbstractRuleActionStrategy<A extends AbstractRuleBasedPromotionActionModel> extends java.lang.Object implements RuleActionStrategy, org.springframework.beans.factory.BeanNameAware
Abstract base class for Rule Action Strategy.
-
-
Constructor Summary
Constructors Constructor Description AbstractRuleActionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected A
createPromotionAction(PromotionResultModel promotionResult, AbstractRuleActionRAO action)
Creates an instance of the configuredpromotionAction
(which is a subtype ofRuleBasedPromotionActionModel
, sets a new unique UUID, sets this strategy's id, marks the action as applied, attaches the givenpromotionResult
and tries to lookup the rule which created the givenAbstractRuleActionRAO
.protected ActionUtils
getActionUtils()
protected CalculationService
getCalculationService()
protected ExtendedOrderDao
getExtendedOrderDao()
protected java.lang.Boolean
getForceImmediateRecalculation()
protected java.util.List<RuleActionMetadataHandler>
getMetadataHandlers(java.lang.String mdKey)
protected ModelService
getModelService()
protected java.lang.Class<A>
getPromotionAction()
protected PromotionActionService
getPromotionActionService()
protected PromotionResultUtils
getPromotionResultUtils()
protected java.util.Map<java.lang.String,java.util.List<RuleActionMetadataHandler>>
getRuleActionMetadataHandlers()
java.lang.String
getStrategyId()
Returns this strategy's unique Idprotected void
handleActionMetadata(AbstractRuleActionRAO action, AbstractRuleBasedPromotionActionModel actionModel)
protected void
handleUndoActionMetadata(AbstractRuleBasedPromotionActionModel action)
protected boolean
recalculateIfNeeded(AbstractOrderModel order)
recalculates the givenorder
if the#forceImmediateRecalculation
flag is set totrue
.void
setActionUtils(ActionUtils actionUtils)
void
setBeanName(java.lang.String beanName)
void
setCalculationService(CalculationService calculationService)
void
setExtendedOrderDao(ExtendedOrderDao extendedOrderDao)
void
setForceImmediateRecalculation(java.lang.Boolean forceImmediateRecalculation)
void
setModelService(ModelService modelService)
void
setPromotionAction(java.lang.Class<A> promotionAction)
void
setPromotionActionService(PromotionActionService promotionActionService)
void
setPromotionResultUtils(PromotionResultUtils promotionResultUtils)
void
setRuleActionMetadataHandlers(java.util.Map<java.lang.String,java.util.List<RuleActionMetadataHandler>> ruleActionMetadataHandlers)
protected AbstractOrderModel
undoInternal(A action)
removes the givenaction
(if it is not already removed), its associated DiscountValues and its PromotionResult (if the PromotionResult has no other actions associated with it).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.ruleengineservices.action.RuleActionStrategy
apply, undo
-
-
-
-
Method Detail
-
createPromotionAction
protected A createPromotionAction(PromotionResultModel promotionResult, AbstractRuleActionRAO action)
Creates an instance of the configuredpromotionAction
(which is a subtype ofRuleBasedPromotionActionModel
, sets a new unique UUID, sets this strategy's id, marks the action as applied, attaches the givenpromotionResult
and tries to lookup the rule which created the givenAbstractRuleActionRAO
. Note: the action is created through themodelService
, but it is not saved.- Parameters:
promotionResult
- the promotionResult that the to-be-created promotion action belongs toaction
- the action rao- Returns:
- the newly created instance
-
handleActionMetadata
protected void handleActionMetadata(AbstractRuleActionRAO action, AbstractRuleBasedPromotionActionModel actionModel)
-
handleUndoActionMetadata
protected void handleUndoActionMetadata(AbstractRuleBasedPromotionActionModel action)
-
getMetadataHandlers
protected java.util.List<RuleActionMetadataHandler> getMetadataHandlers(java.lang.String mdKey)
-
undoInternal
protected AbstractOrderModel undoInternal(A action)
removes the givenaction
(if it is not already removed), its associated DiscountValues and its PromotionResult (if the PromotionResult has no other actions associated with it).- Parameters:
action
- the action to undo- Returns:
- the action's associated order (or null if the action is already removed)
-
recalculateIfNeeded
protected boolean recalculateIfNeeded(AbstractOrderModel order)
recalculates the givenorder
if the#forceImmediateRecalculation
flag is set totrue
.- Parameters:
order
- the order to recalculate- Returns:
- false if the recalculation failed, otherwise true
-
getExtendedOrderDao
protected ExtendedOrderDao getExtendedOrderDao()
-
setExtendedOrderDao
public void setExtendedOrderDao(ExtendedOrderDao extendedOrderDao)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getPromotionAction
protected java.lang.Class<A> getPromotionAction()
-
setPromotionAction
public void setPromotionAction(java.lang.Class<A> promotionAction)
-
getPromotionActionService
protected PromotionActionService getPromotionActionService()
-
setPromotionActionService
public void setPromotionActionService(PromotionActionService promotionActionService)
-
getForceImmediateRecalculation
protected java.lang.Boolean getForceImmediateRecalculation()
-
setForceImmediateRecalculation
public void setForceImmediateRecalculation(java.lang.Boolean forceImmediateRecalculation)
-
getCalculationService
protected CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
setBeanName
public void setBeanName(java.lang.String beanName)
- Specified by:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
-
getStrategyId
public java.lang.String getStrategyId()
Description copied from interface:RuleActionStrategy
Returns this strategy's unique Id- Specified by:
getStrategyId
in interfaceRuleActionStrategy<A extends AbstractRuleBasedPromotionActionModel>
- Returns:
- the strategy's Id
-
getRuleActionMetadataHandlers
protected java.util.Map<java.lang.String,java.util.List<RuleActionMetadataHandler>> getRuleActionMetadataHandlers()
-
setRuleActionMetadataHandlers
public void setRuleActionMetadataHandlers(java.util.Map<java.lang.String,java.util.List<RuleActionMetadataHandler>> ruleActionMetadataHandlers)
-
getPromotionResultUtils
protected PromotionResultUtils getPromotionResultUtils()
-
setPromotionResultUtils
public void setPromotionResultUtils(PromotionResultUtils promotionResultUtils)
-
getActionUtils
protected ActionUtils getActionUtils()
-
setActionUtils
public void setActionUtils(ActionUtils actionUtils)
-
-