Class CachingPromotionsManager
- java.lang.Object
-
- de.hybris.platform.jalo.Manager
-
- de.hybris.platform.jalo.extension.Extension
-
- de.hybris.platform.promotions.jalo.GeneratedPromotionsManager
-
- de.hybris.platform.promotions.jalo.PromotionsManager
-
- de.hybris.platform.promotions.jalo.CachingPromotionsManager
-
- All Implemented Interfaces:
ItemLifecycleListener,java.io.Serializable
- Direct Known Subclasses:
CachingPromotionsManagerTest.MockCachingPromotionsManager
public class CachingPromotionsManager extends PromotionsManager
Created with IntelliJ IDEA. User: gary Date: 08/05/2013 Time: 09:26 To change this template use File | Settings | File Templates.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.promotions.jalo.PromotionsManager
PromotionsManager.AutoApplyMode, PromotionsManager.RestrictionSetResult
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.extension.Extension
Extension.RestrictedLanguagesProvider, Extension.RightsProvider
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCACHING_ALLOWED-
Fields inherited from class de.hybris.platform.promotions.jalo.GeneratedPromotionsManager
CATEGORYPROMOTIONRELATION_MARKMODIFIED, CATEGORYPROMOTIONRELATION_SRC_ORDERED, CATEGORYPROMOTIONRELATION_TGT_ORDERED, DEFAULT_INITIAL_ATTRIBUTES, ORDER2PROMOTIONRESULTSRELATIONALLPROMOTIONRESULTSHANDLER, PRODUCTPROMOTIONRELATION_MARKMODIFIED, PRODUCTPROMOTIONRELATION_SRC_ORDERED, PRODUCTPROMOTIONRELATION_TGT_ORDERED
-
-
Constructor Summary
Constructors Constructor Description CachingPromotionsManager()
-
Method Summary
-
Methods inherited from class de.hybris.platform.promotions.jalo.PromotionsManager
autoApplyApplies, buildQueryForDistinctProductPromotionQuery, cleanupCart, cleanupOrphanedResults, cleanupOrphanedResults, createEssentialData, createPromotionGroup, createPromotionPriceRow, createPromotionPriceRow, createPromotionQuantityAndPricesRow, evaluatePromotion, evaluateRestrictions, evaluateRestrictions, filterPromotionsByRestrictions, findOrderAndProductPromotionsSortByPriority, fixupVouchersReapplyVouchers, fixupVouchersRemoveVouchers, getBaseProductsForOrder, getComposedType, getDefaultPromotionGroup, getDefaultPromotionGroup, getInstance, getLanguageNeutralSessionContext, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getOrderPromotions, getProductPromotions, getProductPromotions, getProductPromotions, getPromotionGroup, getPromotionResults, getPromotionResults, initialiseDefaultLocalisedValues, initialiseDefaultLocalisedValues, keepApplied, makeActionGUID, notifyInitializationEnd, notifyInitializationStart, sortByPromotionPriority, transferPromotionsToOrder, updatePromotions, updatePromotionsNotThreadSafe
-
Methods inherited from class de.hybris.platform.promotions.jalo.GeneratedPromotionsManager
addToAllPromotionResults, addToAllPromotionResults, addToPromotions, addToPromotions, addToPromotions, addToPromotions, createAbstractPromotionAction, createAbstractPromotionAction, createAbstractPromotionRestriction, createAbstractPromotionRestriction, createCachedPromotionNullAction, createCachedPromotionNullAction, createCachedPromotionOrderAddFreeGiftAction, createCachedPromotionOrderAddFreeGiftAction, createCachedPromotionOrderAdjustTotalAction, createCachedPromotionOrderAdjustTotalAction, createCachedPromotionOrderChangeDeliveryModeAction, createCachedPromotionOrderChangeDeliveryModeAction, createCachedPromotionOrderEntryAdjustAction, createCachedPromotionOrderEntryAdjustAction, createCachedPromotionOrderEntryConsumed, createCachedPromotionOrderEntryConsumed, createCachedPromotionResult, createCachedPromotionResult, createOrderPromotion, createOrderPromotion, createOrderThresholdChangeDeliveryModePromotion, createOrderThresholdChangeDeliveryModePromotion, createOrderThresholdDiscountPromotion, createOrderThresholdDiscountPromotion, createOrderThresholdFreeGiftPromotion, createOrderThresholdFreeGiftPromotion, createOrderThresholdFreeVoucherPromotion, createOrderThresholdFreeVoucherPromotion, createOrderThresholdPerfectPartnerPromotion, createOrderThresholdPerfectPartnerPromotion, createProductBOGOFPromotion, createProductBOGOFPromotion, createProductBundlePromotion, createProductBundlePromotion, createProductFixedPricePromotion, createProductFixedPricePromotion, createProductMultiBuyPromotion, createProductMultiBuyPromotion, createProductOneToOnePerfectPartnerPromotion, createProductOneToOnePerfectPartnerPromotion, createProductPercentageDiscountPromotion, createProductPercentageDiscountPromotion, createProductPerfectPartnerBundlePromotion, createProductPerfectPartnerBundlePromotion, createProductPerfectPartnerPromotion, createProductPerfectPartnerPromotion, createProductPromotion, createProductPromotion, createProductSteppedMultiBuyPromotion, createProductSteppedMultiBuyPromotion, createPromotionGroup, createPromotionGroup, createPromotionNullAction, createPromotionNullAction, createPromotionOrderAddFreeGiftAction, createPromotionOrderAddFreeGiftAction, createPromotionOrderAdjustTotalAction, createPromotionOrderAdjustTotalAction, createPromotionOrderChangeDeliveryModeAction, createPromotionOrderChangeDeliveryModeAction, createPromotionOrderEntryAdjustAction, createPromotionOrderEntryAdjustAction, createPromotionOrderEntryConsumed, createPromotionOrderEntryConsumed, createPromotionPriceRow, createPromotionPriceRow, createPromotionProductRestriction, createPromotionProductRestriction, createPromotionQuantityAndPricesRow, createPromotionQuantityAndPricesRow, createPromotionResult, createPromotionResult, createPromotionUserRestriction, createPromotionUserRestriction, getAllPromotionResults, getAllPromotionResults, getDefaultAttributeModes, getName, getPreviousDeliveryMode, getPreviousDeliveryMode, getPromotions, getPromotions, getPromotions, getPromotions, getPromotionsCount, getPromotionsCount, getPromotionsCount, getPromotionsCount, removeFromAllPromotionResults, removeFromPromotions, removeFromPromotions, removeFromPromotions, removeFromPromotions, setAllPromotionResults, setAllPromotionResults, setPreviousDeliveryMode, setPreviousDeliveryMode, setPromotions, setPromotions, setPromotions, setPromotions
-
Methods inherited from class de.hybris.platform.jalo.extension.Extension
checkBeforeItemRemoval, createProjectData, createSampleData, getCreatorDescription, getCreatorName, getCreatorParameterDefault, getCreatorParameterNames, getCreatorParameterPossibleValues, getRemote, isCreatorDisabled, notifyItemRemoval, onFirstSessionCreation, writeReplace
-
Methods inherited from class de.hybris.platform.jalo.Manager
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, init, setAttribute, setTenant, setTransientObject, wrap
-
-
-
-
Field Detail
-
CACHING_ALLOWED
protected static final java.lang.String CACHING_ALLOWED
- See Also:
- Constant Field Values
-
-
Method Detail
-
updatePromotions
public PromotionOrderResults updatePromotions(SessionContext ctx, java.util.Collection<PromotionGroup> promotionGroups, AbstractOrder order)
Description copied from class:PromotionsManagerUpdate the promotions on the specifiedAbstractOrderobject. This method will automatically apply all possible product promotional updates to the cart, but not apply order level promotions. Any previously applied order level promotions will remain applied. Promotions are evaluated at the current system time. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callingPromotionsManager.getPromotionResults(de.hybris.platform.jalo.order.AbstractOrder).- Overrides:
updatePromotionsin classPromotionsManager- Parameters:
ctx- The hybris session contextpromotionGroups- The promotion groups to evaluateorder- The order object to update with the results of the promotions- Returns:
- The promotion results
- See Also:
PromotionsManager.updatePromotions(SessionContext, Collection, AbstractOrder, boolean, AutoApplyMode, AutoApplyMode, Date),PromotionsManager.getPromotionResults(de.hybris.platform.jalo.order.AbstractOrder),PromotionsManager.getPromotionResults(de.hybris.platform.jalo.SessionContext, de.hybris.platform.jalo.order.AbstractOrder),PromotionsManager.getPromotionResults(SessionContext, Collection, AbstractOrder, boolean, AutoApplyMode, AutoApplyMode, Date)
-
updatePromotions
public PromotionOrderResults updatePromotions(SessionContext ctx, java.util.Collection<PromotionGroup> promotionGroups, AbstractOrder order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Description copied from class:PromotionsManagerUpdate the promotions on the specifiedAbstractOrderobject. The resulting promotions can be retrieved later by callingPromotionsManager.getPromotionResults(de.hybris.platform.jalo.order.AbstractOrder). The order must be calculated before calling this method.PromotionsManager.updatePromotions(java.util.Collection<de.hybris.platform.promotions.jalo.PromotionGroup>, de.hybris.platform.jalo.order.AbstractOrder)must be called after callingAbstractOrder.recalculate()on theAbstractOrder. Where thePromotionsManager.AutoApplyModeis set toPromotionsManager.AutoApplyMode.KEEP_APPLIEDthe state of any previously appliedPromotionResultis recorded and if it is still in the fired state (PromotionResult.isApplied()) after reevaluating the promotions it will be automatically reapplied. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callingPromotionsManager.getPromotionResults(de.hybris.platform.jalo.order.AbstractOrder).- Overrides:
updatePromotionsin classPromotionsManager- Parameters:
ctx- The hybris session contextpromotionGroups- The promotion groups to evaluateorder- The AbstractOrder object to update the promotions forevaluateRestrictions- If true any promotion restrictions will be observed, if false all promotion restrictions are ignoredproductPromotionMode- The auto apply mode. This determines whether this method applies any product promotional changes to line items or discounts to the overall amountorderPromotionMode- The auto apply mode. This determines whether this method applies any order promotional changes to line items or discounts to the overall amountdate- The effective date for the promotions to check. Use this to to see the effects of promotions in the past or future.- Returns:
- The promotion results
- See Also:
PromotionsManager.getPromotionResults(de.hybris.platform.jalo.order.AbstractOrder),PromotionsManager.getPromotionResults(de.hybris.platform.jalo.SessionContext, de.hybris.platform.jalo.order.AbstractOrder),PromotionsManager.getPromotionResults(SessionContext, Collection, AbstractOrder, boolean, AutoApplyMode, AutoApplyMode, Date)
-
getPromotionResults
public PromotionOrderResults getPromotionResults(SessionContext ctx, AbstractOrder order)
Description copied from class:PromotionsManagerGet the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toPromotionsManager.updatePromotions(java.util.Collection<de.hybris.platform.promotions.jalo.PromotionGroup>, de.hybris.platform.jalo.order.AbstractOrder)for the same order. If any of the promotion results are invalid then they will be ignored. To force the list of promotions to be recalculated either callPromotionsManager.updatePromotions(java.util.Collection<de.hybris.platform.promotions.jalo.PromotionGroup>, de.hybris.platform.jalo.order.AbstractOrder)or call the version ofPromotionsManager.getPromotionResults(SessionContext, Collection, AbstractOrder, boolean, AutoApplyMode, AutoApplyMode, Date).- Overrides:
getPromotionResultsin classPromotionsManager- Parameters:
ctx- The session contextorder- The order to get the promotion results for- Returns:
- The promotion results
- See Also:
PromotionsManager.updatePromotions(Collection, AbstractOrder),PromotionsManager.updatePromotions(SessionContext, Collection, AbstractOrder),PromotionsManager.updatePromotions(SessionContext, Collection, AbstractOrder, boolean, AutoApplyMode, AutoApplyMode, Date)
-
cleanupCart
public void cleanupCart(SessionContext ctx, Cart cart)
Description copied from class:PromotionsManagerDelete the the stored promotion results for a Cart.- Overrides:
cleanupCartin classPromotionsManager- Parameters:
ctx- The session contextcart- TheCartto delete the results for
-
transferPromotionsToOrder
public void transferPromotionsToOrder(SessionContext ctx, AbstractOrder source, Order target, boolean onlyTransferAppliedPromotions)
Description copied from class:PromotionsManagerTransfer the promotions applied to a cart to a new order. This is used when an order is created from a cart.- Overrides:
transferPromotionsToOrderin classPromotionsManager- Parameters:
ctx- The session contextsource- The cart that has promotionstarget- The order that promotions should be applied toonlyTransferAppliedPromotions- Flag to indicate that only applied promotions should be transfered. If false all promotion results will be transfered
-
getPromotionResultsInternal
protected java.util.List<PromotionResult> getPromotionResultsInternal(SessionContext ctx, AbstractOrder order)
Description copied from class:PromotionsManagerGet the list of promotion results for the specified order.- Overrides:
getPromotionResultsInternalin classPromotionsManager- Parameters:
ctx- The session contextorder- The order to get the promotion results for- Returns:
- The promotion results
-
deleteStoredPromotionResults
protected void deleteStoredPromotionResults(SessionContext ctx, AbstractOrder order, boolean undoActions)
Description copied from class:PromotionsManagerDelete the the stored promotion results for an AbstractOrder.- Overrides:
deleteStoredPromotionResultsin classPromotionsManager- Parameters:
ctx- The session contextorder- The order to delete the results forundoActions- Undo the actions before deleting the promotion results
-
createPromotionOrderEntryConsumed
public PromotionOrderEntryConsumed createPromotionOrderEntryConsumed(SessionContext ctx, java.lang.String code, AbstractOrderEntry orderEntry, long quantity)
Description copied from class:PromotionsManagerCreate a newPromotionOrderEntryConsumedinstance.- Overrides:
createPromotionOrderEntryConsumedin classPromotionsManager- Parameters:
ctx- The session contextcode- The object's codeorderEntry- TheAbstractOrderEntrythat is the base order entry for the objectquantity- The quantity mapped through from the base order entry- Returns:
- the new
PromotionOrderEntryConsumed
-
createPromotionOrderEntryConsumed
public PromotionOrderEntryConsumed createPromotionOrderEntryConsumed(SessionContext ctx, java.lang.String code, AbstractOrderEntry orderEntry, long quantity, double adjustedUnitPrice)
Description copied from class:PromotionsManagerCreate a newPromotionOrderEntryConsumedinstance.- Overrides:
createPromotionOrderEntryConsumedin classPromotionsManager- Parameters:
ctx- The session contextcode- The object's codeorderEntry- TheAbstractOrderEntrythat is the base order entry for the objectquantity- The quantity mapped through from the base order entryadjustedUnitPrice- The adjusted unit price- Returns:
- the new
PromotionOrderEntryConsumed
-
createPromotionResult
public PromotionResult createPromotionResult(SessionContext ctx, AbstractPromotion promotion, AbstractOrder order, float certainty)
Description copied from class:PromotionsManagerCreate a newPromotionResultinstance.- Overrides:
createPromotionResultin classPromotionsManager- Parameters:
ctx- The session contextpromotion- TheAbstractPromotionthat created thePromotionResultorder- TheAbstractOrderthat thePromotionResultis related tocertainty- The certainty of firing in the range 0 to 1. 1.0 is fired, less than 1.0 is could fire.- Returns:
- the new
PromotionResult
-
createPromotionOrderAdjustTotalAction
public PromotionOrderAdjustTotalAction createPromotionOrderAdjustTotalAction(SessionContext ctx, double totalAdjustment)
Description copied from class:PromotionsManagerCreate a newPromotionOrderAdjustTotalActioninstance.- Overrides:
createPromotionOrderAdjustTotalActionin classPromotionsManager- Parameters:
ctx- The session contexttotalAdjustment- The amount to adjust the order total (positive increases order total, negative decreases)- Returns:
- the new
PromotionOrderAdjustTotalAction
-
createPromotionOrderAddFreeGiftAction
public PromotionOrderAddFreeGiftAction createPromotionOrderAddFreeGiftAction(SessionContext ctx, Product product, PromotionResult result)
Description copied from class:PromotionsManagerCreate a newPromotionOrderAddFreeGiftActioninstance.- Overrides:
createPromotionOrderAddFreeGiftActionin classPromotionsManager- Parameters:
ctx- The session contextproduct- TheProductto give awayresult- ThePromotionResultthat owns this action.- Returns:
- the new
PromotionOrderAddFreeGiftAction
-
createPromotionOrderChangeDeliveryModeAction
public PromotionOrderChangeDeliveryModeAction createPromotionOrderChangeDeliveryModeAction(SessionContext ctx, DeliveryMode deliveryMode)
Description copied from class:PromotionsManagerCreate a newPromotionOrderChangeDeliveryModeActioninstance.- Overrides:
createPromotionOrderChangeDeliveryModeActionin classPromotionsManager- Parameters:
ctx- The session contextdeliveryMode- TheDeliveryModeto set on the order- Returns:
- the new
PromotionOrderChangeDeliveryModeAction
-
createPromotionOrderEntryAdjustAction
public PromotionOrderEntryAdjustAction createPromotionOrderEntryAdjustAction(SessionContext ctx, AbstractOrderEntry entry, long quantity, double adjustment)
Description copied from class:PromotionsManagerCreate a newPromotionOrderEntryAdjustActioninstance.- Overrides:
createPromotionOrderEntryAdjustActionin classPromotionsManager- Parameters:
ctx- The session contextentry- TheAbstractOrderEntryto adjustquantity- The quantity to adjustadjustment- The adjustment to make- Returns:
- the new
PromotionOrderEntryAdjustAction
-
createPromotionOrderEntryAdjustAction
public PromotionOrderEntryAdjustAction createPromotionOrderEntryAdjustAction(SessionContext ctx, AbstractOrderEntry entry, double adjustment)
Description copied from class:PromotionsManagerThis does not store the order entry but records its information so that a similar order entry with the same product and quantity can be located in this and other orders.- Overrides:
createPromotionOrderEntryAdjustActionin classPromotionsManager- Parameters:
ctx- The session contextentry- TheAbstractOrderEntryto adjustadjustment- The adjustment to make- Returns:
- the new
PromotionOrderEntryAdjustAction
-
createPromotionNullAction
public PromotionNullAction createPromotionNullAction(SessionContext ctx)
Description copied from class:PromotionsManagerCreate a newPromotionNullActioninstance.- Overrides:
createPromotionNullActionin classPromotionsManager- Parameters:
ctx- The session context- Returns:
- the new
PromotionNullAction
-
removeFromAllPromotionResults
public void removeFromAllPromotionResults(SessionContext ctx, AbstractOrder item, PromotionResult value)
Description copied from class:GeneratedPromotionsManagerGenerated method - Removesvaluefrom allPromotionResults.- Overrides:
removeFromAllPromotionResultsin classGeneratedPromotionsManagervalue- the item to remove from allPromotionResults
-
doUpdatePromotions
protected PromotionOrderResults doUpdatePromotions(SessionContext ctx, java.util.Collection<PromotionGroup> promotionGroups, AbstractOrder order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
-
doUpdatePromotionsOutOfCache
protected PromotionOrderResults doUpdatePromotionsOutOfCache(SessionContext ctx, java.util.Collection<PromotionGroup> promotionGroups, AbstractOrder order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
-
getNonCachedPromotionResultsInternal
protected java.util.List<PromotionResult> getNonCachedPromotionResultsInternal(SessionContext ctx, AbstractOrder order)
-
applyWithCachingEnabled
protected <T> T applyWithCachingEnabled(SessionContext ctx, AbstractOrder order, java.util.function.BiFunction<SessionContext,AbstractOrder,T> function)
-
getCurrentJaloSession
protected JaloSession getCurrentJaloSession()
-
acceptWithCachingEnabled
protected void acceptWithCachingEnabled(SessionContext ctx, AbstractOrder order, java.util.function.BiConsumer<SessionContext,AbstractOrder> consumer)
-
setCachingAllowed
protected void setCachingAllowed(SessionContext ctx, AbstractOrder order)
-
isCachingAllowed
protected boolean isCachingAllowed(SessionContext ctx)
-
getCache
public CachingStrategy getCache()
-
setCache
public void setCache(CachingStrategy cache)
-
-