atg.commerce.order
Class ShippingGroupManager

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

public class ShippingGroupManager
extends GenericService

This class is the business layer object for managing and manipulating ShippingGroups. This class holds all the business logic for manipulating all types of ShippingGroups.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static java.util.ResourceBundle sResourceBundle
          Resource Bundle
 
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
ShippingGroupManager()
          Constructs a ShippingGroupManager object.
 
Method Summary
 void addRemainingShippingCostToPaymentGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pPaymentGroupId)
          Adds any unassigned amount of the ShippingGroup's cost with the given id to the PaymentGroup with the given id.
 void addShippingCostAmountToPaymentGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pPaymentGroupId, double pAmount)
          Adds the given amount of the ShippingGroup's cost with the given id to the PaymentGroup with the given id.
 java.lang.String addShippingGroupToMap(ShippingGroup pShippingGroup, ShippingGroupMapContainer pShippingGroupMapContainer, java.util.Collection pShippingGroupMatchers)
          Deprecated.  
 void addShippingGroupToOrder(Order pOrder, ShippingGroup pShippingGroup)
          Adds the given ShippingGroup to the given order.
 ShippingGroup cloneShippingGroup(ShippingGroup pShippingGroup)
          Duplicate the specified shipping group by creating a new instance of the same class and copying selected properties from the old shipping group to the new one.
 void copyShippingAddress(ShippingGroup pFromShippingGroup, ShippingGroupImpl pToShippingGroup)
          Copy the address from one shipping group to another
 void copySpecialInstructions(ShippingGroup pFromShippingGroup, ShippingGroupImpl pToShippingGroup)
          Copy the special instructions
 ShippingGroup createShippingGroup()
          Creates a new ShippingGroup object using the type mapped to the defaultShippingGroupType property in OrderTools.
 ShippingGroup createShippingGroup(java.lang.String pShippingGroupType)
          Creates a new ShippingGroup object using the type mapped to the type supplied in pShippingGroupType.
 ShippingGroup createShippingGroup(java.lang.String pShippingGroupType, ShippingPriceInfo pPriceInfo)
          Creates a new ShippingGroup object using the type mapped to the type supplied in pShippingGroupType.
 java.util.List getAllShippingGroupRelationships(Order pOrder)
          Provides a List of all ShippingGroupRelationships associated with the given Order.
 CommerceItemManager getCommerceItemManager()
          Returns property commerceItemManager
 java.util.List getElectronicShippingGroups(Order pOrder)
          Returns all the electronic shipping groups with commerce item relationships
 HardgoodShippingGroup getFirstNonGiftHardgoodShippingGroup(Order pOrder)
          Returns the first non-gift hardgood shipping group from the order
 HardgoodShippingGroup getFirstNonGiftHardgoodShippingGroupWithRels(Order pOrder)
          Returns the first non-gift hardgood shipping group with relationships from the order
 GiftlistManager getGiftlistManager()
          The giftlist manager
 java.util.List getGiftShippingGroups(Order pOrder)
          Returns a list of all shipping groups that contain gifts.
 HandlingInstructionManager getHandlingInstructionManager()
          Returns property handlingInstructionManager
 java.util.List getHardgoodShippingGroups(Order pOrder)
          Returns all the hardgood shipping groups with commerce item relationships
 java.lang.String getNewShippingGroupName(ShippingGroup pShippingGroup, java.util.Collection pShippingGroupMatchers)
          Deprecated. - This method is moved to ShippingGroupMapContainerService
 int getNonGiftHardgoodShippingGroupCount(Order pOrder)
          Returns the number of non-gift hardgood shipping groups with commerce item relationships
 java.util.List getNonGiftHardgoodShippingGroups(Order pOrder)
          Returns the non-gift hardgood shipping groups with commerce item relationships
 java.util.List getNonModifiableShippingGroups(Order pOrder)
          This method determines whether the shipping group is in a condusive to editing state
 java.lang.String[] getNonModifiableShippingGroupStates()
           
 OrderTools getOrderTools()
          Returns property orderTools
 PaymentGroupManager getPaymentGroupManager()
          Returns property paymentGroupManager
 long getRemainingQuantityForShippingGroup(CommerceItem pItem)
          Calculate the "quantity remaining" for a given item.
 ShippingGroup getShippingGroupByDescription(java.util.List pShippingGroups, java.lang.String pDescription)
          This method will return a ShippingGroup whose description is pDescription.
 ShippingGroupCommerceItemRelationship getShippingGroupCommerceItemRelationship(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId)
          Returns the relationship object which exists between the given CommerceItem and ShippingGroup.
 java.lang.String getShippingGroupName(ShippingGroup pShippingGroup, ShippingGroupMapContainer pShippingGroupMapContainer, java.util.Collection pShippingGroupMatchers)
          Deprecated.  
 boolean isAnyElectronicShippingGroups(Order pOrder)
          Returns true if the order has at least one electronic shipping group with commerce item relationships
 boolean isAnyHardgoodShippingGroups(Order pOrder)
          Returns true if the order has at least one hargood shipping group with commerce item relationships.
 boolean isAnyNonGiftHardgoodShippingGroups(Order pOrder)
          Determines if there are any non-gift hardgood shipping groups with relationships
 boolean isMultipleHardgoodShippingGroupsWithRelationships(Order pOrder)
          Returns true if the order has more than one hardgood shipping group with commerce item relationships
 boolean isMultipleNonGiftHardgoodItems(Order pOrder)
          Determines if the total quantity of all non-gift hardgood items is more than one.
 boolean isMultipleNonGiftHardgoodShippingGroups(Order pOrder)
          Returns true if the order has more than one non-gift hardgood shipping group with commerce item relationships
