com.ibm.commerce.order.calculation
Class CalculationRuleCombineCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.command.BusinessPolicyCommandImpl
                          |
                          +--com.ibm.commerce.order.calculation.CalculationCmdImpl
                                |
                                +--com.ibm.commerce.order.calculation.CalculationRuleCombineCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculationCmd, CalculationRuleCombineCmd, ECCommand, ECTargetableCommand, TaskCommand

public class CalculationRuleCombineCmdImpl
extends CalculationCmdImpl
implements CalculationRuleCombineCmd

The default implementation of CalculationRuleCombineCmd.

Its behaviour is as follows:

  1. retrieves the calculation rules of the calculation code.
  2. for each calculation rule:
    1. for sales/shipping tax only, ignore this calculation rule if it doesn't belong to the tax categories specified.
    2. if the calculation rule is restricted, invokes the calculation method of type "CalculationRuleQualify" referenced by the calculation rule (see CALRULE.CALMETHOD_ID_QFY, CalculationRuleQualifyCmd) to determine the list of qualified items.
    3. invokes the calculation method of type "CalculationRuleCalculate" referenced by the calculation rule (see CALRULE.CALMETHOD_ID, CalculationRuleQualifyCmd) to calculate its values for the list of qualified items.
  3. selects the combination of calculation rules (see CALRULE.COMBINATION) that yields the smallest total value.
  4. Commands used:

    Access beans used:
    See Also:
    Serialized Form

    Field Summary
    static java.lang.String COPYRIGHT
               
     
    Fields inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
    policyId, requestProperties
     
    Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
    commandContext
     
    Fields inherited from interface com.ibm.commerce.order.calculation. CalculationRuleCombineCmd
    defaultCommandClassName, NAME
     
    Fields inherited from interface com.ibm.commerce.command. ECCommand
    defaultCommandClassName
     
    Constructor Summary
    CalculationRuleCombineCmdImpl()
               
     
    Method Summary
    protected  java.math.BigDecimal[] callRuleCalculate(CalculationRuleAccessBean aabRule, Item[] aItems)
              This method is called by performExecute() to invoke the CalculationRuleCalculate command.
    protected  Item[] callRuleQualify(CalculationRuleAccessBean aabRule, Item[] aItems)
              This method is called by performExecute() to invoke the CalculationRuleQualify command.
    protected  void combineRules()
              This method is called by performExecute() to combine calculation rules based on their combination values.
    protected  CalculationCodeAccessBean getCode()
               
    protected  Item[] getItems()
               
     CalculationRuleAccessBean[] getRules()
              getRules method comment.
    protected  java.lang.Integer[] getTaxCategoryIds()
              Returns the tax categories.
     java.math.BigDecimal[] getValues(java.lang.Integer anRuleId)
              getValues method comment.
    protected  boolean isRestricted(CalculationRuleAccessBean aabRule)
               
     void performExecute()
              The business logic for this command.
    protected  void removeValues(java.lang.Integer anRuleId)
              This method is called by combineRules() to remove a calculation rule and its result.
     void reset()
              This method should be called after a command has been executed to reset its states variables.
     void setCode(CalculationCodeAccessBean aabCode)
              Sets the calculation code.
     void setItems( Item[] aItems)
              Sets the items.
    protected  void setRules(CalculationRuleAccessBean[] aabRules)
              Sets the calculation rules.
     void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
              Sets the tax categories that should be active during execution.
    protected  void setValues(java.lang.Integer anRuleId, java.math.BigDecimal[] adValues)
              Sets the result of a particular calculation rule.
     
    Methods inherited from class com.ibm.commerce.order.calculation. CalculationCmdImpl
    createCommand, getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
     
    Methods inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
    getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
     
    Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
    accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
     
    Methods inherited from class java.lang.Object
    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface com.ibm.commerce.order.calculation. CalculationCmd
    getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
     
    Methods inherited from interface com.ibm.commerce.command. BusinessPolicyCommand
    getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
     

    Field Detail
    public static final java.lang.String COPYRIGHT
    
    See Also:
    Constant Field Values
    Constructor Detail

    CalculationRuleCombineCmdImpl

    public CalculationRuleCombineCmdImpl()
    
    Method Detail

    callRuleCalculate

    protected java.math.BigDecimal[] callRuleCalculate(CalculationRuleAccessBean aabRule,
    Item[] aItems)
                                                throws ECException
    
    This method is called by performExecute() to invoke the CalculationRuleCalculate command.
    ECException

    callRuleQualify

    protected Item[] callRuleQualify(CalculationRuleAccessBean aabRule,
    Item[] aItems)
                              throws ECException
    
    This method is called by performExecute() to invoke the CalculationRuleQualify command.
    ECException

    combineRules

    protected void combineRules()
                         throws ECException
    
    This method is called by performExecute() to combine calculation rules based on their combination values.
    ECException

    getRules

    public CalculationRuleAccessBean[] getRules()
    
    getRules method comment.
    Specified by:
    getRules in interface CalculationRuleCombineCmd
    Returns:
    the applicable calculation rules.

    getTaxCategoryIds

    protected java.lang.Integer[] getTaxCategoryIds()
    
    Returns the tax categories.

    getValues

    public java.math.BigDecimal[] getValues(java.lang.Integer anRuleId)
    
    getValues method comment.
    Specified by:
    getValues in interface CalculationRuleCombineCmd
    Parameters:
    anRuleId - the calculation rule ID.
    Returns:
    the values of the calculation rules corresponding to the items.

    isRestricted

    protected boolean isRestricted(CalculationRuleAccessBean aabRule)
                            throws ECException
    
    ECException

    performExecute

    public void performExecute()
                        throws ECException
    
    Description copied from class: AbstractECTargetableCommand
    The business logic for this command. This method should be overwritten by all command writers. Command writers should call super.performExecute() as the first line in their method.
    Specified by:
    performExecute in interface ECCommand
    Overrides:
    performExecute in class AbstractECTargetableCommand
    ECException

    removeValues

    protected void removeValues(java.lang.Integer anRuleId)
    
    This method is called by combineRules() to remove a calculation rule and its result.

    reset

    public void reset()
    
    Description copied from class: AbstractECTargetableCommand
    This method should be called after a command has been executed to reset its states variables. After the call to reset, we should be able to execute the command again.
    Overrides:
    reset in class CalculationCmdImpl
    See Also:
    com.ibm.websphere.command.Command#reset()

    setCode

    public void setCode(CalculationCodeAccessBean aabCode)
    
    Description copied from interface: CalculationRuleCombineCmd
    Sets the calculation code.
    Specified by:
    setCode in interface CalculationRuleCombineCmd
    Parameters:
    aabCode - the calculation code.

    getCode

    protected CalculationCodeAccessBean getCode()
    

    setItems

    public void setItems(Item[] aItems)
    
    Description copied from interface: CalculationRuleCombineCmd
    Sets the items.
    Specified by:
    setItems in interface CalculationRuleCombineCmd
    Parameters:
    aItems - the items.

    getItems

    protected Item[] getItems()
    

    setRules

    protected void setRules(CalculationRuleAccessBean[] aabRules)
    
    Sets the calculation rules.

    setTaxCategoryIds

    public void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
    
    Description copied from interface: CalculationRuleCombineCmd
    Sets the tax categories that should be active during execution. Normally that would be all sales/shipping tax categories defined in the current store. For sales/shipping tax only.
    Specified by:
    setTaxCategoryIds in interface CalculationRuleCombineCmd
    Parameters:
    anTaxCategoryIds - the tax category IDs.

    setValues

    protected void setValues(java.lang.Integer anRuleId,
                             java.math.BigDecimal[] adValues)
    
    Sets the result of a particular calculation rule.