com.ibm.commerce.order.calculation
Class CalculationCodeCombineCmdImpl

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.CalculationCodeCombineCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculationCmd, CalculationCodeCombineCmd, ECCommand, ECTargetableCommand, TaskCommand
Direct Known Subclasses:
DiscountCalculationCodeCombineCmdImpl, TaxCalculationCodeCombineCmdImpl

public class CalculationCodeCombineCmdImpl
extends CalculationCmdImpl
implements CalculationCodeCombineCmd

The default implementation of CalculationCodeCombineCmd.

Its behaviour is as follows:

  1. for each item, determines the calculation codes attached, which are:
    1. the calculation codes directly attached to the item (see ORDICALCD).
    2. the calculation codes directly attached to its order (see ORDCALCD).
    3. if none, or if none is marked as "overrideIndirectAttachments" (see ORDCALCD/ORDICALCD.CALFLAGS), the calculation codes indirectly attached:
      • the catalog entry referenced by the item, and its parent product (see CATENCALCD).
      • the catalog groups directly containing the catalog entries above (see CATGPCALCD).
    4. if none, the default calculation code (see STENCALUSG.CALCODE_ID).
  2. groups the items with calculation codes attached by calculation code and its groupBy attribute value (see CALCODE.GROUPBY).
  3. for each group, invokes the calculation method of type "CalculationCodeQualify" referenced by the calculation code (see CALCODE.CALMETHOD_ID_QFY, CalculationCodeQualifyCmd) to trim the list of items if the calculation code is restricted (see CALCODE.FLAGS).

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. CalculationCodeCombineCmd
defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
CalculationCodeCombineCmdImpl()
          Constructor for CalculationCodeCombineCmdImpl.
 
Method Summary
protected  void addItem( GroupKey aKey, Item aItem)
          Adds an item to a group with the specified key.
protected  Item[] callCodeQualify(CalculationCodeAccessBean aabCode, Item[] aItems)
          Invokes the calculation method of type "CalculationCodeQualify" referenced by the calculation code (see CALCODE.CALMETHOD_ID_QFY, CalculationCodeQualifyCmd) to determine the qualifying items.
protected  GroupKey createGroupKey(CalculationCodeAccessBean aabCode, Item aItem)
          Generates a group key from a calculation code and an item.
protected  Group[] createGroups()
          Generates the groups.
protected  CalculationCodeAccessBean[] getCodes( Item aItem)
          Returns the calculation codes attached to an item.
protected  CalculationCodeAccessBean getDefaultCode()
          Returns the default calculation code.
protected  CalculationCodeAccessBean[] getDirectlyAttachedCodes( Item aItem)
          Returns the calculation codes directly attached to an item.
  Group[] getGroups()
          Returns the groups.
protected  CalculationCodeAccessBean[] getIndirectlyAttachedCodes( Item aItem)
          Returns the calculation codes indirectly attached to an item.
protected  Item[] getItems()
          Returns the items.
protected  java.lang.Integer[] getTaxCategoryIds()
          Returns the tax categories.
protected  boolean isDirectAttachmentsOverride( Item aItem)
          Returns whether the calculation codes directly attached to an item should override the ones indirectly attached to it.
protected  boolean isRestricted(CalculationCodeAccessBean aabCode)
          Returns whether a calculation code is restricted.
 void performExecute()
          The business logic for this command.
protected  void processItem( Item aItem)
          Processes an item.
 void reset()
          This method should be called after a command has been executed to reset its states variables.
protected  void setGroups( Group[] aGroups)
          Sets the groups.
 void setItems( Item[] aItems)
          Sets the items.
 void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
          Sets the tax categories that should be active during execution.
protected  java.lang.String toString(CalculationCodeAccessBean[] aabCodes)
          Returns the string representation of a list of calculation codes for diagnostic purposes.
 
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

CalculationCodeCombineCmdImpl

public CalculationCodeCombineCmdImpl()
Constructor for CalculationCodeCombineCmdImpl.
Method Detail

addItem

protected void addItem(GroupKey aKey,
Item aItem)
Adds an item to a group with the specified key. This method is called by processItem(Item).
Parameters:
aKey - the key.
aItem - the item.

