atg.commerce.order.purchase
Class CommerceItemShippingInfoTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.purchase.CommerceItemShippingInfoTools
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class CommerceItemShippingInfoTools
extends GenericService

This tools component contains API that is shared between the ShippingGroupDroplet and ShippingGroupFormHandler to modify the CommerceItemShippingInfo objects


Field Summary
static java.lang.String CLASS_VERSION
           
protected  CommerceItemManager mCommerceItemManager
           
protected  GiftlistManager mGiftlistManager
           
protected  HandlingInstructionManager mHandlingInstructionManager
           
protected  boolean mIncludeGifts
           
protected  ShippingGroupManager mShippingGroupManager
           
protected  int mSplitByUnitLimit
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CommerceItemShippingInfoTools()
           
 
Method Summary
protected  CommerceItemShippingInfo addNewCommerceItemShippingInfoFromOrder(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, CommerceItem pItem, java.lang.String pRelationshipType, long pQuantity, ShippingGroup pShippingGroup, java.util.Collection pShippingGroupMatchers)
          Create a CommerceItemShippingInfo from the information given and adds it to the container.
protected  void adjustHandlingInstructionsForSplit(CommerceItemShippingInfo pOriginalInfo, CommerceItemShippingInfo pNewInfo, long pSplitQuantity)
          Moves or splits handling instructions after a splitting a CommerceItemShippingInfo
 void applyCommerceItemShippingInfo(CommerceItemShippingInfo pCommerceItemShippingInfo, Order pOrder, ShippingGroupMapContainer pShippingGroupMapContainer)
          applyCommerceItemShippingInfo get the Relatonship type from the CommerceItemShippingInfo then invoke the business logic in CommerceItemManager to update the order.
 void applyCommerceItemShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, Order pOrder, boolean pConsolidateBeforeApply, boolean pApplyDefaultShipping)
          Applies the CommerceItemShippingInfos to the order.
 void applyDefaultShippingGroup(Order pOrder, ShippingGroupMapContainer pShippingGroupMapContainer)
          applyDefaultShippingGroup checks to see if there is a defaultShippingGroup.
 void applyHandlingInstructions(CommerceItemShippingInfo pCommerceItemShippingInfo, ShippingGroup pShippingGroup)
          Applies the handling instructions on the CommerceItemShippingInfo to the given shipping group
 void clearCommerceItemShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer)
          Clears the shipping group map container.
 void clearShippingGroups(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer)
          Clears the shipping group map container.
protected  void consolidateShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingGroupContainer)
          consolidateShippingInfos consolidates CommerceItemShippingInfos by ensuring there is no redundant data.
protected  CommerceItemShippingInfo createCommerceItemShippingInfo(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, CommerceItem pItem, java.lang.String pRelationshipType, long pQuantity, ShippingGroup pShippingGroup, java.lang.String pShippingGroupName)
          Creates a CommerceItemShippingInfo for the given item, relationship type, quantity and shipping group name.
protected  HandlingInstructionInfo createHandlingInstructionInfo(HandlingInstruction pHandlingInstruction, long pQuantity)
          Creates a new HandlingInstructionInfo object
protected  void createHandlingInstructionInfos(CommerceItemShippingInfo pCommerceItemShippingInfo, java.util.Collection pHandlingInstructions)
          Creates the handling instruction infos for each on the given handling instructions
protected  void createHandlingInstructionInfos(CommerceItemShippingInfo pCommerceItemShippingInfo, ShippingGroup pShippingGroup)
          Creates handling instruction infos for the handling instructions on the given shipping group for the given item.
 void debug(java.lang.String pDebugString)
           
protected  long determineQuantityOfGifts(CommerceItemShippingInfo pCommerceItemShippingInfo)
          Helper method that returns the sum of all gift handling instruction quantities
protected  void ensureGiftRegistryAddresses(Order pOrder, ShippingGroupMapContainer pShippingGroupMapContainer, java.util.Collection pShippingGroupMatchers)
          Ensures that all gift registry addresses are in the shipping group map
