com.ibm.commerce.order.calculation
Class ApplyCalculationUsageCmdImpl

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.ApplyCalculationUsageCmdImpl
All Implemented Interfaces:
ApplyCalculationUsageCmd, BusinessPolicyCommand, CalculationCmd, ECCommand, ECTargetableCommand, TaskCommand
Direct Known Subclasses:
ApplyCalculationUsageTIKCmdImpl, ApplyStandardShippingChargeBySellerCmdImpl

public class ApplyCalculationUsageCmdImpl
extends CalculationCmdImpl
implements ApplyCalculationUsageCmd

The default implementation of ApplyCalculationUsageCmd.

Its behaviour is as follows:

  1. invokes the calculation method of type "CalculationCodeCombine" referenced by the current store (see STENCALUSG.ACTCC_CALMETHOD_ID, CalculationCodeCombineCmd) to determine the calculation codes attached to each item.
  2. for each calculation code identified:
    1. invokes the calculation method of type "CalculationCodeCalculate" referenced by the calculation code (see CALCODE.CALMETHOD_ID, CalculationCodeCalculateCmd) to calculate the values corresponding to the items.
    2. invokes the calculation method of type "CalculationCodeApply" referenced by the calculation code (see CALCODE.CALMETHOD_ID_APP, CalculationCodeApplyCmd) to apply the values to the items.

Commands used:

Access beans used:
See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          The IBM copyright notice field.
 
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. ApplyCalculationUsageCmd
defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
ApplyCalculationUsageCmdImpl()
          Constructor for ApplyCalculationUsageCmdImpl.
 
Method Summary
protected  void callCodeApply( Group aGroup)
          Invokes the calculation method of type "CalculationCodeApply" referenced by the calculation code (see CALCODE.CALMETHOD_ID_APP, CalculationCodeApplyCmd) to apply the values.
protected  void callCodeCalculate( Group aGroup)
          Invokes the calculation method of type "CalculationCodeCalculate" referenced by the calculation code (see CALCODE.CALMETHOD_ID, CalculationCodeCalculateCmd) to calculate the values.
protected  Group[] callCodeCombine( Item[] aItems)
          Invokes the calculation method of type "CalculationCodeCombine" referenced by the current store (see STENCALUSG.ACTCC_CALMETHOD_ID, CalculationCodeCombineCmd) to determine the calculation codes attached to each item.
 void checkAppliedItems()
          Checks if a value has been calculated and applied to each and every item.
 java.util.Set getAppliedItems()
          Returns the items that have been applied to.
protected  Item[] getItems()
          Returns the items.
protected  java.lang.Integer[] getTaxCategoryIds()
          Returns the tax categories.
 void performExecute()
          The business logic for this command.
 void reset()
          This method should be called after a command has been executed to reset its states variables.
 void setItems( Item[] aItems)
          Sets the items.
 void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
          Sets the tax categories that should be active during execution.
protected  void updateAppliedItems( Group aGroup)
          Updates the set of items that have been applied to.
 
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
The IBM copyright notice field.
See Also:
Constant Field Values
Constructor Detail

ApplyCalculationUsageCmdImpl

public ApplyCalculationUsageCmdImpl()
Constructor for ApplyCalculationUsageCmdImpl.
Method Detail

callCodeApply

protected void callCodeApply(Group aGroup)
                      throws ECException
Invokes the calculation method of type "CalculationCodeApply" referenced by the calculation code (see CALCODE.CALMETHOD_ID_APP, CalculationCodeApplyCmd) to apply the values. This method is called by performExecute().
Parameters:
aGroup - a group containing a calculation code, the items it is attached to, and the value(s) corresponding to each item.
Throws:
ECException

callCodeCalculate

protected void callCodeCalculate(Group aGroup)
                          throws ECException
Invokes the calculation method of type "CalculationCodeCalculate" referenced by the calculation code (see CALCODE.CALMETHOD_ID, CalculationCodeCalculateCmd) to calculate the values. This method is called by performExecute().
Parameters:
aGroup - a group containing a calculation code and the items it is attached to.
Throws:
ECException

callCodeCombine

protected Group[] callCodeCombine(Item[] aItems)
                           throws ECException
Invokes the calculation method of type "CalculationCodeCombine" referenced by the current store (see STENCALUSG.ACTCC_CALMETHOD_ID, CalculationCodeCombineCmd) to determine the calculation codes attached to each item. This method is called by performExecute().
Parameters:
aItems - the items.
Returns:
a list of groups, each containing a calculation code and the items it is attached to.
Throws:
ECException

checkAppliedItems

public void checkAppliedItems()
                       throws ECException
Checks if a value has been calculated and applied to each and every item. If not, an ECApplicationException with ECMessage _ERR_CALCODE will be thrown.
Specified by:
checkAppliedItems in interface ApplyCalculationUsageCmd
Throws:
ECException

getAppliedItems

public java.util.Set getAppliedItems()
Returns the items that have been applied to.
Specified by:
getAppliedItems in interface ApplyCalculationUsageCmd
Returns:
the items (class: Item).

getItems

protected Item[] getItems()
Returns the items.
Returns:
the items.

getTaxCategoryIds

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

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
Throws:
ECException
See Also:
ECCommand.performExecute()

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()

setItems

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

setTaxCategoryIds

public void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
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 ApplyCalculationUsageCmd
Parameters:
anTaxCategoryIds - the tax category IDs.

updateAppliedItems

protected void updateAppliedItems(Group aGroup)
Updates the set of items that have been applied to. This method is called by performExecute().
Parameters:
aGroup - a group containing a calculation code, the items it is attached to, and the value(s) corresponding to each item.