com.ibm.commerce.order.calculation
Class ApplyShippingCmdImpl

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.ApplyShippingCmdImpl
All Implemented Interfaces:
ApplyCalculationUsageCmd, ApplyShippingCmd, BusinessPolicyCommand, CalculationCmd, ECCommand, ECTargetableCommand, TaskCommand

public class ApplyShippingCmdImpl
extends CalculationCmdImpl
implements ApplyShippingCmd

The default implementation of ApplyShippingCmd.

Its behaviour is as follows:

  1. for each item:
    1. determines the contract it references.
    2. determines ShippingTCShippingCharge of the contract.
    3. determines business policy of type "ShippingCharge" referenced by the ShippingTCShippingCharge.
  2. groups items sharing the same business policy.
  3. for each business policy, invokes the business policy command implementation it references (see the business policy command interface ApplyCalculationUsageCmd and its implementations, ApplyStandardShippingChargeBySellerCmdImpl and ApplyShippingChargeByCarrierCmdImpl).
  4. applies the service discounts generated by the discount calculation usage (see DiscountCalculationCodeCombineCmd and its default implementation, DiscountCalculationCodeCombineCmdImpl).

Commands used:

Access beans used:
See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          The IBM copyright string.
 
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. ApplyShippingCmd
defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
ApplyShippingCmdImpl()
          Contructor for ApplyShippingCmdImpl.
 
Method Summary
protected  void applyServiceDiscount( ServiceDiscount aServiceDiscount)
          Applies a service discount.
protected  void applyServiceDiscounts()
          Applies the service discounts generated by the discount calculation usage.
protected  void callApplyCalculationUsage(java.lang.Long anPolicyId, Item[] aItems)
          Invokes the business policy command implementation referenced by a business policy of type "ShippingCharge".
 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  java.lang.Long getPolicyId(java.lang.Long anTradingId)
          Determines the business policy of type "ShippingCharge" associated with a contract.
 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.
 
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 string.
See Also:
Constant Field Values
Constructor Detail

ApplyShippingCmdImpl

public ApplyShippingCmdImpl()
Contructor for ApplyShippingCmdImpl.
Method Detail

applyServiceDiscount

protected void applyServiceDiscount(ServiceDiscount aServiceDiscount)
                             throws ECException
Applies a service discount. For more information, refer to DiscountCalculationCodeCombineCmd and its default implementation, DiscountCalculationCodeCombineCmdImpl.
Parameters:
aServiceDiscount - the service discount.
Throws:
ECException

applyServiceDiscounts

protected void applyServiceDiscounts()
                              throws ECException
Applies the service discounts generated by the discount calculation usage. For more information, refer to DiscountCalculationCodeCombineCmd and its default implementation, DiscountCalculationCodeCombineCmdImpl.
Throws:
ECException

callApplyCalculationUsage

protected void callApplyCalculationUsage(java.lang.Long anPolicyId,
Item[] aItems)
                                  throws ECException
Invokes the business policy command implementation referenced by a business policy of type "ShippingCharge". This method is called by performExecute(). For more information, refer to the business policy command interface ApplyCalculationUsageCmd and its implementations, ApplyStandardShippingChargeBySellerCmdImpl and ApplyShippingChargeByCarrierCmdImpl.
Parameters:
anPolicyId - the business policy ID.
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).

getPolicyId

protected java.lang.Long getPolicyId(java.lang.Long anTradingId)
                              throws ECException
Determines the business policy of type "ShippingCharge" associated with a contract. This method is called by performExecute().
Parameters:
anTradingId - the contract ID.
Returns:
the business policy ID.
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()

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.