protected  HandlingInstructionInfo findGiftlistHandlingInstructionWithQuantity(CommerceItemShippingInfo pCommerceItemShippingInfo, long pQuantity)
          Helper method to find the first gift list handling instruction with a specific quantity
 java.util.List getAllNonGiftHandlingInstructionsForCommerceItem(Order pOrder, java.lang.String pCommerceItemId)
          Return a list of all handling instructions for the given commerce item, excluding gift handling instructions
 CommerceItemManager getCommerceItemManager()
          Return the CommerceItemManager property.
 GiftlistManager getGiftlistManager()
          Return the GiftlistManager property.
 HandlingInstructionManager getHandlingInstructionManager()
          Returns property handlingInstructionManager
 java.util.List getNonGiftHandlingInstructionsForCommerceItem(ShippingGroup pShippingGroup, java.lang.String pCommerceItemId)
          Return a list of handling instructions for the given commerce item and shipping group, excluding gift handling instructions
protected  ShippingGroup getShippingGroup(ShippingGroupMapContainer pShippingGroupMapContainer, java.lang.String pShippingGroupId)
          getShippingGroup gets the ShippingGroup with the given name from the ShippingGroupMapContainer.
 ShippingGroupManager getShippingGroupManager()
          Return the ShippingGroupManager property.
 int getSplitByUnitLimit()
          Gets the maximum commerce item quantity that can be split into single units.
 void initCommerceItemShippingInfoToDefaultShippingGroup(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, Order pOrder, CommerceItem pItem)
          Creates a CommerceItemShippingInfo for the item that points to the default shipping group name as specified by the ShippingGroupMapContainer.defaultShippingGroupName.
 void initializeBasedOnOrder(Order pOrder, CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, java.util.Collection pShippinGroupMatchers, boolean pOnePerUnit)
          Initializes the containers based on the contents of the item to shipping group relationships in the order.
 void initializeBasedOnShippingRelationships(Order pOrder, CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, java.util.Collection pShippinGroupMatchers)
          Initializes the CommerceItemShippingInfos and ShippingGroups based on the items and their relationships to the shipping groups.
 void initializeCommerceItemShippingInfosToDefaultShipping(Order pOrder, CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer, boolean pOnePerUnit)
          Creates a CommerceItemShippingInfo for each item in the order.
 void initializeUserShippingMethods(ShippingGroupMapContainer pShippingGroupMapContainer, Profile pProfile, java.lang.String[] pShippingGroupTypes, java.util.Map pShippingGroupInitializers)
          Initializes the shipping group map container for the shipping group types provided.
 boolean isIncludeGifts()
          Determines if gift items are included when initializing the commerce item info and shipping group containers.
protected  CommerceItemShippingInfo mergeCommerceItemShippingInfos(CommerceItemShippingInfo pCisi1, CommerceItemShippingInfo pCisi2)
          mergeCommerceItemShippingInfos merges 2 CommerceItemShippingInfos into one by combining their quantities.
protected  void mergeHandlingInstruction(CommerceItemShippingInfo pCommerceItemShippingInfo, HandlingInstructionInfo pHandlingInstructionInfo)
          Merges the handling instruction with the handling instructions on the given CommerceItemShippingInfo
protected  void moveHandlingInstructionInfo(CommerceItemShippingInfo pFromInfo, CommerceItemShippingInfo pToInfo, HandlingInstructionInfo pHandlingInstructionInfo)
          Moves a handling instruction from the original to new CommerceItemShippingInfo
protected  void movePartialHandlingInstruction(CommerceItemShippingInfo pFromInfo, CommerceItemShippingInfo pToInfo, HandlingInstructionInfo pHandlingInstructionInfo, long pQuantityToMove)
          Moves a portion of a handling instruction from the original to new CommerceItemShippingInfo
 void removeDeletedShippingGroups(ShippingGroupMapContainer pShippingGroupMapContainer)
          Removes shipping groups in the container that have a backing repository item that has been removed from the repository.
