com.ibm.commerce.order.calculation
Class DiscountCalculationCodeCombineCmdImpl

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
                                      |
                                      +--com.ibm.commerce.order.calculation.DiscountCalculationCodeCombineCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculationCmd, CalculationCodeCombineCmd, DiscountCalculationCodeCombineCmd, ECCommand, ECTargetableCommand, TaskCommand

public class DiscountCalculationCodeCombineCmdImpl
extends CalculationCodeCombineCmdImpl
implements DiscountCalculationCodeCombineCmd

The default implementation of CalculationCodeCombineCmd.

If rule based discount is enabled, its behaviour is as follows:

  1. calls InvokePersonalizationRuleServiceCommand to invoke the discount rule service.
  2. for each discount returned through the discount context (see Discount, DiscountContext):
    1. creates a group (see Group) that contains the following:
      • the calculation code referenced by the discount.
      • the items.
    2. for each monetary discount referenced by the discount (see MonetaryDiscount), adds its monetary values to the group by calling addMonetaryDiscount(Group, MonetaryDiscount).
    3. for each fixed price item referenced by the discount (see FixedPriceItem), adds its monetary values to the group by calling addFixedPriceItem(Group, FixedPriceItem).
    4. for each freebie item referenced by the discount (see FreebieItem), adds its monetary values to the group by calling addFreebieItem(Group, FreebieItem).
    5. for each service discount referenced by the discount (see ServiceDiscount), adds the service discount to the custom property "vecServiceDiscounts" by calling addServiceDiscount(ServiceDiscount).

If rule based discount is not enabled, its behaviour is the same as that of CalculationCodeCombineCmdImpl.

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. DiscountCalculationCodeCombineCmd
defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
DiscountCalculationCodeCombineCmdImpl()
          Constructor for DiscountCalculationCodeCombineCmdImpl.
 
Method Summary
protected  void addFixedPriceItem( Group aGroup, FixedPriceItem aFixedPriceItem)
          Processes the specified FixedPriceItem and adds the corresponding discount values to the specified Group.
protected  void addFreebieItem( Group aGroup, FreebieItem aFreebieItem)
          Processes the specified FreebieItem and adds the corresponding discount values to the specified Group.
protected  void addMonetaryDiscount( Group aGroup, MonetaryDiscount aMonetaryDiscount)
          Processes the specified MonetaryDiscount and adds the corresponding discount values to the specified Group.
protected  void addServiceDiscount( ServiceDiscount aServiceDiscount)
          Adds the specified ServiceDiscount to the custom property "vecServiceDiscounts" - a Vector of ServiceDiscounts.
protected  DiscountContext createDiscountContext()
          Creates the DiscountContext.
protected  CalculationCodeAccessBean[] getCodes( Item aItem)
          Returns the calculation codes attached to an item.
protected  CalculationCodeAccessBean getRuleBasedDiscountCode( Discount aDiscount)
          Returns the CalculationCodeAccessBean corresponding to the specified Discount.
protected  java.math.BigDecimal[] getRunningNetPrices()
          Returns the running net prices of Items returned by CalculationCodeCombineCmdImpl.getItems().
protected  void invokeRuleService( DiscountContext aDiscountContext)
          Invokes the rule service "Discount Service".
 void performExecute()
          The business logic for this command.
protected  void setRunningNetPrices(java.math.BigDecimal[] adRunningNetPrices)
          Sets the running net prices of Items returned by CalculationCodeCombineCmdImpl.getItems().
 
Methods inherited from class com.ibm.commerce.order.calculation. CalculationCodeCombineCmdImpl
addItem, callCodeQualify, createGroupKey, createGroups, getDefaultCode, getDirectlyAttachedCodes, getGroups, getIndirectlyAttachedCodes, getItems, getTaxCategoryIds, isDirectAttachmentsOverride, isRestricted, processItem, reset, setGroups, setItems, setTaxCategoryIds, toString
 
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. CalculationCodeCombineCmd
getGroups, setItems, setTaxCategoryIds
 
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

DiscountCalculationCodeCombineCmdImpl

public DiscountCalculationCodeCombineCmdImpl()
Constructor for DiscountCalculationCodeCombineCmdImpl.
Method Detail

getRunningNetPrices

protected java.math.BigDecimal[] getRunningNetPrices()
Returns the running net prices of Items returned by CalculationCodeCombineCmdImpl.getItems().
Returns:
the running net prices.

setRunningNetPrices

protected void setRunningNetPrices(java.math.BigDecimal[] adRunningNetPrices)
Sets the running net prices of Items returned by CalculationCodeCombineCmdImpl.getItems().
Parameters:
adRunningNetPrices - the running net prices.

addFixedPriceItem

protected void addFixedPriceItem(Group aGroup,
FixedPriceItem aFixedPriceItem)
                          throws ECException
Processes the specified FixedPriceItem and adds the corresponding discount values to the specified Group.
Parameters:
aGroup - the Group.
aFixedPriceItem - the FixedPriceItem.
Throws:
ECException

addFreebieItem

protected void addFreebieItem(Group aGroup,
FreebieItem aFreebieItem)
                       throws ECException
Processes the specified FreebieItem and adds the corresponding discount values to the specified Group.
Parameters:
aGroup - the Group.
aFreebieItem - the FreebieItem.
Throws:
ECException

addMonetaryDiscount

protected void addMonetaryDiscount(Group aGroup,
MonetaryDiscount aMonetaryDiscount)
                            throws ECException
Processes the specified MonetaryDiscount and adds the corresponding discount values to the specified Group.
Parameters:
aGroup - the Group.
aMonetaryDiscount - the MonetaryDiscount.
Throws:
ECException

addServiceDiscount

protected void addServiceDiscount(ServiceDiscount aServiceDiscount)
                           throws ECException
Adds the specified ServiceDiscount to the custom property "vecServiceDiscounts" - a Vector of ServiceDiscounts.
Parameters:
aServiceDiscount - the ServiceDiscount.
Throws:
ECException
See Also:
CalculationCmd#getCustomProperty(), CalculationCmd.setCustomProperty(String, Object)

createDiscountContext

protected DiscountContext createDiscountContext()
Creates the DiscountContext.
Returns:
the DiscountContext.

getRuleBasedDiscountCode

protected CalculationCodeAccessBean getRuleBasedDiscountCode(Discount aDiscount)
                                                      throws ECException
Returns the CalculationCodeAccessBean corresponding to the specified Discount.
Parameters:
aDiscount - the Discount.
Returns:
the CalculationCodeAccessBean.
Throws:
ECException

invokeRuleService

protected void invokeRuleService(DiscountContext aDiscountContext)
                          throws ECException
Invokes the rule service "Discount Service".
Parameters:
aDiscountContext - the DiscountContext.
Throws:
ECException

getCodes

protected CalculationCodeAccessBean[] getCodes(Item aItem)
                                        throws ECException
Returns the calculation codes attached to an item. This version returns only the calculation codes that are directly attached to the item. This method is called by CalculationCodeCombineCmdImpl.processItem(Item).
Overrides:
getCodes in class CalculationCodeCombineCmdImpl
Parameters:
aItem - the item.
Returns:
the calculation codes attached to the item.
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 CalculationCodeCombineCmdImpl
Throws:
ECException
See Also:
ECCommand.performExecute()