public interface PromotionPolicy extends XMLizable
PromotionContext
and PromotionExecutionRecord
. A promotion policy
is called when the conditions of a promotion are satisfied, and the
adjustments of the promotion have been "tentatively” applied to the
PromotionContext. The responsibility of a promotion policy, carried out by
the apply method, is to check the state of the PromotionContext to determine
whether there are any violations. If no violations are found for the
promotion policy, then the adjustments can be applied to the order, else
the "tentatively" applied adjustments are to rolled back by the PromotionEngine.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright
|
static int |
POLICY_STATUS_ACTIVE
Value of the status of a promotion policy to indicate that it is active.
|
static int |
POLICY_STATUS_DELETED
Value of the status of a promotion policy to indicate that it is marked for deletion.
|
static int |
POLICY_STATUS_INACTIVE
Value of the status of a promotion policy to indicate that it is inactive.
|
Modifier and Type | Method and Description |
---|---|
boolean |
apply(PromotionContext context,
PromotionExecutionRecord record)
This method is used to apply the policy to a promotion to deem if any violation is found on application.
|
java.lang.String |
getDescription(java.util.Locale locale,
int type)
Returns the description of the promotion policy based on its type and
locale.
|
PromotionPolicyKey |
getKey()
Returns the key of this promotion policy
|
int |
getStatus()
Returns the status of this promotion policy
|
void |
setKey(PromotionPolicyKey key)
Sets the key of this promotion policy
|
void |
setStatus(int newStatus)
Sets the status of a promotion policy.
|
static final java.lang.String COPYRIGHT
static final int POLICY_STATUS_ACTIVE
static final int POLICY_STATUS_INACTIVE
static final int POLICY_STATUS_DELETED
PromotionPolicyKey getKey()
java.lang.String getDescription(java.util.Locale locale, int type)
locale
- for which the description is being retrieved.type
- the type of description to retrieve. Possible type values
include Description.ADMIN_DESC
,
Description.SHOPPER_LONG_DESC
or
Description.SHOPPER_SHORT_DESC
.boolean apply(PromotionContext context, PromotionExecutionRecord record) throws PromotionPolicyApplicationException
context
- PromotionContext, created and passed to this policy by the enginerecord
- the PromotionExecutionRecord
for which violation is tested.true
if by applying this promotion (as indicated by the record parameter), no violation with this policy is found.
false
a violation is found, this promotion can not be applied.PromotionPolicyApplicationException
- when the evaluation runs into any unexpected errorint getStatus()
POLICY_STATUS_ACTIVE
, POLICY_STATUS_INACTIVE
,
POLICY_STATUS_DELETED
.void setStatus(int newStatus)
POLICY_STATUS_ACTIVE
, POLICY_STATUS_INACTIVE
, POLICY_STATUS_DELETED
.newStatus
- the new status to setvoid setKey(PromotionPolicyKey key)
key
- the key to be set