protected  void removeNonGiftQuantityFromRelationships(Order pOrder, ShippingGroup pShippingGroup)
          Removes all non-gift quantity from the items relationship to the shipping group.
 void removeShippingGroupsBeforeApply(Order pOrder)
          This method prepares the order before applying the CommerceItemShippingInfos.
 void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
          Set the CommerceItemManager property.
 void setGiftlistManager(GiftlistManager pGiftlistManager)
          Set the GiftlistManager property.
 void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
          Sets property handlingInstructionManager
 void setIncludeGifts(boolean pIncludeGifts)
           
 void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
          Set the ShippingGroupManager property.
 void setSplitByUnitLimit(int pSplitByUnitLimit)
          Sets the maximum commerce item quantity that can be split into single units.
 void specifyDefaultShippingGroup(ShippingGroupMapContainer ShippingGroupMapContainer, java.lang.String pDefaultShippingGroupName)
          Sets the defaultShippingGroupName in the ShippingGroupMapContainer.
 CommerceItemShippingInfo splitCommerceItemShippingInfoByQuantity(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, CommerceItemShippingInfo pCommerceItemShippingInfo, long pSplitQuantity)
          splitCommerceItemShippingInfoByQuantity splits a CommerceItemShippingInfo by quantity.
protected  void splitCommerceItemShippingInfosByGift(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer)
          Used to split the CommerceItemShippingInfos based on the gifts items contained in each one.
protected  void splitCommerceItemShippingInfosByUnit(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer, ShippingGroupMapContainer pShippingGroupMapContainer)
          Splits the CommerceItemShippingInfo objects, creating one for each unit.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

mCommerceItemManager

protected CommerceItemManager mCommerceItemManager

mGiftlistManager

protected GiftlistManager mGiftlistManager

mShippingGroupManager

protected ShippingGroupManager mShippingGroupManager

mHandlingInstructionManager

protected HandlingInstructionManager mHandlingInstructionManager

mIncludeGifts

protected boolean mIncludeGifts

mSplitByUnitLimit

protected int mSplitByUnitLimit
Constructor Detail

CommerceItemShippingInfoTools

public CommerceItemShippingInfoTools()
Method Detail

setCommerceItemManager

public void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
Set the CommerceItemManager property.

Parameters:
pCommerceItemManager - a CommerceItemManager value

getCommerceItemManager

public CommerceItemManager getCommerceItemManager()
Return the CommerceItemManager property.

Returns:
a CommerceItemManager value

setGiftlistManager

public void setGiftlistManager(GiftlistManager pGiftlistManager)
Set the GiftlistManager property.

Parameters:
pGiftlistManager - a GiftlistManager value

getGiftlistManager

public GiftlistManager getGiftlistManager()
Return the GiftlistManager property.

Returns:
a GiftlistManager value

setShippingGroupManager

public void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
Set the ShippingGroupManager property.

Parameters:
pShippingGroupManager - a ShippingGroupManager value

getShippingGroupManager

public ShippingGroupManager getShippingGroupManager()
Return the ShippingGroupManager property.

Returns:
a ShippingGroupManager value

getHandlingInstructionManager

public HandlingInstructionManager getHandlingInstructionManager()
Returns property handlingInstructionManager

Returns:
returns property handlingInstructionManager

setHandlingInstructionManager

public void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
Sets property handlingInstructionManager

Parameters:
pHandlingInstructionManager - the value to set for property handlingInstructionManager

isIncludeGifts

public boolean isIncludeGifts()
Determines if gift items are included when initializing the commerce item info and shipping group containers.

default is false

Returns:

setIncludeGifts

public void setIncludeGifts(boolean pIncludeGifts)

getSplitByUnitLimit

public int getSplitByUnitLimit()
Gets the maximum commerce item quantity that can be split into single units.

default is 500

Returns:
the maximum quantity that can be split into single units

setSplitByUnitLimit

public void setSplitByUnitLimit(int pSplitByUnitLimit)
Sets the maximum commerce item quantity that can be split into single units.


debug

public void debug(java.lang.String pDebugString)

movePartialHandlingInstruction

protected void movePartialHandlingInstruction(CommerceItemShippingInfo pFromInfo,
                                              CommerceItemShippingInfo pToInfo,
                                              HandlingInstructionInfo pHandlingInstructionInfo,
                                              long pQuantityToMove)
Moves a portion of a handling instruction from the original to new CommerceItemShippingInfo

Parameters:
pFromInfo - the item containing the handling instruction
pToInfo - the item to receive a portion of the handling instruction
pHandlingInstruction - the handling instruciton info
pQuantityToMove - the quantity to move to the pToInfo