protected  boolean isNullAddress(Address pAddress)
          Query whether an Address object is null or empty.
 boolean isShippingGroupInOrder(Order pOrder, java.lang.String pShippingGroupId)
          isShippingGroupInOrder is used to determine if the ShippingGroup is already in the Order.
protected  ElectronicShippingGroup mergeOrdersCopyElectronicShippingGroup(Order pSrcOrder, Order pDstOrder, ElectronicShippingGroup pGroup)
          This method is used by mergeOrdersCopyShippingGroup to copy an electronic shipping group from a source order to a destination order.
protected  HardgoodShippingGroup mergeOrdersCopyHardgoodShippingGroup(Order pSrcOrder, Order pDstOrder, HardgoodShippingGroup pGroup)
          This method is used by mergeOrdersCopyShippingGroup to copy a hardgood shipping group from a source order to a destination order.
protected  ShippingGroup mergeOrdersCopyShippingGroup(Order pSrcOrder, Order pDstOrder, ShippingGroup pGroup)
          This method is used by OrderManager.mergeOrders to copy a shipping group from a source order to a destination order.
protected  void postCloneShippingGroup(ShippingGroup pOldGroup, ShippingGroup pNewGroup)
          This method is called just before cloneShippingGroup returns a newly created shipping group.
 void removeAllRelationshipsFromShippingGroup(Order pOrder, java.lang.String pShippingGroupId)
          Removes all the relationships from the ShippingGroup with the given id in the given order.
 void removeAllShippingGroupsFromOrder(Order pOrder)
          Removes all the ShippingGroups and their Relationships from an Order.
 void removeAllShippingGroupsFromOrder(Order pOrder, java.util.List pExclusions)
          Removes ShippingGroups and their Relationships from an Order, retaining the ShippingGroups passed in via the exclusion list parameter.
 void removeEmptyShippingGroups(Order pOrder)
          Removes all the ShippingGroups which have no CommerceItems.
 void removeRemainingShippingCostFromPaymentGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pPaymentGroupId)
          Removes the "remaining" amount of the ShippingGroup with the given id from the PaymentGroup with the given id.
 void removeShippingCostAmountFromPaymentGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pPaymentGroupId, double pAmount)
          Removes the given amount of the ShippingGroup's cost with the given id from the PaymentGroup with the given id.
 void removeShippingGroupFromOrder(Order pOrder, java.lang.String pShippingGroupId)
          Removes the given ShippingGroup from the given order.
 void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
          Sets property commerceItemManager
 void setGiftlistManager(GiftlistManager pGiftlistManager)
          Specifies the GiftlistManager.
 void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
          Sets property handlingInstructionManager
 void setNonModifiableShippingGroupStates(java.lang.String[] pNonModifiableShippingGroupStates)
          Sets array of shipping group states that indicate that a shipping group is not modifiable
 void setOrderTools(OrderTools pOrderTools)
          Sets property orderTools
 void setPaymentGroupManager(PaymentGroupManager pPaymentGroupManager)
          Sets property paymentGroupManager
 boolean shippingGroupIsModifiable(ShippingGroup pShippingGroup)
          This method determines whether the shipping group is in a condusive to editing state
 java.util.List splitShippingGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String[] pItemIds)
          Moves a set of Items from a ShippingGroup to a new ShippingGroup.
 java.util.List splitShippingGroup(Order pOrder, java.lang.String pShippingGroupId, java.lang.String[] pItemIds, long[] pQuantities)
          Moves a set of Items from a ShippingGroup to a new ShippingGroup.
