com.elasticpath.domain.rules
Interface Rule

All Superinterfaces:
Entity, EpDomain, Persistence, java.io.Serializable
All Known Implementing Classes:
AbstractRuleImpl, PromotionRuleImpl

public interface Rule
extends Entity

Represents a rule that can be applied by the rules engine. For example, "Give a 10% discount for all products in category X."


Field Summary
static boolean AND_OPERATOR
          "AND" operator.
static boolean OR_OPERATOR
          "OR" operator.
 
Method Summary
 void addAction(RuleAction ruleAction)
          Add an action to the rule.
 void addCondition(RuleCondition condition)
          Adds a condition to the set of conditions.
 void addEligibility(RuleEligibility eligibility)
          Adds a rule eligiblity to the set of eligibilities.
 java.util.Set getActions()
          Get the actions associated with this rule.
 boolean getConditionOperator()
          Gets the operator (AND/OR) if there are multiple conditions.
 java.util.Set getConditions()
          Get the conditions associated with this rule.
 java.util.Set getEligibilities()
          Get the eligibility conditions associated with this rule.
 boolean getEligibilityOperator()
          Gets the operator (AND/OR) if there are multiple eligibility conditions.
 java.util.Date getEndDate()
          Get the end date.
 java.lang.String getName()
          Get the name of this rule.
 java.lang.String getPromoCode()
          Get the promoCode of this rule.
 java.lang.String getRuleCode()
          Returns the Drools code corresponding to this rule.
 RuleSet getRuleSet()
          Get the ruleSet this rule belongs to.
 java.util.Date getStartDate()
          Get the starting date that this rule can be applied.
 boolean isSingleUse()
          True if this promoCode is only for single use.
 void setActions(java.util.Set actions)
          Set the actions of this rule.
 void setConditionOperator(boolean conditionOperator)
          Sets the operator (AND/OR) if there are multiple eligibility conditions.
 void setConditions(java.util.Set conditions)
          Set the conditions of this rule.
 void setEligibilities(java.util.Set eligibilities)
          Set the eligibility conditions of this rule.
 void setEligibilityOperator(boolean eligibilityOperator)
          Sets the operator (AND/OR) if there are multiple eligibility conditions.
 void setEndDate(java.util.Date endDate)
          Set the end date.
 void setName(java.lang.String name)
          Set the name of the rule.
 void setPromoCode(java.lang.String promoCode)
          Set the promoCode of the rule.
 void setRuleSet(RuleSet ruleSet)
          Set the ruleSet this rule belongs to.
 void setSingleUse(boolean singleUse)
          Sets whether this promoCode is for single use.
 void setStartDate(java.util.Date startDate)
          Set the starting date that this rule can be applied.
 void validate()
          Checks that the rule set domain model is well formed.
 
Methods inherited from interface com.elasticpath.domain.Entity
getGuid, setGuid
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

AND_OPERATOR

static final boolean AND_OPERATOR
"AND" operator.

See Also:
Constant Field Values

OR_OPERATOR

static final boolean OR_OPERATOR
"OR" operator.

See Also:
Constant Field Values
Method Detail

addAction

void addAction(RuleAction ruleAction)
Add an action to the rule.

Parameters:
ruleAction - the action to add.
Throws:
EpDomainException - if anything goes wrong.

addCondition

void addCondition(RuleCondition condition)
Adds a condition to the set of conditions.

Parameters:
condition - the condition to add.
Throws:
EpDomainException - if anything goes wrong.

addEligibility

void addEligibility(RuleEligibility eligibility)
Adds a rule eligiblity to the set of eligibilities.

Parameters:
eligibility - the RuleEligibility to add.
Throws:
EpDomainException - if anything goes wrong.

getActions

java.util.Set getActions()
Get the actions associated with this rule.

Returns:
the actions

getConditionOperator

boolean getConditionOperator()
Gets the operator (AND/OR) if there are multiple conditions.

Returns:
the eligibility condition operator (ANR/OR)

getConditions

java.util.Set getConditions()
Get the conditions associated with this rule.

Returns:
the conditions

getEligibilities

java.util.Set getEligibilities()
Get the eligibility conditions associated with this rule.

Returns:
the eligibility conditions

getEligibilityOperator

boolean getEligibilityOperator()
Gets the operator (AND/OR) if there are multiple eligibility conditions.

Returns:
the eligibility condition operator (ANR/OR)

getEndDate

java.util.Date getEndDate()
Get the end date. After the end date, the rule will no longer be applied.

Returns:
the end date

getName

java.lang.String getName()
Get the name of this rule.

Returns:
the name of the rule

getPromoCode

java.lang.String getPromoCode()
Get the promoCode of this rule.

Returns:
the promoCode of the rule

getRuleCode

java.lang.String getRuleCode()
                             throws EpDomainException
Returns the Drools code corresponding to this rule.

Returns:
the rule code.
Throws:
EpDomainException - if the rule is not well formed

getRuleSet

RuleSet getRuleSet()
Get the ruleSet this rule belongs to.

Returns:
the ruleSet it belongs to.

getStartDate

java.util.Date getStartDate()
Get the starting date that this rule can be applied.

Returns:
the start date

isSingleUse

boolean isSingleUse()
True if this promoCode is only for single use.

Returns:
True if this promoCode is only for single use.

setActions

void setActions(java.util.Set actions)
Set the actions of this rule.

Parameters:
actions - a set of RuleAction objects

setConditionOperator

void setConditionOperator(boolean conditionOperator)
Sets the operator (AND/OR) if there are multiple eligibility conditions.

Parameters:
conditionOperator - - the condition operator (ANR/OR).

setConditions

void setConditions(java.util.Set conditions)
Set the conditions of this rule.

Parameters:
conditions - a set of RuleCondition objects

setEligibilities

void setEligibilities(java.util.Set eligibilities)
Set the eligibility conditions of this rule.

Parameters:
eligibilities - a set of RuleCondition objects

setEligibilityOperator

void setEligibilityOperator(boolean eligibilityOperator)
Sets the operator (AND/OR) if there are multiple eligibility conditions.

Parameters:
eligibilityOperator - - the eligibility condition operator (ANR/OR).

setEndDate

void setEndDate(java.util.Date endDate)
Set the end date.

Parameters:
endDate - the end date

setName

void setName(java.lang.String name)
Set the name of the rule.

Parameters:
name - the name of the rule

setPromoCode

void setPromoCode(java.lang.String promoCode)
Set the promoCode of the rule.

Parameters:
promoCode - the promoCode of the rule

setRuleSet

void setRuleSet(RuleSet ruleSet)
Set the ruleSet this rule belongs to.

Parameters:
ruleSet - the ruleSet it belongs to.

setSingleUse

void setSingleUse(boolean singleUse)
Sets whether this promoCode is for single use.

Parameters:
singleUse - set to True if this promoCode is only for single use.

setStartDate

void setStartDate(java.util.Date startDate)
Set the starting date that this rule can be applied.

Parameters:
startDate - the start date

validate

void validate()
              throws EpDomainException
Checks that the rule set domain model is well formed. For example, rule conditions must have all required parameters specified.

Throws:
EpDomainException - if the structure is not correct.