createHandlingInstructionInfo

protected HandlingInstructionInfo createHandlingInstructionInfo(HandlingInstruction pHandlingInstruction,
                                                                long pQuantity)
Creates a new HandlingInstructionInfo object

Parameters:
pHandlingInstruction -
pQuantity -
Returns:
HandlingInstructionInfo

moveHandlingInstructionInfo

protected void moveHandlingInstructionInfo(CommerceItemShippingInfo pFromInfo,
                                           CommerceItemShippingInfo pToInfo,
                                           HandlingInstructionInfo pHandlingInstructionInfo)
Moves a handling instruction from the original to new CommerceItemShippingInfo

Parameters:
pFromInfo -
pNewInfo -
pHandlingInstructionInfo -

determineQuantityOfGifts

protected long determineQuantityOfGifts(CommerceItemShippingInfo pCommerceItemShippingInfo)
Helper method that returns the sum of all gift handling instruction quantities

Parameters:
pCommerceItemShippingInfo -

findGiftlistHandlingInstructionWithQuantity

protected HandlingInstructionInfo findGiftlistHandlingInstructionWithQuantity(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                                                              long pQuantity)
Helper method to find the first gift list handling instruction with a specific quantity

Parameters:
pCommerceItemShippingInfo -
pQuantity -
Returns:
HandlingInstructionInfo with gift handling instruction and matching quantity, or null

adjustHandlingInstructionsForSplit

protected void adjustHandlingInstructionsForSplit(CommerceItemShippingInfo pOriginalInfo,
                                                  CommerceItemShippingInfo pNewInfo,
                                                  long pSplitQuantity)
                                           throws CommerceException
Moves or splits handling instructions after a splitting a CommerceItemShippingInfo

Determines if the handling instructions on the original CommerceItemShippingInfo need to be split between the new CommerceItemShippingInfo

There are two reasons for which a gift handling instruction needs to split 1. because the original hi.qty > originalInfo.qty 2. because the original hi.qty + other gift quantitys > originalInfo.qty All other handling instructions are split when their quantity exceeds the originalInfo.qty

Parameters:
pOriginalInfo - the original CommerceItemShippingInfo that was split
pNewInfo - the new CommerceItemShippingInfo that was created by the split operation
pSplitQuantity - the quantity of the split operation.
Throws:
CommerceException

splitCommerceItemShippingInfoByQuantity

public CommerceItemShippingInfo splitCommerceItemShippingInfoByQuantity(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                                        CommerceItemShippingInfo pCommerceItemShippingInfo,
                                                                        long pSplitQuantity)
                                                                 throws CommerceException
splitCommerceItemShippingInfoByQuantity splits a CommerceItemShippingInfo by quantity. This creates a new CommerceItemShippingInfo, adjusts properties of both the original and the new object, and adds the new object to the CommerceItemShippingInfoContainer.

Parameters:
pCommerceItemShippingInfoContainer - the container with the infos
pCommerceItemShippingInfo - a CommerceItemShippingInfo to be split
pSplitQuantity - the quantity to split off into a new CommerceItemShippingInfo
Returns:
the new CommerceItemShippingInfo that was generated as a result of the split.
Throws:
CommerceException
See Also:
adjustHandlingInstructionsForSplit(CommerceItemShippingInfo, CommerceItemShippingInfo, long)

splitCommerceItemShippingInfosByUnit

protected void splitCommerceItemShippingInfosByUnit(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                    ShippingGroupMapContainer pShippingGroupMapContainer)
                                             throws CommerceException
Splits the CommerceItemShippingInfo objects, creating one for each unit. For example, an item with quantity of 5 ends up with 5 CommerceItemShippingInfo objects.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
Throws:
CommerceException

splitCommerceItemShippingInfosByGift

protected void splitCommerceItemShippingInfosByGift(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                    ShippingGroupMapContainer pShippingGroupMapContainer)
                                             throws CommerceException
Used to split the CommerceItemShippingInfos based on the gifts items contained in each one.

Gifts are identified by the gift handling instructions on each CommerceItemShippingInfo. A split is issued based on the quantity of a gift handling instruction if the cisi quantity is greather than the handling instruction quantity.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
Throws:
CommerceException