protected  java.util.List splitShippingGroupWithImplicitRelationships(Order pOrder, ShippingGroup pShippingGroup, java.lang.String[] pItemIds, long[] pQuantities)
          This method is called by splitShippingGroup().
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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
Class version string

See Also:
Constant Field Values

sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle

Constructor Detail

ShippingGroupManager

public ShippingGroupManager()
Constructs a ShippingGroupManager object.

Method Detail

getOrderTools

public OrderTools getOrderTools()
Returns property orderTools

Returns:
returns property orderTools

setOrderTools

public void setOrderTools(OrderTools pOrderTools)
Sets property orderTools

Parameters:
pOrderTools - the value to set for property orderTools

getCommerceItemManager

public CommerceItemManager getCommerceItemManager()
Returns property commerceItemManager

Returns:
returns property commerceItemManager

setCommerceItemManager

public void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
Sets property commerceItemManager

Parameters:
pCommerceItemManager - the value to set for property commerceItemManager

getPaymentGroupManager

public PaymentGroupManager getPaymentGroupManager()
Returns property paymentGroupManager

Returns:
returns property paymentGroupManager

setPaymentGroupManager

public void setPaymentGroupManager(PaymentGroupManager pPaymentGroupManager)
Sets property paymentGroupManager

Parameters:
pPaymentGroupManager - the value to set for property paymentGroupManager

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

setNonModifiableShippingGroupStates

public void setNonModifiableShippingGroupStates(java.lang.String[] pNonModifiableShippingGroupStates)
Sets array of shipping group states that indicate that a shipping group is not modifiable

Parameters:
pNonModifiableShippingGroupStates - an array of shipping group states that indicate that a shipping group is not modifiable

getNonModifiableShippingGroupStates

public java.lang.String[] getNonModifiableShippingGroupStates()
Returns:
an array of shipping group states that indicate that a shipping group is not modifiable

setGiftlistManager

public void setGiftlistManager(GiftlistManager pGiftlistManager)
Specifies the GiftlistManager.

Parameters:
pGiftlistManager - a GiftlistManager value

getGiftlistManager

public GiftlistManager getGiftlistManager()
The giftlist manager

Returns:
a GiftlistManager value

getGiftShippingGroups

public java.util.List getGiftShippingGroups(Order pOrder)
Returns a list of all shipping groups that contain gifts.

Parameters:
pOrder - the order to use.
Returns:

getNonGiftHardgoodShippingGroupCount

public int getNonGiftHardgoodShippingGroupCount(Order pOrder)
Returns the number of non-gift hardgood shipping groups with commerce item relationships

Parameters:
pOrder - the order to use.
Returns:
the number of non-empty non-gift hardgood shipping groups

isAnyHardgoodShippingGroups

public boolean isAnyHardgoodShippingGroups(Order pOrder)
Returns true if the order has at least one hargood shipping group with commerce item relationships. Both non-gift and gift shipping groups are considered.

Parameters:
pOrder - the order to use.
Returns:
boolean true if the order has at least one non-empty hardgood shipping group.

isAnyElectronicShippingGroups

public boolean isAnyElectronicShippingGroups(Order pOrder)
Returns true if the order has at least one electronic shipping group with commerce item relationships

Parameters:
pOrder - the order to use.
Returns:
boolean true if the order has at least one non-empty electronic shipping group.

isMultipleNonGiftHardgoodShippingGroups

public boolean isMultipleNonGiftHardgoodShippingGroups(Order pOrder)
Returns true if the order has more than one non-gift hardgood shipping group with commerce item relationships

Parameters:
pOrder - the order to use.
Returns:
boolean true if the order has more than one non-gift hardgood shipping group.

isMultipleHardgoodShippingGroupsWithRelationships

public boolean isMultipleHardgoodShippingGroupsWithRelationships(Order pOrder)
Returns true if the order has more than one hardgood shipping group with commerce item relationships

Returns:
boolean true if the order has more than one hardgood shipping group.

isAnyNonGiftHardgoodShippingGroups

public boolean isAnyNonGiftHardgoodShippingGroups(Order pOrder)
Determines if there are any non-gift hardgood shipping groups with relationships

Parameters:
pOrder - the order to use.
Returns:
true if any non-gift hardgood shipping groups with relationships are found

getNonGiftHardgoodShippingGroups

public java.util.List getNonGiftHardgoodShippingGroups(Order pOrder)
Returns the non-gift hardgood shipping groups with commerce item relationships

Parameters:
pOrder - the order to use.

getFirstNonGiftHardgoodShippingGroupWithRels

public HardgoodShippingGroup getFirstNonGiftHardgoodShippingGroupWithRels(Order pOrder)
Returns the first non-gift hardgood shipping group with relationships from the order

