public class PromotionContext
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright
|
Constructor and Description |
---|
PromotionContext(PromotionEngine aEngine,
PromotionExecutionAgenda aAgenda,
PromotionArgument aArgument)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addPromotionExecutionRecord(PromotionExecutionRecord record)
Append a promotion execution record to the list of current promotion
execution records.
|
void |
addPromotionExecutionRecordToArgument(PromotionExecutionRecord record)
Appends a promotion execution record to PromotionArgument.
|
ProtectedContextAttribute |
addProtectedContextAttribute(java.lang.String name,
ProtectedContextAttribute attr)
Adds a named protected context attribute.
|
void |
addRewardOptionForPromotion(PromotionKey aPromotionKey,
RewardOption aRewardOption)
Adds a RewardOption for a specific promotion.
|
java.lang.Object |
addUnprotectedContextAttribute(java.lang.String name,
java.lang.Object attr)
Adds a named un-protected context attribute.
|
com.ibm.commerce.marketing.promotion.coupon.Coupon |
allocateCoupon(Promotion promotion)
Allocates an available coupon for a promotion.
|
void |
appendPromotionErrorReport(PromotionErrorReport report)
Appends a promotion error report to a list of error reports
|
void |
clearAttributeNamesInCache()
This method clears the transaction cache that stores all attribute names for all PromotionContext objects
|
java.lang.Object |
clone() |
void |
commitPCB(PromotionContext context)
Commits all the changes in the current promotion execution control block.
|
PromotionExecutionAgenda |
getAgenda()
Gets the PromotionExecutionAgenda for the PromotionContext.
|
java.util.List |
getAllAttributeNames()
gets all the attribute names stored in cache in the promotion context specified
|
java.util.Enumeration |
getApplicablePolicies(Promotion promotion)
Returns a list of promotion policies applicable to a promotion according
to the PromotionExecutionAgenda.
|
java.util.List |
getAppliedCodesFor(Promotion promotion)
Returns a subset of promotion codes entered for a promotion.
|
PromotionArgument |
getArgument()
Returns the argument.
|
java.lang.String |
getCodeFor(Promotion promotion)
Returns the first code entered for a promotion
|
java.util.List |
getCodesFor(Promotion promotion)
Returns a list of all promotion codes entered for a promotion
|
java.util.Hashtable |
getCodeToPromotionMap()
Returns the codeToPromotionMap.
|
com.ibm.commerce.marketing.promotion.coupon.Coupon[] |
getCouponFor(Promotion promotion)
Returns an array of coupons entered for a promotion
|
java.util.Hashtable |
getCouponToPromotionMap()
Returns the map between promotions and coupons
|
PriceConverter |
getCurrencyConverter()
Returns a currency converter
|
PromotionExecutionRecord |
getCurrentPromotionExecutionRecord()
Gets the current PromotionExecutionRecord object.
|
PromotionExecutionRecord[] |
getCurrentResults()
Returns the currentResults.
|
PromotionEngine |
getEngine()
Returns the engine.
|
java.util.Hashtable |
getFullCodeToPromotionMap()
Returns the codeToPromotionMap containing the promotion key as the key
and a list of codes as the value.
|
java.util.Enumeration |
getGovernedPromotions(PromotionPolicy policy)
Returns a list of promotions governed by a promotion policy according to
the PromotionExecutionAgenda.
|
com.ibm.commerce.marketing.promotion.group.PromotionGroup[] |
getGroups()
Returns all the promotion groups be evaluated in this invocation
|
LineItemSet |
getLineItemsCanBeAffectedByCurrentPromotion()
Returns a LineItemSet of associated order items that can be affected by
the current promotion.
|
LineItemSet |
getLineItemsCanBeTargetedByCurrentPromotion()
Returns a LineItemSet of associated order items that can be targeted by
the current promotion.
|
LineItemSet |
getLineItemsCanNotBeAffectedByCurrentPromotion()
Returns a LineItemSet of associated order items that can no longer be
affected by the current promotion.
|
LineItemSet |
getLineItemsCanNotBeTargetedByCurrentPromotion()
Returns a LineItemSet of associated order items that can no longer be
targeted by the current promotion.
|
Order |
getOrder()
Returns the order to which promotions will be applied
|
LineItemSet |
getOrderAsALineItemSet()
Returns the original order as an LineItemSet
|
java.lang.String |
getOrderCurrency()
Returns the currency of the order
|
java.math.BigDecimal |
getOrderQualifyingTotal(int types)
Returns the current order qualifying total for a combination of any of
the four values: price, shipping, shipping tax, and tax.
|
java.math.BigDecimal |
getOrderRunningTotal(int type)
Returns the running total for the order with which this
OrderRunningTotalController was initialized.
|
Promotion |
getPromotionCurrentlyUnderEvaluation()
Returns the current promotion under evaluation
|
PromotionErrorReport[] |
getPromotionErrorReports()
Returns all the promotion error reports accumulated so far.
|
ProtectedContextAttribute |
getProtectedContextAttribute(java.lang.String name)
Returns a protected context attribute object.
|
OrderQualifyingTotal |
getQualifyingTotalObject()
Returns the qualifying total object on the context object
|
int |
getRedemptionCountForThisPromotion(Promotion promotion)
Returns the number of times a promotion has been redeemed
|
int |
getRedemptionCountForThisPromotionForCurrentShopper(Promotion promotion)
Returns the number of times a promotion has been redeemed by a shopper
|
int |
getRedemptionCountForThisPromotionInCurrentOrder(Promotion promotion)
Returns the number of times a promotion has been redeemed in this order
|
java.util.List |
getRewardOptionForPromotion(PromotionKey aPromotionKey)
Gets list of RewardOption object for a specific promotion.
|
java.util.Map |
getRewardOptions()
Gets the RewardOption map object.
|
Rounding |
getRounding()
Returns a rounding
|
java.math.BigDecimal |
getRunningTotalFor(AssociatedOrderItem[] items,
int type)
Returns the running total for an array of order items or portions of them
as identified by the AssociatedOrderItem array parameter.
|
java.math.BigDecimal |
getRunningTotalFor(AssociatedOrderItem anItem,
int type)
Returns the running total for an order item or a portion of it as
identified by the AssociatedOrderItem parameter.
|
java.math.BigDecimal |
getRunningTotalFor(LineItemSet set,
int type)
Returns the running total for everything in a LineItemSet.
|
java.math.BigDecimal |
getRunningTotalFor(OrderItem item,
int type)
Returns the running total for an order item.
|
OrderRunningTotal |
getRunningTotalObject()
Returns the running total object on the context object
|
java.util.Vector |
getSequence()
Returns the sequence.
|
java.util.Map<java.lang.String,java.lang.String> |
getSimulatedPromotionEvaluationConfigurations()
Gets the Map object that contains the optional evaluation configurations as name value pairs.
|
StoreKey |
getStoreKey()
Returns the key of the store
|
java.lang.Object |
getUnprotectedContextAttribute(java.lang.String name)
Returns an un-protected context attribute object.
|
boolean |
hasNextPromotion()
Returns true if there are more promotions to be evaluated in the
promotion evaluation sequence
|
void |
initPCB(PromotionContext context)
Initializes the promotion execution control block
|
boolean |
isCodeEnteredFor(Promotion promotion)
Checks if promotion code is entered for a promotion or not
|
boolean |
isCouponAddedFor(Promotion promotion)
Checks to see if coupon has been added for a promotion
|
boolean |
isPricePresent()
Indicates if price is calculated when this template is invoked.
|
boolean |
isShippingChargePresent()
Indicates if shipping charge is calculated when this template is invoked.
|
boolean |
isShippingTaxPresent()
Indicates if shipping tax is calculated when this template is invoked.
|
boolean |
isTaxPresent()
Indicates if tax is calculated when this template is invoked.
|
boolean |
isUnderSimulatedPromotionEvaluationMode()
Return true or false that indicates the promotion engine is evaluating
under simulated mode.
|
java.util.Enumeration |
listAllPromotionPolicies()
Lists all promotion policies in the execution agenda
|
java.util.Enumeration |
listAllPromotions()
Lists all promotions in the execution agenda
|
void |
markLineItemsNotToBeAffectedByPromotionAtCurrentGroupLevel(LineItemSet items)
Temporarily marks line items to be ineligible to receive any adjustments.
|
void |
markLineItemsNotToBeAffectedByPromotionAtGlobalLevel(LineItemSet items)
Temporarily marks a set of order items as can no longer be affected by
any promotion.
|
void |
markLineItemsNotToBeTargetedByPromotionAtCurrentGroupLevel(LineItemSet items)
Temporarily marks line items to be not targetable by promotions in the
same group as the promotion currently under evaluation.
|
void |
markLineItemsNotToBeTargetedByPromotionAtGlobalLevel(LineItemSet items)
Temporarily marks a set of order items as no longer targetable by any
promotion.
|
void |
markPromotionAsNotApplicable(Promotion promotion)
Temporarily marks a promotion as no longer applicable to the current
order.
|
Promotion |
nextPromotion()
Returns next promotion in the promotion evaluation sequence.
|
void |
reduceOrderQualifyingTotal(java.math.BigDecimal amount,
int types)
Reduces the amount and type of order qualifying total
|
void |
releaseCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon coupon)
Releases a coupon to the pool of available coupons
|
void |
resetRewardOptions()
Reset RewardOption map object to its original state.
|
void |
rollbackPCB(PromotionContext context)
Rolls back all the changes in the current promotion execution control
block.
|
void |
setAgenda(PromotionExecutionAgenda aAgenda)
Sets the PromotionExecutionAgenda for the PromotionContext.
|
void |
setAllAttributeNames(java.util.List<java.lang.String> allAttributeNames)
sets all attribute names in cache for this context
|
void |
setArgument(PromotionArgument aArgument)
Sets the argument.
|
void |
setCodeToPromotionMap(java.util.Hashtable aCodeToPromotionMap)
Sets the codeToPromotionMap.
|
void |
setCouponToPromotionMap(java.util.Hashtable hashtable)
Sets the promotion to coupon map.
|
void |
setCurrencyConverter(PriceConverter converter)
Sets the currency converter
|
void |
setCurrentPromotionExecutionRecord(PromotionExecutionRecord aPromotionExecutionRecord)
Sets the PromotionExecutionRecord object.
|
void |
setCurrentResults(PromotionExecutionRecord[] aCurrentResults)
Sets the currentResult.
|
void |
setFullCodeToPromotionMap(java.util.Hashtable aCodeToPromotionMap)
Sets the full codeToPromotionMap where the key is the promotion key, and the
value is a list of promotion codes for that promotion.
|
void |
setMask(boolean[] aMask)
Sets the mask.
|
void |
setOrder(Order aOrder)
Sets the order to which promotions will be applied
|
void |
setRewardOptions(java.util.Map aMap)
Sets the RewardOption map object.
|
void |
setRounding(Rounding newRounding)
Sets the currency rounding tool
|
void |
setSequence(java.util.Vector aSequence)
Sets the sequence.
|
void |
setStoreKey(StoreKey key)
Sets the store key
|
int |
tentativelyApplyMonetaryAdjustment(PromotionExecutionRecord record)
Calculates monetary adjustments as a result of applying a promotion,
updates the running total accordingly.
|
void |
useCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon coupon)
This method adds a coupon to the list of usedCoupons to track the coupons used in this order
|
public static final java.lang.String COPYRIGHT
public PromotionContext(PromotionEngine aEngine, PromotionExecutionAgenda aAgenda, PromotionArgument aArgument)
aEngine
- promotion engine in which the invocation is being made.aAgenda
- PromotionExecutionAgenda for this invocationaArgument
- PromotionArgument for this invocation in/out parameterpublic java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
Object.clone()
public boolean hasNextPromotion()
public Promotion getPromotionCurrentlyUnderEvaluation()
public Promotion nextPromotion()
public void markPromotionAsNotApplicable(Promotion promotion)
promotion
- to be marked as no longer applicablepublic java.util.Enumeration getApplicablePolicies(Promotion promotion)
promotion
- the promotionpublic java.util.Enumeration getGovernedPromotions(PromotionPolicy policy)
policy
- The policypublic LineItemSet getLineItemsCanBeTargetedByCurrentPromotion()
public LineItemSet getLineItemsCanBeAffectedByCurrentPromotion()
public LineItemSet getLineItemsCanNotBeTargetedByCurrentPromotion()
public LineItemSet getLineItemsCanNotBeAffectedByCurrentPromotion()
public void markLineItemsNotToBeTargetedByPromotionAtGlobalLevel(LineItemSet items)
items
- that will be marked as no longer targetable by any promotionpublic void markLineItemsNotToBeAffectedByPromotionAtGlobalLevel(LineItemSet items)
items
- that will be marked as no longer targetable by any promotionpublic void markLineItemsNotToBeTargetedByPromotionAtCurrentGroupLevel(LineItemSet items)
items
- items to be marked as non-targetablepublic void markLineItemsNotToBeAffectedByPromotionAtCurrentGroupLevel(LineItemSet items)
items
- items to be marked as ineligible to be affected.public PromotionEngine getEngine()
public boolean isCodeEnteredFor(Promotion promotion)
promotion
- the promotionpublic java.lang.String getCodeFor(Promotion promotion)
promotion
- the promotionpublic java.util.List getCodesFor(Promotion promotion)
promotion
- the promotionpublic java.util.List getAppliedCodesFor(Promotion promotion)
promotion
- the promotionpublic PromotionExecutionRecord[] getCurrentResults()
public void setCurrentResults(PromotionExecutionRecord[] aCurrentResults)
aCurrentResults
- The currentResult to setpublic PromotionArgument getArgument()
public void setArgument(PromotionArgument aArgument)
aArgument
- The argument to setpublic void addPromotionExecutionRecordToArgument(PromotionExecutionRecord record)
record
- The promotion execution record to be appendedpublic void addPromotionExecutionRecord(PromotionExecutionRecord record)
record
- the promotion execution to be appended to the list of current
results.public java.util.Hashtable getCodeToPromotionMap()
public java.util.Hashtable getFullCodeToPromotionMap()
public java.util.Vector getSequence()
public void setCodeToPromotionMap(java.util.Hashtable aCodeToPromotionMap)
aCodeToPromotionMap
- The codeToPromotionMap to setpublic void setFullCodeToPromotionMap(java.util.Hashtable aCodeToPromotionMap)
aCodeToPromotionMap
- public void setSequence(java.util.Vector aSequence)
aSequence
- The sequence to setpublic void setMask(boolean[] aMask)
aMask
- The mask to setpublic int getRedemptionCountForThisPromotionInCurrentOrder(Promotion promotion)
promotion
- the promotionpublic int getRedemptionCountForThisPromotionForCurrentShopper(Promotion promotion)
promotion
- the promotionpublic int getRedemptionCountForThisPromotion(Promotion promotion)
promotion
- the promotionpublic com.ibm.commerce.marketing.promotion.group.PromotionGroup[] getGroups()
public void commitPCB(PromotionContext context)
context
- the context for this invocationpublic void rollbackPCB(PromotionContext context)
context
- the context for this invocationpublic void initPCB(PromotionContext context)
context
- the context for this invocationpublic java.util.Hashtable getCouponToPromotionMap()
public void setCouponToPromotionMap(java.util.Hashtable hashtable)
hashtable
- map of promotion and couponspublic com.ibm.commerce.marketing.promotion.coupon.Coupon[] getCouponFor(Promotion promotion)
promotion
- the promotionpublic boolean isCouponAddedFor(Promotion promotion)
promotion
- the promotionpublic com.ibm.commerce.marketing.promotion.coupon.Coupon allocateCoupon(Promotion promotion)
AllowMultipleCouponRedemptions
was turned on,
then it allocates an unused coupon from the promotion
If the flag was turned off, then it allocates the first coupon from the promotionpromotion
- the promotionpublic void useCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon coupon)
coupon
- coupon to add to the listpublic void releaseCoupon(com.ibm.commerce.marketing.promotion.coupon.Coupon coupon)
coupon
- the coupon to be releasedpublic java.math.BigDecimal getOrderQualifyingTotal(int types)
OrderQualifyingTotal
class.types
- the bit pattern of the types of monetary values that need to
be returnedpublic java.math.BigDecimal getRunningTotalFor(AssociatedOrderItem anItem, int type)
anItem
- the AssociatedOrderItemtype
- the type of running total to returnpublic java.math.BigDecimal getRunningTotalFor(AssociatedOrderItem[] items, int type)
items
- the array of AssociatedOrderItemstype
- the type of running total to returnpublic java.math.BigDecimal getRunningTotalFor(LineItemSet set, int type)
set
- the LineItemSettype
- the type of running total to returnpublic java.math.BigDecimal getOrderRunningTotal(int type)
type
- the type of running total to returnpublic java.math.BigDecimal getRunningTotalFor(OrderItem item, int type)
item
- order itemtype
- the type of running total to returnpublic int tentativelyApplyMonetaryAdjustment(PromotionExecutionRecord record)
record
- the PromotionExecutionRecord, which represents one promotion
that applied once.public Order getOrder()
public LineItemSet getOrderAsALineItemSet()
public PriceConverter getCurrencyConverter()
public Rounding getRounding()
public StoreKey getStoreKey()
public void setOrder(Order aOrder)
aOrder
- to set the order to which promotions will be appliedpublic void setCurrencyConverter(PriceConverter converter)
converter
- to set the current converterpublic void setRounding(Rounding newRounding)
newRounding
- the customized rounding tool.public void setStoreKey(StoreKey key)
key
- the store keypublic java.lang.String getOrderCurrency()
public OrderRunningTotal getRunningTotalObject()
public OrderQualifyingTotal getQualifyingTotalObject()
public boolean isPricePresent()
public boolean isShippingChargePresent()
public boolean isShippingTaxPresent()
public boolean isTaxPresent()
public java.util.Enumeration listAllPromotions()
public java.util.Enumeration listAllPromotionPolicies()
public void appendPromotionErrorReport(PromotionErrorReport report)
report
- the error report to be addedpublic PromotionErrorReport[] getPromotionErrorReports()
public ProtectedContextAttribute addProtectedContextAttribute(java.lang.String name, ProtectedContextAttribute attr)
name
- The name of the protected context attribute.attr
- The attribute object.public ProtectedContextAttribute getProtectedContextAttribute(java.lang.String name)
name
- The name of the protected context attribute object.public java.lang.Object addUnprotectedContextAttribute(java.lang.String name, java.lang.Object attr)
name
- of the un-protected context attributeattr
- the attribute objectpublic java.lang.Object getUnprotectedContextAttribute(java.lang.String name)
name
- the name of the un-protected context attribute objectpublic void reduceOrderQualifyingTotal(java.math.BigDecimal amount, int types)
amount
- the amount to be reducedtypes
- the bit pattern of the monetary values to be reducedpublic void setRewardOptions(java.util.Map aMap)
aMap
- The map object.public void resetRewardOptions()
public java.util.Map getRewardOptions()
public java.util.List getRewardOptionForPromotion(PromotionKey aPromotionKey)
aPromotionKey
- The promotion key.public void addRewardOptionForPromotion(PromotionKey aPromotionKey, RewardOption aRewardOption)
aPromotionKey
- The promotion key.aRewardOption
- The RewardOption object to add.public PromotionExecutionAgenda getAgenda()
public void setAgenda(PromotionExecutionAgenda aAgenda)
aAgenda
- The PromotionExecutionAgenda to set.public PromotionExecutionRecord getCurrentPromotionExecutionRecord()
public void setCurrentPromotionExecutionRecord(PromotionExecutionRecord aPromotionExecutionRecord)
aPromotionExecutionRecord
- The PromotionExecutionRecord object to set.public boolean isUnderSimulatedPromotionEvaluationMode()
public java.util.Map<java.lang.String,java.lang.String> getSimulatedPromotionEvaluationConfigurations()
public void setAllAttributeNames(java.util.List<java.lang.String> allAttributeNames)
allAttributeNames
- a list of all attribute names to be storedpublic java.util.List getAllAttributeNames()
public void clearAttributeNamesInCache()