initializeBasedOnOrder

public void initializeBasedOnOrder(Order pOrder,
                                   CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                   ShippingGroupMapContainer pShippingGroupMapContainer,
                                   java.util.Collection pShippinGroupMatchers,
                                   boolean pOnePerUnit)
                            throws CommerceException
Initializes the containers based on the contents of the item to shipping group relationships in the order.

Will optionally create one CISI per item unit or create seperate CISI's for gift items.

Parameters:
pOrder -
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pShippinGroupMatchers -
pOnePerUnit - determines if one CommerceItemShippingInfos ais created for each individual item unit.
Throws:
CommerceException
See Also:
splitCommerceItemShippingInfosByUnit(CommerceItemShippingInfoContainer, ShippingGroupMapContainer), splitCommerceItemShippingInfosByGift(CommerceItemShippingInfoContainer, ShippingGroupMapContainer)

initializeCommerceItemShippingInfosToDefaultShipping

public void initializeCommerceItemShippingInfosToDefaultShipping(Order pOrder,
                                                                 CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                                 ShippingGroupMapContainer pShippingGroupMapContainer,
                                                                 boolean pOnePerUnit)
Creates a CommerceItemShippingInfo for each item in the order.

Each one is initialized to the default shipping group name as defined in the ShippingGroupMapContainer.

Parameters:
pOrder -
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pOnePerUnit -

initializeBasedOnShippingRelationships

public void initializeBasedOnShippingRelationships(Order pOrder,
                                                   CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                   ShippingGroupMapContainer pShippingGroupMapContainer,
                                                   java.util.Collection pShippinGroupMatchers)
                                            throws CommerceException
Initializes the CommerceItemShippingInfos and ShippingGroups based on the items and their relationships to the shipping groups.

Parameters:
pOrder -
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pShippinGroupMatchers -
Throws:
CommerceException

initCommerceItemShippingInfoToDefaultShippingGroup

public void initCommerceItemShippingInfoToDefaultShippingGroup(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                               ShippingGroupMapContainer pShippingGroupMapContainer,
                                                               Order pOrder,
                                                               CommerceItem pItem)
Creates a CommerceItemShippingInfo for the item that points to the default shipping group name as specified by the ShippingGroupMapContainer.defaultShippingGroupName.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pOrder -
pItem -

createCommerceItemShippingInfo

protected CommerceItemShippingInfo createCommerceItemShippingInfo(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                                  ShippingGroupMapContainer pShippingGroupMapContainer,
                                                                  CommerceItem pItem,
                                                                  java.lang.String pRelationshipType,
                                                                  long pQuantity,
                                                                  ShippingGroup pShippingGroup,
                                                                  java.lang.String pShippingGroupName)
Creates a CommerceItemShippingInfo for the given item, relationship type, quantity and shipping group name.

If pShippingGroup is provided, the shipping info's shippingMethod and handling instructions are set to match the shipping group.

Parameters:
pItem - the commerce item
pRelationshipType - the relationship type for the info
pQuantity - the quantity for the info
pShippingGroup - the shipping group associated with the shipping info (optional)
pShippingGroupName - the name of the shipping group in the map to which the info should be associated.
Returns:
CommerceItemShippingInfo

createHandlingInstructionInfos

protected void createHandlingInstructionInfos(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                              ShippingGroup pShippingGroup)
Creates handling instruction infos for the handling instructions on the given shipping group for the given item.

Parameters:
pCommerceItemShippingInfo -
pShippingGroup -

createHandlingInstructionInfos

protected void createHandlingInstructionInfos(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                              java.util.Collection pHandlingInstructions)
Creates the handling instruction infos for each on the given handling instructions

Parameters:
pCommerceItemShippingInfo -
pHandlingInstructions -

getNonGiftHandlingInstructionsForCommerceItem

public java.util.List getNonGiftHandlingInstructionsForCommerceItem(ShippingGroup pShippingGroup,
                                                                    java.lang.String pCommerceItemId)
Return a list of handling instructions for the given commerce item and shipping group, excluding gift handling instructions

Parameters:
pShippingGroup - the shipping group containing the handling instructions
pCommerceItemId - The id of the item
Returns:
a list of handling instructions for the given commerce item and shipping group, excluding gift handling instructions