Parameters:
pOrder - the order to use.
Returns:
the first non-gift hardgood shipping group or null if there isn't one.

getFirstNonGiftHardgoodShippingGroup

public HardgoodShippingGroup getFirstNonGiftHardgoodShippingGroup(Order pOrder)
Returns the first non-gift hardgood shipping group from the order

Parameters:
pOrder - the order to use.
Returns:
the first non-gift hardgood shipping group or null if there isn't one.

getHardgoodShippingGroups

public java.util.List getHardgoodShippingGroups(Order pOrder)
Returns all the hardgood shipping groups with commerce item relationships

Parameters:
pOrder - the order to use.

getElectronicShippingGroups

public java.util.List getElectronicShippingGroups(Order pOrder)
Returns all the electronic shipping groups with commerce item relationships

Parameters:
pOrder - the order to use.

isMultipleNonGiftHardgoodItems

public boolean isMultipleNonGiftHardgoodItems(Order pOrder)
Determines if the total quantity of all non-gift hardgood items is more than one.

Parameters:
pOrder - the order to use.
Returns:
true if the the non-gift hg item quantity is more than one.

createShippingGroup

public ShippingGroup createShippingGroup()
                                  throws CommerceException
Creates a new ShippingGroup object using the type mapped to the defaultShippingGroupType property in OrderTools. Populates the ShippingGroup with the priceInfo object using the default ShippingPriceInfo class as defined in the OrderTools nucleus component.

Returns:
the ShippingGroup object which was created
Throws:
ObjectCreationException - if the instantiation of an object fails
InvalidParameterException - thrown if any of the parameters are null
CommerceException
See Also:
OrderTools.getDefaultShippingGroupType()

createShippingGroup

public ShippingGroup createShippingGroup(java.lang.String pShippingGroupType)
                                  throws CommerceException
Creates a new ShippingGroup object using the type mapped to the type supplied in pShippingGroupType. Populates the ShippingGroup with the priceInfo object using the default ShippingPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pShippingGroupType - the type mapped to the object instance to use for the ShippingGroup
Returns:
the ShippingGroup object which was created
Throws:
ObjectCreationException - if the instantiation of an object fails
InvalidParameterException - thrown if any of the parameters are null
CommerceException

createShippingGroup

public ShippingGroup createShippingGroup(java.lang.String pShippingGroupType,
                                         ShippingPriceInfo pPriceInfo)
                                  throws CommerceException
Creates a new ShippingGroup object using the type mapped to the type supplied in pShippingGroupType. Populates the ShippingGroup with the supplied data.

Parameters:
pShippingGroupType - the type mapped to the object instance to use for the ShippingGroup
pPriceInfo - the ShippingPriceInfo object for this ShippingGroup
Returns:
the ShippingGroup object which was created
Throws:
ObjectCreationException - if the instantiation of an object fails
InvalidParameterException - thrown if any of the parameters are null
CommerceException

addShippingGroupToOrder

public void addShippingGroupToOrder(Order pOrder,
                                    ShippingGroup pShippingGroup)
                             throws CommerceException
Adds the given ShippingGroup to the given order.

Parameters:
pOrder - the Order to add the ShippingGroup to
pShippingGroup - the ShippingGroup to add to the Order
Throws:
InvalidParameterException - thrown if any of the parameters are null
CommerceException

removeAllShippingGroupsFromOrder

public void removeAllShippingGroupsFromOrder(Order pOrder)
                                      throws CommerceException
Removes all the ShippingGroups and their Relationships from an Order.

Parameters:
pOrder - the Order which contains the ShippingGroups to be removed
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - thrown if a ShippingGroup cannot be removed
CommerceException

removeAllShippingGroupsFromOrder

public void removeAllShippingGroupsFromOrder(Order pOrder,
                                             java.util.List pExclusions)
                                      throws CommerceException
Removes ShippingGroups and their Relationships from an Order, retaining the ShippingGroups passed in via the exclusion list parameter.

Parameters:
pOrder - the Order which contains the ShippingGroups to be removed
pExclusions - the ShippingGroups to be retained (can be null or an empty list)
Throws:
InvalidParameterException - thrown if any required parameter is null
ObjectRemovalException - thrown if a ShippingGroup cannot be removed
CommerceException

removeShippingGroupFromOrder

public void removeShippingGroupFromOrder(Order pOrder,
                                         java.lang.String pShippingGroupId)
                                  throws CommerceException
Removes the given ShippingGroup from the given order. This method will also remove relationships and HandlingInstructions which reference the ShippingGroup. Also if there is only one ShippingGroup, it will check for any HandlingInstructions in that ShippingGroup.

