com.elasticpath.domain.rules.impl
Class AbstractRuleImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractEntityImpl
              extended by com.elasticpath.domain.rules.impl.AbstractRuleImpl
All Implemented Interfaces:
Entity, EpDomain, Persistence, Rule, java.io.Serializable
Direct Known Subclasses:
PromotionRuleImpl

public abstract class AbstractRuleImpl
extends AbstractEntityImpl
implements Rule

Represents a rule that can be applied by the rules engine. For example, promotion rules that execute the following may be implemented by subclasses: "Give a 10% discount for all products in category X."

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Fields inherited from interface com.elasticpath.domain.rules.Rule
AND_OPERATOR, OR_OPERATOR
 
Constructor Summary
AbstractRuleImpl()
           
 
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 conditons 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.
abstract  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.
 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 setDefaultValues()
          Set default values for those fields need default values.
 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 setRuleSet(RuleSet ruleSet)
          Set the ruleSet this rule belongs to.
 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 class com.elasticpath.domain.impl.AbstractEntityImpl
convertAttributeGroupAttributes, getGuid, setGuid
 
Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.domain.rules.Rule
getPromoCode, isSingleUse, setPromoCode, setSingleUse
 
Methods inherited from interface com.elasticpath.domain.Entity
getGuid, setGuid
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

AbstractRuleImpl

public AbstractRuleImpl()
Method Detail

addAction

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

Specified by:
addAction in interface Rule
Parameters:
ruleAction - the action to add.
Throws:
EpDomainException - if anything goes wrong.

addCondition

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

Specified by:
addCondition in interface Rule
Parameters:
condition - the condition to add
Throws:
EpDomainException - if anything goes wrong.

addEligibility

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

Specified by:
addEligibility in interface Rule
Parameters:
eligibility - the RuleEligibility to add
Throws:
EpDomainException - if anything goes wrong.

getActions

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

Specified by:
getActions in interface Rule
Returns:
the actions

getConditionOperator

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

Specified by:
getConditionOperator in interface Rule
Returns:
the eligibility condition operator (ANR/OR)

getConditions

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

Specified by:
getConditions in interface Rule
Returns:
the conditions

getEligibilities

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

Specified by:
getEligibilities in interface Rule
Returns:
the eligibility conditions

getEligibilityOperator

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

Specified by:
getEligibilityOperator in interface Rule
Returns:
the eligibility condition operator (ANR/OR)

getEndDate

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

Specified by:
getEndDate in interface Rule
Returns:
the end date

getName

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

Specified by:
getName in interface Rule
Returns:
the name of the rule

getRuleCode

public abstract java.lang.String getRuleCode()
Returns the Drools code corresponding to this rule.

Specified by:
getRuleCode in interface Rule
Returns:
the rule code.

getRuleSet

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

Specified by:
getRuleSet in interface Rule
Returns:
the ruleSet it belongs to.

getStartDate

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

Specified by:
getStartDate in interface Rule
Returns:
the start date

setActions

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

Specified by:
setActions in interface Rule
Parameters:
actions - a set of RuleAction objects

setConditionOperator

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

Specified by:
setConditionOperator in interface Rule
Parameters:
conditionOperator - - the condition operator (ANR/OR).

setConditions

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

Specified by:
setConditions in interface Rule
Parameters:
conditions - a set of RuleCondition objects

setDefaultValues

public void setDefaultValues()
Set default values for those fields need default values.

Specified by:
setDefaultValues in interface Persistence
Overrides:
setDefaultValues in class AbstractEntityImpl

setEligibilities

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

Specified by:
setEligibilities in interface Rule
Parameters:
eligibilities - a set of RuleCondition objects

setEligibilityOperator

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

Specified by:
setEligibilityOperator in interface Rule
Parameters:
eligibilityOperator - - the eligibility condition operator (ANR/OR).

setEndDate

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

Specified by:
setEndDate in interface Rule
Parameters:
endDate - the end date

setName

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

Specified by:
setName in interface Rule
Parameters:
name - the name of the rule

setRuleSet

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

Specified by:
setRuleSet in interface Rule
Parameters:
ruleSet - the ruleSet it belongs to.

setStartDate

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

Specified by:
setStartDate in interface Rule
Parameters:
startDate - the start date

validate

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

Specified by:
validate in interface Rule
Throws:
EpDomainException - if the structure is not correct.