getAllNonGiftHandlingInstructionsForCommerceItem

public java.util.List getAllNonGiftHandlingInstructionsForCommerceItem(Order pOrder,
                                                                       java.lang.String pCommerceItemId)
Return a list of all handling instructions for the given commerce item, excluding gift handling instructions

Parameters:
pOrder - the order containing the item
pCommerceItemId - The id of the item
Returns:
a list of all handling instructions for the given commerce item, excluding gift handling instructions

addNewCommerceItemShippingInfoFromOrder

protected CommerceItemShippingInfo addNewCommerceItemShippingInfoFromOrder(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                                                           ShippingGroupMapContainer pShippingGroupMapContainer,
                                                                           CommerceItem pItem,
                                                                           java.lang.String pRelationshipType,
                                                                           long pQuantity,
                                                                           ShippingGroup pShippingGroup,
                                                                           java.util.Collection pShippingGroupMatchers)
                                                                    throws CommerceException
Create a CommerceItemShippingInfo from the information given and adds it to the container. Also adds the given shipping group to the map container

If IncludeGifts is false then only the quantity of the item that is not a gift is accounted for in the new CISI. If the entire quantity is a gift then no item is created and null is returned.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pItem -
pRelationshipType -
pQuantity -
pShippingGroup -
pShippingGroupMatchers -
Returns:
the CommerceItemShippingInfo that was created and added
Throws:
CommerceException

ensureGiftRegistryAddresses

protected void ensureGiftRegistryAddresses(Order pOrder,
                                           ShippingGroupMapContainer pShippingGroupMapContainer,
                                           java.util.Collection pShippingGroupMatchers)
Ensures that all gift registry addresses are in the shipping group map

Parameters:
pOrder -
pShippingGroupMapContainer -
pShippingGroupMatchers -

applyCommerceItemShippingInfos

public void applyCommerceItemShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                           ShippingGroupMapContainer pShippingGroupMapContainer,
                                           Order pOrder,
                                           boolean pConsolidateBeforeApply,
                                           boolean pApplyDefaultShipping)
                                    throws CommerceException
Applies the CommerceItemShippingInfos to the order.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -
pOrder -
pConsolidateBeforeApply -
pApplyDefaultShipping -
Throws:
CommerceException

applyDefaultShippingGroup

public void applyDefaultShippingGroup(Order pOrder,
                                      ShippingGroupMapContainer pShippingGroupMapContainer)
                               throws CommerceException
applyDefaultShippingGroup checks to see if there is a defaultShippingGroup. If so, this ShippingGroup is added to the remaining quantity of each CommerceItem whose quantity is not already fully assigned to ShippingGroups.

Parameters:
pOrder - an Order value
Throws:
CommerceException

applyCommerceItemShippingInfo

public void applyCommerceItemShippingInfo(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                          Order pOrder,
                                          ShippingGroupMapContainer pShippingGroupMapContainer)
                                   throws CommerceException
applyCommerceItemShippingInfo get the Relatonship type from the CommerceItemShippingInfo then invoke the business logic in CommerceItemManager to update the order.

Parameters:
pCommerceItemShippingInfo - a CommerceItemShippingInfo value
pOrder - an Order value
pShippingGroupMapContainer - the map container that contains the shipping groups associated with the given shipping info
Throws:
CommerceException

applyHandlingInstructions

public void applyHandlingInstructions(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                      ShippingGroup pShippingGroup)
                               throws CommerceException
Applies the handling instructions on the CommerceItemShippingInfo to the given shipping group

Parameters:
pCommerceItemShippingInfo -
pShippingGroup -
Throws:
CommerceException

getShippingGroup

protected ShippingGroup getShippingGroup(ShippingGroupMapContainer pShippingGroupMapContainer,
                                         java.lang.String pShippingGroupId)
getShippingGroup gets the ShippingGroup with the given name from the ShippingGroupMapContainer.

Parameters:
pShippingGroupMapContainer - the container that contains the shipping group
pShippingGroupId - a String value
Returns:
a ShippingGroup value

consolidateShippingInfos

protected void consolidateShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingGroupContainer)
                                 throws CommerceException