Parameters:
pOrder - the Order to remove the ShippingGroup from
pShippingGroupId - the id of the ShippingGroup to remove from the Order
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - thrown if the ShippingGroup contains any relationships
CommerceException

removeAllRelationshipsFromShippingGroup

public void removeAllRelationshipsFromShippingGroup(Order pOrder,
                                                    java.lang.String pShippingGroupId)
                                             throws CommerceException
Removes all the relationships from the ShippingGroup with the given id in the given order. Also implicitly removes all the HandlingInstructions in the given ShippingGroup.

Parameters:
pOrder - the Order which contains the CommerceItem to remove the relationships from
pShippingGroupId - the id of the ShippingGroup
Throws:
InvalidParameterException - thrown if any of the parameters are null
ShippingGroupNotFoundException - if a ShippingGroup with the given id is not found in the given order
ObjectRemovalException - thrown if a relationship cannot be removed
CommerceException

getAllShippingGroupRelationships

public java.util.List getAllShippingGroupRelationships(Order pOrder)
                                                throws CommerceException
Provides a List of all ShippingGroupRelationships associated with the given Order. This could include PaymentGroupShippingGroupRelationships or ShippingGroupCommerceItemRelationships.

Parameters:
pOrder - the Order whose relationships are sought
Returns:
a List of ShippingGroupRelationships in the Order
Throws:
InvalidParameterException - thrown if order parameter is null
CommerceException
See Also:
Relationship, ShippingGroupRelationship, ShippingGroupCommerceItemRelationship, PaymentGroupShippingGroupRelationship

addShippingCostAmountToPaymentGroup

public void addShippingCostAmountToPaymentGroup(Order pOrder,
                                                java.lang.String pShippingGroupId,
                                                java.lang.String pPaymentGroupId,
                                                double pAmount)
                                         throws CommerceException
Adds the given amount of the ShippingGroup's cost with the given id to the PaymentGroup with the given id. Underneath the surface, this method creates a PaymentGroupShippingGroupRelationship with type SHIPPINGAMOUNT and sets the PaymentGroup, ShippingGroup, and amount properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the PaymentGroup and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup's cost to add
pPaymentGroupId - the id of the PaymentGroup which the ShippingGroup's cost will be added to
pAmount - the amount that is assigned for payment to the PaymentGroup
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a PaymentGroup or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
PaymentGroupShippingGroupRelationship

addRemainingShippingCostToPaymentGroup

public void addRemainingShippingCostToPaymentGroup(Order pOrder,
                                                   java.lang.String pShippingGroupId,
                                                   java.lang.String pPaymentGroupId)
                                            throws CommerceException
Adds any unassigned amount of the ShippingGroup's cost with the given id to the PaymentGroup with the given id. Underneath the surface, this method creates a PaymentGroupShippingGroupRelationship with type SHIPPINGAMOUNTREMAINING and sets the PaymentGroup and ShippingGroup properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the PaymentGroup and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup's cost to add
pPaymentGroupId - the id of the PaymentGroup which the ShippingGroup's cost will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a PaymentGroup or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
PaymentGroupShippingGroupRelationship

removeShippingCostAmountFromPaymentGroup

public void removeShippingCostAmountFromPaymentGroup(Order pOrder,
                                                     java.lang.String pShippingGroupId,
                                                     java.lang.String pPaymentGroupId,
                                                     double pAmount)
                                              throws CommerceException
Removes the given amount of the ShippingGroup's cost with the given id from the PaymentGroup with the given id.

Parameters:
pOrder - the Order which the PaymentGroup and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup
pPaymentGroupId - the id of the PaymentGroup
pAmount - the amount to remove
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if the given Relationship is not found in the ShippingGroup or PaymentGroup
ObjectRemovalException - if the removal of the object fails
CommerceException

removeRemainingShippingCostFromPaymentGroup

public void removeRemainingShippingCostFromPaymentGroup(Order pOrder,
                                                        java.lang.String pShippingGroupId,
                                                        java.lang.String pPaymentGroupId)
                                                 throws CommerceException
Removes the "remaining" amount of the ShippingGroup with the given id from the PaymentGroup with the given id.

Parameters:
pOrder - the Order which the PaymentGroup and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup
pPaymentGroupId - the id of the PaymentGroup
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if the given relationship is not found in the PaymentGroup or ShippingGroup
ObjectRemovalException - if the removal of the object fails
CommerceException

splitShippingGroup

public java.util.List splitShippingGroup(Order pOrder,
                                         java.lang.String pShippingGroupId,
                                         java.lang.String[] pItemIds,
                                         long[] pQuantities)
                                  throws CommerceException