callCodeQualify

protected Item[] callCodeQualify(CalculationCodeAccessBean aabCode,
Item[] aItems)
                          throws ECException
Invokes the calculation method of type "CalculationCodeQualify" referenced by the calculation code (see CALCODE.CALMETHOD_ID_QFY, CalculationCodeQualifyCmd) to determine the qualifying items. This method is called by createGroups().
Parameters:
aabCode - the calculation code.
aItems - the items.
Returns:
the qualifying items.
Throws:
ECException

createGroupKey

protected GroupKey createGroupKey(CalculationCodeAccessBean aabCode,
Item aItem)
                           throws ECException
Generates a group key from a calculation code and an item.
Parameters:
aabCode - the calculation code.
aItem - the item.
Returns:
the group key.
Throws:
ECException

createGroups

protected Group[] createGroups()
                        throws ECException
Generates the groups. This method is called by performExecute().
Throws:
ECException

getCodes

protected CalculationCodeAccessBean[] getCodes(Item aItem)
                                        throws ECException
Returns the calculation codes attached to an item. This method is called by processItem(Item).
Parameters:
aItem - the item.
Returns:
the calculation codes attached to the item.
Throws:
ECException

getDefaultCode

protected CalculationCodeAccessBean getDefaultCode()
                                            throws ECException
Returns the default calculation code. This method is called by getCodes(Item).
Returns:
the default calculation code.
Throws:
ECException

getDirectlyAttachedCodes

protected CalculationCodeAccessBean[] getDirectlyAttachedCodes(Item aItem)
                                                        throws ECException
Returns the calculation codes directly attached to an item. This method is called by getCodes(Item).
Parameters:
aItem - the item.
Returns:
the calculation codes directly attached to the item.
Throws:
ECException

getGroups

public Group[] getGroups()
Returns the groups.
Specified by:
getGroups in interface CalculationCodeCombineCmd
Returns:
the groups.

getIndirectlyAttachedCodes

protected CalculationCodeAccessBean[] getIndirectlyAttachedCodes(Item aItem)
                                                          throws ECException
Returns the calculation codes indirectly attached to an item. This method is called by getCodes(Item).
Parameters:
aItem - the item.
Returns:
the calculation codes indirectly attached to the item.
Throws:
ECException

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.

isDirectAttachmentsOverride

protected boolean isDirectAttachmentsOverride(Item aItem)
                                       throws ECException
Returns whether the calculation codes directly attached to an item should override the ones indirectly attached to it. This method is called by getCodes(Item).
Parameters:
aItem - the item.
Returns:
true if the calculation codes directly attached to the item should override the ones indirectly attached to it.
Throws:
ECException

isRestricted

protected boolean isRestricted(CalculationCodeAccessBean aabCode)
                        throws ECException
Returns whether a calculation code is restricted. For more information, refer to CALCODE.FLAGS.
Parameters:
aabCode - the calculation code.
Returns:
true if the calculation code is restricted.
Throws:
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
Throws:
ECException
See Also:
ECCommand.performExecute()

processItem

protected void processItem(Item aItem)
                    throws ECException
Processes an item. Its behaviour is as follows:
  1. calls getCodes(Item) to identify the calculation codes attached to the item.
  2. for each calculation code identified, calls addItem(GroupKey, Item) to add the item to an appropiate group.
Parameters:
aItem - the item.
Throws:
ECException

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

setGroups

protected void setGroups(Group[] aGroups)
Sets the groups.
Parameters:
aGroups - the groups.

setItems

public void setItems(Item[] aItems)
Sets the items.
Specified by:
setItems in interface CalculationCodeCombineCmd
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 CalculationCodeCombineCmd
Parameters:
anTaxCategoryIds - the tax category IDs.

toString

protected java.lang.String toString(CalculationCodeAccessBean[] aabCodes)
                             throws ECException
Returns the string representation of a list of calculation codes for diagnostic purposes.
Parameters:
aabCodes - the calculation codes.
Returns:
the string representation of the calculation codes.
Throws:
ECException