consolidateShippingInfos consolidates CommerceItemShippingInfos by ensuring there is no redundant data.

Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs
CommerceException

mergeCommerceItemShippingInfos

protected CommerceItemShippingInfo mergeCommerceItemShippingInfos(CommerceItemShippingInfo pCisi1,
                                                                  CommerceItemShippingInfo pCisi2)
                                                           throws CommerceException
mergeCommerceItemShippingInfos merges 2 CommerceItemShippingInfos into one by combining their quantities.

Parameters:
pCisi1 - a CommerceItemShippingInfo value
pCisi2 - a CommerceItemShippingInfo value
Returns:
a CommerceItemShippingInfo value
Throws:
CommerceException

mergeHandlingInstruction

protected void mergeHandlingInstruction(CommerceItemShippingInfo pCommerceItemShippingInfo,
                                        HandlingInstructionInfo pHandlingInstructionInfo)
Merges the handling instruction with the handling instructions on the given CommerceItemShippingInfo

Merge is done by either incrementing the quantity on a matching handling instruction or by adding the handling instruction to the CommerceItemShippingInfo

Gift handling instructions are merged if the gift list, gift item and handling methods are equal.

All other handling instructions are merged if the handling methods are equal.

Parameters:
pCommerceItemShippingInfo -
pHandlingInstructionInfo -

removeDeletedShippingGroups

public void removeDeletedShippingGroups(ShippingGroupMapContainer pShippingGroupMapContainer)
Removes shipping groups in the container that have a backing repository item that has been removed from the repository.

This can happen when a shipping group was applied to an order and then "unapplied", causing the cascade delete on the repository item to remove it from the repository.


initializeUserShippingMethods

public void initializeUserShippingMethods(ShippingGroupMapContainer pShippingGroupMapContainer,
                                          Profile pProfile,
                                          java.lang.String[] pShippingGroupTypes,
                                          java.util.Map pShippingGroupInitializers)
Initializes the shipping group map container for the shipping group types provided.

For each type, the shipping group initializers createe shipping groups based on the profile.

Parameters:
pShippingGroupMapContainer -
pProfile -
pShippingGroupTypes -
pShippingGroupInitializers -

specifyDefaultShippingGroup

public void specifyDefaultShippingGroup(ShippingGroupMapContainer ShippingGroupMapContainer,
                                        java.lang.String pDefaultShippingGroupName)
                                 throws javax.servlet.ServletException,
                                        java.io.IOException
Sets the defaultShippingGroupName in the ShippingGroupMapContainer.

Throws:
javax.servlet.ServletException
java.io.IOException

clearShippingGroups

public void clearShippingGroups(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                ShippingGroupMapContainer pShippingGroupMapContainer)
Clears the shipping group map container.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -

clearCommerceItemShippingInfos

public void clearCommerceItemShippingInfos(CommerceItemShippingInfoContainer pCommerceItemShippingInfoContainer,
                                           ShippingGroupMapContainer pShippingGroupMapContainer)
Clears the shipping group map container.

Parameters:
pCommerceItemShippingInfoContainer -
pShippingGroupMapContainer -

removeShippingGroupsBeforeApply

public void removeShippingGroupsBeforeApply(Order pOrder)
                                     throws CommerceException
This method prepares the order before applying the CommerceItemShippingInfos.

If gifts are being included all shipping groups, with the exception of the non-modifiable shipping groups identified by the ShippingGroupManager, are removed from the order.

If gifts are not included, shipping groups that contain gifts exclusively are left in the order. All other shipping groups that contain a mix of gift and non-gift items are adjusted to remove the non-gift quantities and handling instructions.

Parameters:
pOrder -
Throws:
CommerceException

removeNonGiftQuantityFromRelationships

protected void removeNonGiftQuantityFromRelationships(Order pOrder,
                                                      ShippingGroup pShippingGroup)
                                               throws CommerceException
Removes all non-gift quantity from the items relationship to the shipping group. The idea is to leave ony the gift information for the shipping group

Either the quantity is adjusted to a new value or the relationship is removed entirely when the new quantity is zero or it's a quantity remaining type relationship.

All non-gift handling instructions are also removed

Parameters:
pOrder -
pShippingGroup -
Throws:
CommerceException