Moves a set of Items from a ShippingGroup to a new ShippingGroup. The new ShippingGroup has the same information as the original. The reason for this method is to allow the fulfillment engine to handle partial shipment of an Order. This method creates two new ShippingGroups and moves the items given in pItems to one ShippingGroup and the remaining items in the original ShippingGroup to the other ShippingGroup. The original ShippingGroup, pShippingGroup, is removed from the Order and no longer valid. Note that the ShippingPriceInfo from the original ShippingGroup is moved to the new ShippingGroup which contains the items whose ids were supplied in pItemIds and the other new ShippingGroup contains a ShippingPriceInfo whose value is 0.

Parameters:
pOrder - the Order which the ShippingGroup and CommerceItems exist in
pShippingGroupId - the id of the ShippingGroup which contains the CommerceItems in pItems which are to be moved to a new ShippingGroup
pItemIds - the ids of the CommerceItems which are to be split into a new ShippingGroup. The length of the array must be equal to the number of ids supplied in the array and not greater, otherwise an exception will be thrown.
pQuantities - the quantities of the CommerceItems which are to be moved into the new ShippingGroup. This array is in parallel with pItems, so pQuantities[0] contains the quantity of the item at pItems[0] which should be moved to the new ShippingGroup. The length of this array must be the same as the length of pItemIds.
Returns:
a List of the two new ShippingGroups. The first ShippingGroup in the array contains the original ShippingGroup and the second ShippingGroup contains the specified quantities of the specified items the remaining items.
Throws:
InvalidParameterException - thrown if any of the parameters are null or invalid
ObjectCreationException - if during the process of splitting some object cannot be instantiated
InvalidTypeException - if an invalid type is found in a Relationship
CommerceException - if some unexpected event occurs

splitShippingGroup

public java.util.List splitShippingGroup(Order pOrder,
                                         java.lang.String pShippingGroupId,
                                         java.lang.String[] pItemIds)
                                  throws CommerceException
Moves a set of Items from a ShippingGroup to a new ShippingGroup. The new ShippingGroup has the same information as the original. The reason for this method is to allow the fulfillment subsystem to split items which are not serviced by the same fulfiller into a different shipping group.

Parameters:
pOrder - the Order which the ShippingGroup and CommerceItems exist in
pShippingGroupId - the id of the ShippingGroup which contains the CommerceItems in pItems which are to be moved to a new ShippingGroup
pItemIds - the ids of the CommerceItems which are to be split into a new ShippingGroup. The length of the array must be equal to the number of ids supplied in the array and not greater, otherwise an exception will be thrown.
Returns:
a List of the two new ShippingGroups. The first ShippingGroup in the array contains the original ShippingGroup and the second ShippingGroup contains the specified quantities of the specified items the remaining items.
Throws:
CommerceException

splitShippingGroupWithImplicitRelationships

protected java.util.List splitShippingGroupWithImplicitRelationships(Order pOrder,
                                                                     ShippingGroup pShippingGroup,
                                                                     java.lang.String[] pItemIds,
                                                                     long[] pQuantities)
                                                              throws CommerceException
This method is called by splitShippingGroup(). Moves a set of Items from a ShippingGroup to a new ShippingGroup which has no Relationships to the supplied items. This is called by splitShippingGroup in the special case when there is only onr ShippingGroup which has implicit Relationships to all the Items in the Order. The new ShippingGroup has the same information as the original. The reason for this method is to allow the fulfillment engine to handle partial shipment of an Order. This method creates two new ShippingGroups and moves the items given in pItems to one ShippingGroup and the remaining items in the original ShippingGroup to the other ShippingGroup. The original ShippingGroup, pShippingGroup, is removed from the Order and no longer valid. Note that the ShippingPriceInfo from the original ShippingGroup is moved to the new ShippingGroup which contains the items whose ids were supplied in pItemIds and the other new ShippingGroup contains a ShippingPriceInfo whose value is 0.

Parameters:
pOrder - the Order which the ShippingGroup and CommerceItems exist in
pShippingGroupId - the id of the ShippingGroup which contains the CommerceItems in pItems which are to be moved to a new ShippingGroup
pItemIds - the ids of the CommerceItems which are to be split into a new ShippingGroup. The length of the array must be equal to the number of ids supplied in the array and not greater, otherwise an exception will be thrown.
pQuantities - the quantities of the CommerceItems which are to be moved into the new ShippingGroup. This array is in parallel with pItems, so pQuantities[0] contains the quantity of the item at pItems[0] which should be moved to the new ShippingGroup. The length of this array must be the same as the length of pItemIds.
Returns:
a List of the two new ShippingGroups. The first ShippingGroup in the array contains the original ShippingGroup and the second ShippingGroup contains the specified quantities of the specified items the remaining items.
Throws:
InvalidParameterException - thrown if any of the parameters are null or invalid
ObjectCreationException - if during the process of splitting some object cannot be instantiated
InvalidTypeException - if an invalid type is found in a Relationship
CommerceException - if some unexpected event occurs

cloneShippingGroup

public ShippingGroup cloneShippingGroup(ShippingGroup pShippingGroup)
                                 throws CommerceException
Duplicate the specified shipping group by creating a new instance of the same class and copying selected properties from the old shipping group to the new one. The following properties are copied to the new shipping group:


copyShippingAddress

public void copyShippingAddress(ShippingGroup pFromShippingGroup,
                                ShippingGroupImpl pToShippingGroup)
                         throws CommerceException
Copy the address from one shipping group to another

Parameters:
pFromShippingGroup - the shipping group to copy from
pToShippingGroup - the shipping group to copy to
Throws:
CommerceException

copySpecialInstructions

public void copySpecialInstructions(ShippingGroup pFromShippingGroup,
                                    ShippingGroupImpl pToShippingGroup)
Copy the special instructions

Parameters:
pFromShippingGroup - the shipping group to copy from
pToShippingGroup - the shipping group to copy to

postCloneShippingGroup

protected void postCloneShippingGroup(ShippingGroup pOldGroup,
                                      ShippingGroup pNewGroup)
                               throws CommerceException
This method is called just before cloneShippingGroup returns a newly created shipping group. By default it does nothing. Subclasses of ShippingGroupManager can implement this method to add code that copies custom shipping group properties from the original shipping group to the new one.

Parameters:
pOldGroup - The shipping group being cloned.
pNewGroup - The newly created shipping group, whose initial property values will already have been set by cloneShippingGroup.
Throws:
CommerceException - if any error occurs during the post-clone operation

getRemainingQuantityForShippingGroup

public long getRemainingQuantityForShippingGroup(CommerceItem pItem)
Calculate the "quantity remaining" for a given item. Add up all the quantities in relationships of type SHIPPINGQUANTITY then subtract from the CommerceItem's quantity. This method assumes that ShippingGroupCommerceItemRelationships have been created between the CommerceItem and ShippingGroup.

Parameters:
pItem - The CommerceItem we are checking
Returns:
The quantity remaining.

getShippingGroupByDescription

public ShippingGroup getShippingGroupByDescription(java.util.List pShippingGroups,
                                                   java.lang.String pDescription)
                                            throws CommerceException
This method will return a ShippingGroup whose description is pDescription.

Parameters:
pShippingGroups - a List of ShippingGroups
pDescription - the description to search for in the List of ShippingGroups
Returns:
the ShippingGroup whose description is pDescription or null if it is not found
Throws:
InvalidParameterException - if any of the parameters are null
CommerceException

removeEmptyShippingGroups

public void removeEmptyShippingGroups(Order pOrder)
                               throws CommerceException
Removes all the ShippingGroups which have no CommerceItems. Having no CommerceItems means that the ShippingGroup has no CommerceItemRelationships. If the Order has only one ShippingGroup then it is not removed even though it may not have any CommerceItemRelationships.

Parameters:
pOrder - the Order which contains the ShippingGroups
Throws:
CommerceException - if an exception occurs while removing a ShippingGroup

getShippingGroupCommerceItemRelationship

public ShippingGroupCommerceItemRelationship getShippingGroupCommerceItemRelationship(Order pOrder,
                                                                                      java.lang.String pCommerceItemId,
                                                                                      java.lang.String pShippingGroupId)
                                                                               throws CommerceException
Returns the relationship object which exists between the given CommerceItem and ShippingGroup.

Parameters:
pCommerceItemId - the id of the CommerceItem which makes up a half of the relationship
pShippingGroupId - the id of the ShippingGroup which makes up a half of the relationship
Returns:
the ShippingGroupCommerceItemRelationship object that exists between these two objects
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if a relationship is not found
CommerceException

mergeOrdersCopyShippingGroup

protected ShippingGroup mergeOrdersCopyShippingGroup(Order pSrcOrder,
                                                     Order pDstOrder,
                                                     ShippingGroup pGroup)
                                              throws CommerceException
This method is used by OrderManager.mergeOrders to copy a shipping group from a source order to a destination order. Calls either mergeOrdersCopyHardgoodShippingGroup or mergeOrdersCopyElectronicShippingGroup depending on the shipping group type.

Applications that have extended shipping groups to add additional types not derived from HardgoodShippingGroup or ElectronicShippingGroup, or that have extended HardgoodShippingGroup or ElectronicShippingGroup to include additional data, should subclass ShippingGroupManager and override this method if any of that data must be preserved when merging orders.

Parameters:
pSrcOrder - The source order from which shipping groups are being copied.
pDstOrder - The destination order to which shipping groups are being copied.
pGroup - The shipping group currently being copied.
Returns:
A new ShippingGroup whose important properties have been set to the same values as in pGroup.
Throws:
CommerceException

mergeOrdersCopyHardgoodShippingGroup

protected HardgoodShippingGroup mergeOrdersCopyHardgoodShippingGroup(Order pSrcOrder,
                                                                     Order pDstOrder,
                                                                     HardgoodShippingGroup pGroup)
                                                              throws CommerceException
This method is used by mergeOrdersCopyShippingGroup to copy a hardgood shipping group from a source order to a destination order. It creates a new shipping group of the same type as an existing group, then copies the shipping address from the existing group to the new group.

Applications that have extended hardgood shipping group to include additional data should subclass ShippingGroupManager and override this method if any of that data must be preserved when merging orders.

Parameters:
pSrcOrder - The source order from which shipping groups are being copied.
pDstOrder - The destination order to which shipping groups are being copied.
pGroup - The shipping group currently being copied.
Returns:
A new HardgoodShippingGroup whose shipping address has been set to the same value as in pGroup.
Throws:
CommerceException

mergeOrdersCopyElectronicShippingGroup

protected ElectronicShippingGroup mergeOrdersCopyElectronicShippingGroup(Order pSrcOrder,
                                                                         Order pDstOrder,
                                                                         ElectronicShippingGroup pGroup)
                                                                  throws CommerceException
This method is used by mergeOrdersCopyShippingGroup to copy an electronic shipping group from a source order to a destination order. It creates a new shipping group of the same type as an existing group, then copies the email address from the existing group to the new group.

Applications that have extended electronic shipping group to include additional data should subclass ShippingGroupManager and override this method if any of that data must be preserved when merging orders.

Parameters:
pSrcOrder - The source order from which shipping groups are being copied.
pDstOrder - The destination order to which shipping groups are being copied.
pGroup - The shipping group currently being copied.
Returns:
A new ElectronicShippingGroup whose email address has been set to the same value as in pGroup.
Throws:
CommerceException

isNullAddress

protected boolean isNullAddress(Address pAddress)
Query whether an Address object is null or empty.

Returns:
true if the address object is null or if every property in the address is null, false otherwise.

shippingGroupIsModifiable

public boolean shippingGroupIsModifiable(ShippingGroup pShippingGroup)
This method determines whether the shipping group is in a condusive to editing state

Parameters:
pShippingGroup - the shipping group
Returns:
whether the group is editable
Throws:
CommerceException, - if the order or the shipping group id are bogus

getNonModifiableShippingGroups

public java.util.List getNonModifiableShippingGroups(Order pOrder)
This method determines whether the shipping group is in a condusive to editing state

Parameters:
pShippingGroup - the shipping group
Returns:
whether the group is editable
Throws:
CommerceException, - if the order or the shipping group id are bogus

getShippingGroupName

public java.lang.String getShippingGroupName(ShippingGroup pShippingGroup,
                                             ShippingGroupMapContainer pShippingGroupMapContainer,
                                             java.util.Collection pShippingGroupMatchers)
Deprecated. 

Returns the name that the shipping group is mapped to in the map.


getNewShippingGroupName

public java.lang.String getNewShippingGroupName(ShippingGroup pShippingGroup,
                                                java.util.Collection pShippingGroupMatchers)
Deprecated. - This method is moved to ShippingGroupMapContainerService

Returns a new name for a shipping group

Parameters:
pShippingGroup -
pShippingGroupMatchers -
Returns:

isShippingGroupInOrder

public boolean isShippingGroupInOrder(Order pOrder,
                                      java.lang.String pShippingGroupId)
isShippingGroupInOrder is used to determine if the ShippingGroup is already in the Order.

Parameters:
pOrder - an Order value
pShippingGroupId - a String value
Returns:
a boolean value

addShippingGroupToMap

public java.lang.String addShippingGroupToMap(ShippingGroup pShippingGroup,
                                              ShippingGroupMapContainer pShippingGroupMapContainer,
                                              java.util.Collection pShippingGroupMatchers)
Deprecated. 

Adds a shipping group to the map container.

Parameters:
pShippingGroup -
Returns:
name used as the key in the map. If null then the shipping group is not added to the map.