atg.commerce.order
Class CommerceItemManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.CommerceItemManager
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 CommerceItemManager
extends GenericService

This class is the business layer object for managing and manipulating Orders. This class holds all the business logic for manipulating an Order.


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
CommerceItemManager()
          Constructs a CommerceItemManager object.
 
Method Summary
 CommerceItem addAsSeparateItemToOrder(Order pOrder, CommerceItem pItem)
          Adds the given item to the given order.
 CommerceItem addAsSeparateSubItemToConfigurableItem(ConfigurableCommerceItem pItem, SubSkuCommerceItem pSubItem)
          Adds the SubItem to the ConfigurableCommerceItem as a separate item.
 void addItemAmountToPaymentGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pPaymentGroupId, double pAmount)
          Adds the given amount of the CommerceItem with the given id to the PaymentGroup with the given id.
 void addItemQuantityToShippingGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId, long pQuantity)
          Adds the given quantity of the CommerceItem with the given id to the ShippingGroup with the given id.
 CommerceItem addItemToOrder(Order pOrder, CommerceItem pItem)
          Adds the given item to the given order.
 void addRemainingItemAmountToPaymentGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pPaymentGroupId)
          Adds any unassigned amount of the CommerceItem with the given id to the ShippingGroup with the given id.
 void addRemainingItemQuantityToShippingGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId)
          Adds any unassigned quantity of the CommerceItem with the given id to the ShippingGroup with the given id.
 CommerceItem addSubItemToConfigurableItem(ConfigurableCommerceItem pItem, SubSkuCommerceItem pSubItem)
          Adds a sub item to a configurable commerce item
protected  void conditionallyEnforceProductSkuRelationship(java.lang.String pCatalogId, java.lang.String pProductId, java.lang.Object pProductRef, java.lang.String pCatalogRefId, java.lang.Object pCatalogRef)
          If 'enforceProductSkuRelationship' is true, verify that the sku is actually one of the product's child skus.
protected  void copySubItems(ConfigurableCommerceItem pSrcItem, ConfigurableCommerceItem pDstItem)
          Deep copies all the sub items from the source ConfigurableCommerceItem to the destination ConfigurableCommerceItem.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, long pQuantity)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, long pQuantity, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.String pProductId, long pQuantity)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pCatalogRefId, java.lang.String pProductId, long pQuantity, java.lang.String pCatalogKey)
          Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType.
 CommerceItem createCommerceItem(java.lang.String pItemType, java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the CommerceItem type defined in the pItemType.
 CommerceItem createCommerceItem(java.lang.String pItemType, java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity, java.lang.String pCatalogKey, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the CommerceItem type defined in the pItemType.
 CommerceItem createCommerceItem(java.lang.String pItemType, java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity, java.lang.String pCatalogKey, java.lang.String pCatalogId, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the CommerceItem type defined in the pItemType.
 CommerceItem createCommerceItem(java.lang.String pItemType, java.lang.String pCatalogRefId, java.lang.Object pCatalogRef, java.lang.String pProductId, java.lang.Object pProductRef, long pQuantity, java.lang.String pCatalogKey, java.lang.String pCatalogId, java.lang.String pSiteId, ItemPriceInfo pPriceInfo)
          Creates a new CommerceItem object using the CommerceItem type defined in the pItemType.
 CommerceItem createCommerceItem(java.lang.String pItemType, java.lang.String pCatalogRefId, java.lang.String pProductId, long pQuantity)
          Creates a new CommerceItem object using the supplied CommerceItem type.
 CommerceItem findMatchingItem(Order pOrder, CommerceItem pItem)
          Method to try and find a commerce item in the given order that matches the given item.
 void generateRangeForItem(CommerceItem pItem)
          For each ShippingGroupCommerceItemRelationship in the order, update the Range
 void generateRangesForOrder(Order pOrder)
          For each ShippingGroupCommerceItemRelationship in the order, update the Range
 java.util.List getAllCommerceItemRelationships(Order pOrder)
          Provides a List of all CommerceItemRelationships associated with the given Order.
 java.util.List getCommerceItemsFromPaymentGroup(PaymentGroup pPaymentGroup)
          Returns a List of all the CommerceItems within the given PaymentGroup.
 java.util.List getCommerceItemsFromShippingGroup(ShippingGroup pShippingGroup)
          Returns a List of all the CommerceItems within the given ShippingGroup.
 HandlingInstructionManager getHandlingInstructionManager()
          Returns property handlingInstructionManager
 OrderTools getOrderTools()
          Returns property orderTools
 PaymentGroupManager getPaymentGroupManager()
          Returns property paymentGroupManager
 java.lang.Object getProduct(java.lang.String pProductId, java.lang.String pCatalogKey)
          Get the Product object corresponding to the specified ID and (optional) catalog.
protected  java.lang.String getProductDisplayName(java.lang.Object pProduct)
          Return the display name of a product to use when constructing user visible error messages about it, or a string indicating that the product's display name could not be found.
 java.lang.String getProductDisplayNamePropertyName()
          Return the name of the product property that holds the display name for that product.
 java.lang.String getProductIdFromSkuId(java.lang.String pSKUId)
          Returns a Product ID for a given SKU, if one is found.
 java.util.Collection getProductSkus(java.lang.Object pProduct)
          Get a collection of SKU items from the specified product object
 java.lang.String getProductSkusPropertyName()
          Return the name of the product property that holds the list of skus associated with that product.
 java.lang.String getProfilesCatalogPropertyName()
          The name of the property in the profile that stores the catalog
 ShippingGroupManager getShippingGroupManager()
          Returns property shippingGroupManager
 SiteGroupManager getSiteGroupManager()
          Returns property siteGroupManager
 java.lang.Object getSku(java.lang.String pCatalogRefId, java.lang.String pCatalogKey)
          Get the SKU object corresponding to the specified ID and (optional) catalog.
protected  java.lang.String getSkuDisplayName(java.lang.Object pSku)
          Return the display name of a sku to use when constructing user visible error messages about it, or a string indicating that the sku's display name could not be found.
 java.lang.String getSkuDisplayNamePropertyName()
          Return the name of the sku property that holds the display name for the sku.
 long getUnassignedQuantityForCommerceItem(CommerceItem pItem)
          This method returns the unassigned quantity for a CommerceItem.
 boolean isEnforceProductSkuRelationship()
          Return true if the createCommerceItem methods should verify that the product (if any) and sku being used to construct the commerce item are related -- i.e., that the sku is one of the product's child skus.
protected  CommerceItem mergeOrdersCopyCommerceItem(Order pSrcOrder, Order pDstOrder, CommerceItem pItem)
          This method is used by OrderManager.mergeOrders to copy a commerce item from a source order to a destination order.
 boolean productContainsSku(java.lang.Object pProduct, java.lang.String pSkuId)
          Verify that a specified sku ID is an ID of a child sku of the specified product.
protected  boolean productContainsSku(java.lang.String pCatalogId, java.lang.String pProductId, java.lang.Object pProduct, java.lang.String pSkuId, java.lang.Object pSku)
          Verify that a specified sku is actually a child sku of the specified product during creation of a commerce item.
 void removeAllCommerceItemsFromOrder(Order pOrder)
          Removes all the CommerceItems and their Relationships from an Order.
 void removeAllRelationshipsFromCommerceItem(Order pOrder, java.lang.String pCommerceItemId)
          Removes all the relationships from the CommerceItem with the given id in the given order.
 void removeAllSubItemsFromConfigurableItem(ConfigurableCommerceItem pItem)
          Removes all the SubItems from the ConfigurableCommerceItem.
 void removeItemAmountFromPaymentGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pPaymentGroupId, double pAmount)
          Removes the given amount of the CommerceItem with the given id from the PaymentGroup with the given id.
 void removeItemFromOrder(Order pOrder, java.lang.String pCommerceItemId)
          Removes the given item from the given order.
 void removeItemQuantityFromShippingGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId, long pQuantity)
          Removes the given quantity of the CommerceItem with the given id from the ShippingGroup with the given id.
 void removeRemainingItemAmountFromPaymentGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pPaymentGroupId)
          Removes the "remaining" amount of the CommerceItem with the given id from the PaymentGroup with the given id.
 void removeRemainingItemQuantityFromShippingGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId)
          Removes the "remaining" quantity of the CommerceItem with the given id from the ShippingGroup with the given id.
 void removeSubItemFromConfigurableItem(ConfigurableCommerceItem pItem, java.lang.String pSubItemId)
          Removes the SubItem with the given id from the ConfigurableCommerceItem.
 void returnCommerceItem(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId, long pQuantity)
          Marks a CommerceItem as returned in an Order.
 void setCommerceItemProductAndSku(CommerceItem pCommerceItem, java.lang.String pProductId, java.lang.String pSkuId)
          Change the Product and SKU to which the commerce item refers.
 java.lang.Object setCommerceItemSku(CommerceItem pCommerceItem, java.lang.String pSkuId)
          Change the SKU to which the commerce item refers.
 void setEnforceProductSkuRelationship(boolean pEnforceProductSkuRelationship)
          Specify whether the createCommerceItem methods should verify that the product (if any) and sku being used to construct the commerce item are related -- i.e., that the sku is one of the product's child skus.
 void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
          Sets property handlingInstructionManager
 void setOrderTools(OrderTools pOrderTools)
          Sets property orderTools
 void setPaymentGroupManager(PaymentGroupManager pPaymentGroupManager)
          Sets property paymentGroupManager
 void setProductDisplayNamePropertyName(java.lang.String pProductDisplayNamePropertyName)
          Specify the name of the product property that holds the display name for the product.
 void setProductSkusPropertyName(java.lang.String pProductSkusPropertyName)
          Specify the name of the product property that holds the list of skus associated with that product.
 void setProfilesCatalogPropertyName(java.lang.String pProfilesCatalogPropertyName)
           
 void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
          Sets property shippingGroupManager
 void setSiteGroupManager(SiteGroupManager pSiteGroupManager)
          Sets property siteGroupManager
 void setSkuDisplayNamePropertyName(java.lang.String pSkuDisplayNamePropertyName)
          Specify the name of the sku property that holds the display name for the sku.
protected  boolean shouldMergeItems(CommerceItem pExistingItem, CommerceItem pNewItem)
          Determine whether or not we should merge the quantity in one commerce item or subitem into the quantity in an already existing item or subitem, rather than adding the new item to the order as a separate line item or subitem.
protected  boolean shouldMergeItems(Order pOrder, CommerceItem pExistingItem, CommerceItem pNewItem)
          Determine whether or not we should merge the quantity in one commerce item into the quantity in an already existing item, rather than adding the new item to the order as a separate line item.
protected  boolean shouldMergeSubItems(ConfigurableCommerceItem pItem, CommerceItem pExistingSubItem, CommerceItem pNewSubItem)
          Determine whether or not we should merge the quantity in one commerce subitem into the quantity in an already existing sibitem, rather than adding the new subitem to the ConfigurableCommerceItem as a separate subitem.
protected  void updateOrderSite(Order pOrder, CommerceItem pItem)
          Update the order to indicate the site from which the most recent item addition occurred.
protected  void validateSiteCompatibility(java.lang.String pExistingSiteId, java.lang.String pNewSiteId)
          Determine whether a new item's site is compatible with other sites in an order.
 
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 java.lang.String CLASS_VERSION
Class version string


sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle

Constructor Detail

CommerceItemManager

public CommerceItemManager()
Constructs a CommerceItemManager object.

Method Detail

setProfilesCatalogPropertyName

public void setProfilesCatalogPropertyName(java.lang.String pProfilesCatalogPropertyName)

getProfilesCatalogPropertyName

public java.lang.String getProfilesCatalogPropertyName()
The name of the property in the profile that stores the catalog


setProductSkusPropertyName

public void setProductSkusPropertyName(java.lang.String pProductSkusPropertyName)
Specify the name of the product property that holds the list of skus associated with that product. The default value is "childSKUs".


getProductSkusPropertyName

public java.lang.String getProductSkusPropertyName()
Return the name of the product property that holds the list of skus associated with that product.


setProductDisplayNamePropertyName

public void setProductDisplayNamePropertyName(java.lang.String pProductDisplayNamePropertyName)
Specify the name of the product property that holds the display name for the product. The default value is "displayName".


getProductDisplayNamePropertyName

public java.lang.String getProductDisplayNamePropertyName()
Return the name of the product property that holds the display name for that product.


setSkuDisplayNamePropertyName

public void setSkuDisplayNamePropertyName(java.lang.String pSkuDisplayNamePropertyName)
Specify the name of the sku property that holds the display name for the sku. The default value is "displayName".


getSkuDisplayNamePropertyName

public java.lang.String getSkuDisplayNamePropertyName()
Return the name of the sku property that holds the display name for the sku.


isEnforceProductSkuRelationship

public boolean isEnforceProductSkuRelationship()
Return true if the createCommerceItem methods should verify that the product (if any) and sku being used to construct the commerce item are related -- i.e., that the sku is one of the product's child skus. The default value is false, to preserve backward compatibility with pre-7.0 versions of the code.


setEnforceProductSkuRelationship

public void setEnforceProductSkuRelationship(boolean pEnforceProductSkuRelationship)
Specify whether the createCommerceItem methods should verify that the product (if any) and sku being used to construct the commerce item are related -- i.e., that the sku is one of the product's child skus. If true, createCommerceItem will throw a CommerceException if passed a product and sku that are not related to each other.


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

getShippingGroupManager

public ShippingGroupManager getShippingGroupManager()
Returns property shippingGroupManager

Returns:
returns property shippingGroupManager

setShippingGroupManager

public void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
Sets property shippingGroupManager

Parameters:
pShippingGroupManager - the value to set for property shippingGroupManager

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

getSiteGroupManager

public SiteGroupManager getSiteGroupManager()
Returns property siteGroupManager

Returns:
returns property siteGroupManager

setSiteGroupManager

public void setSiteGroupManager(SiteGroupManager pSiteGroupManager)
Sets property siteGroupManager

Parameters:
pSiteGroupManager - the value to set for property siteGroupManager

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.String pProductId,
                                       long pQuantity)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data and priceInfo objects using the default ItemPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pQuantity - the quantity that this CommerceItem should represent
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pItemType,
                                       java.lang.String pCatalogRefId,
                                       java.lang.String pProductId,
                                       long pQuantity)
                                throws CommerceException
Creates a new CommerceItem object using the supplied CommerceItem type. Populates the CommerceItem with the supplied data and priceInfo objects using the default ItemPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pItemType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pQuantity - the quantity that this CommerceItem should represent
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.String pProductId,
                                       long pQuantity,
                                       java.lang.String pCatalogKey)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data and priceInfo objects using the default ItemPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pCatalogKey - the catalog key reference (locale) for this CommerceItem
pQuantity - the quantity that this CommerceItem should represent
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       long pQuantity)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data and priceInfo objects using the default ItemPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pQuantity - the quantity that this CommerceItem should represent
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data and priceInfo objects using the default ItemPriceInfo class as defined in the OrderTools nucleus component.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pQuantity - the quantity that this CommerceItem should represent
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       long pQuantity,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pQuantity - the quantity that this CommerceItem should represent
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the default CommerceItem type defined in the OrderTools property defaultCommerceItemType. Populates the CommerceItem with the supplied data.

Parameters:
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pQuantity - the quantity that this CommerceItem should represent
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pItemType,
                                       java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the CommerceItem type defined in the pItemType. Populates the CommerceItem with the supplied data.

Parameters:
pItemType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pQuantity - the quantity that this CommerceItem should represent
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pItemType,
                                       java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity,
                                       java.lang.String pCatalogKey,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the CommerceItem type defined in the pItemType. Populates the CommerceItem with the supplied data.

Parameters:
pItemType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pCatalogKey - the catalog key reference (locale) for this CommerceItem
pQuantity - the quantity that this CommerceItem should represent
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pItemType,
                                       java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity,
                                       java.lang.String pCatalogKey,
                                       java.lang.String pCatalogId,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the CommerceItem type defined in the pItemType. Populates the CommerceItem with the supplied data.

Parameters:
pItemType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pQuantity - the quantity that this CommerceItem should represent
pCatalogKey - the catalog key reference (locale) for this CommerceItem
pCatalogId - the id of the catalog repository item that this item is in
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

createCommerceItem

public CommerceItem createCommerceItem(java.lang.String pItemType,
                                       java.lang.String pCatalogRefId,
                                       java.lang.Object pCatalogRef,
                                       java.lang.String pProductId,
                                       java.lang.Object pProductRef,
                                       long pQuantity,
                                       java.lang.String pCatalogKey,
                                       java.lang.String pCatalogId,
                                       java.lang.String pSiteId,
                                       ItemPriceInfo pPriceInfo)
                                throws CommerceException
Creates a new CommerceItem object using the CommerceItem type defined in the pItemType. Populates the CommerceItem with the supplied data.

Parameters:
pItemType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pQuantity - the quantity that this CommerceItem should represent
pCatalogKey - the catalog key reference (locale) for this CommerceItem
pCatalogId - the id of the catalog repository item that this item is in
pSiteId - the id of the site that this item is associated with
pPriceInfo - the ItemPriceInfo object for this CommerceItem
Returns:
the CommerceItem 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.getDefaultCommerceItemType()

setCommerceItemSku

public java.lang.Object setCommerceItemSku(CommerceItem pCommerceItem,
                                           java.lang.String pSkuId)
                                    throws CommerceException
Change the SKU to which the commerce item refers. Calls conditionallyEnforceProductSkuRelationship with the new SKU.

Parameters:
pCommerceItem - the commerce item
pSkuId - the ID of the new
Returns:
the new SKU object
Throws:
CommerceException

setCommerceItemProductAndSku

public void setCommerceItemProductAndSku(CommerceItem pCommerceItem,
                                         java.lang.String pProductId,
                                         java.lang.String pSkuId)
                                  throws CommerceException
Change the Product and SKU to which the commerce item refers. Calls setCommerceItemSku with the new SKU.

Parameters:
pCommerceItem - the commerce item
pProductId - the ID of the new product
pSkuId - the ID of the new SKU
Throws:
CommerceException

getSku

public java.lang.Object getSku(java.lang.String pCatalogRefId,
                               java.lang.String pCatalogKey)
                        throws RepositoryException
Get the SKU object corresponding to the specified ID and (optional) catalog.

Parameters:
pCatalogRefId - the SKU ID
pCatalogKey - the catalog key or null
Returns:
the SKU object or null
Throws:
RepositoryException

getProduct

public java.lang.Object getProduct(java.lang.String pProductId,
                                   java.lang.String pCatalogKey)
                            throws RepositoryException
Get the Product object corresponding to the specified ID and (optional) catalog.

Parameters:
pProductId - the Product ID
pCatalogKey - the catalog key or null
Returns:
the Product object or null
Throws:
RepositoryException

addItemToOrder

public CommerceItem addItemToOrder(Order pOrder,
                                   CommerceItem pItem)
                            throws CommerceException
Adds the given item to the given order. By default this method will check for a duplicate item in the order and if one is found, will add the quantity in pItem to the one which already exists in the Order. Otherwise it will add the given CommerceItem to the order.

Parameters:
pOrder - the Order to add the CommerceItem to
pItem - the CommerceItem to add to the Order
Returns:
the CommerceItem which contains the item just added. If the item did not exist pItem is returned. If it did, then the item which already existed in the order is returned
Throws:
InvalidParameterException - thrown if any of the parameters are null
atg.commerce.IncompatibleSitesException - thrown if the sites for the new item and the order's old items can not share the cart
CommerceException - thrown if a CommerceItem is added and a DuplicateCommerceItemException is caught. This is an internal error and will get thrown only if the id of the CommerceItem being added already exists in the order. This should not happen under normal circumstances.

findMatchingItem

public CommerceItem findMatchingItem(Order pOrder,
                                     CommerceItem pItem)
                              throws CommerceException
Method to try and find a commerce item in the given order that matches the given item.

Note, it uses the logic in the shouldMergeItems() method to check for a match. This check is typically based on the site and catalogRefId matching and does not expect the commerce item id to match.

Parameters:
pOrder - Order to check
pItem - CommerceItem to match
Returns:
CommerceItem that matches or null if no match found
Throws:
CommerceException
See Also:
shouldMergeItems(Order, CommerceItem, CommerceItem)

conditionallyEnforceProductSkuRelationship

protected void conditionallyEnforceProductSkuRelationship(java.lang.String pCatalogId,
                                                          java.lang.String pProductId,
                                                          java.lang.Object pProductRef,
                                                          java.lang.String pCatalogRefId,
                                                          java.lang.Object pCatalogRef)
                                                   throws CommerceException
If 'enforceProductSkuRelationship' is true, verify that the sku is actually one of the product's child skus. The actual SKU membership in product test is delegated to another method so subclasses can easily override the business logic if necessary.

Parameters:
pCatalogId - the id of the catalog repository item that this item is in
pProductId - the product id that this CommerceItem references
pProductRef - the product object reference that this CommerceItem represents
pCatalogRefId - the id of the catalog object reference that this CommerceItem represents
pCatalogRef - the catalog object reference that this CommerceItem represents
Throws:
CommerceException - if enforceProductSkuRelationship is true and SKU is not valid for product

shouldMergeItems

protected boolean shouldMergeItems(Order pOrder,
                                   CommerceItem pExistingItem,
                                   CommerceItem pNewItem)
Determine whether or not we should merge the quantity in one commerce item into the quantity in an already existing item, rather than adding the new item to the order as a separate line item. The assumption is that the items' catalogRefIds are already known to be the same. By default we merge items if their product IDs and site IDs are equal. Subclasses can override this method or shouldMergeItems(pExistingItem, pNewItem) to alter the logic used to decide when to merge two commerce items in an order.

Parameters:
pOrder - The order to which pNewItem is being added. This is not used by the default implementation but is provided in case subclasses need it to implement alternative item-merging logic.
pExistingItem - An item already in the cart
pNewItem - The item being added to the cart
Returns:
true if pExistingItem and pNewItem should be merged in the cart
See Also:
shouldMergeItems(CommerceItem, CommerceItem)

shouldMergeItems

protected boolean shouldMergeItems(CommerceItem pExistingItem,
                                   CommerceItem pNewItem)
Determine whether or not we should merge the quantity in one commerce item or subitem into the quantity in an already existing item or subitem, rather than adding the new item to the order as a separate line item or subitem. The assumption is that the items' catalogRefIds are already known to be the same. By default we merge items if their product IDs and site IDs are equal. Subclasses can override this method to alter the logic used to decide when to merge two commerce items in an order or subitems in a commerce item.

Parameters:
pExistingItem - An item already in the cart
pNewItem - The item being added to the cart
Returns:
true if pExistingItem and pNewItem should be merged

validateSiteCompatibility

protected void validateSiteCompatibility(java.lang.String pExistingSiteId,
                                         java.lang.String pNewSiteId)
                                  throws CommerceException
Determine whether a new item's site is compatible with other sites in an order. Compatibility is defined by the site groups that have been defined for the ShoppingCartShareableType. We make sure the new item's site and another site from the order belong to the same site group. If either site is null, the sites are compatible no matter what site groups have been established.

Parameters:
pExistingSiteId - The site ID already associated with the cart
pNewSiteId - The site ID for the item or subitem being added to the cart
Throws:
CommerceException - if the two sites can not share the cart

updateOrderSite

protected void updateOrderSite(Order pOrder,
                               CommerceItem pItem)
Update the order to indicate the site from which the most recent item addition occurred. Always copy an item's non-null siteId to the order's siteId property. If the item has a site and the order's creationSiteId is null, fill it in with the item's site.

Parameters:
pOrder - the Order being updated
pItem - the new or updated CommerceItem

addAsSeparateItemToOrder

public CommerceItem addAsSeparateItemToOrder(Order pOrder,
                                             CommerceItem pItem)
                                      throws CommerceException
Adds the given item to the given order. This method forces the given CommerceItem to be added to the Order and does not look for one with the same catalogRefId. The result of calling this method is that two or more separate CommerceItems with the same catalogRefId can exist in the Order.

Parameters:
pOrder - the Order to add the CommerceItem to
pItem - the CommerceItem to add to the Order
Returns:
the CommerceItem added to the Order, in this case it will be pItem
Throws:
InvalidParameterException - thrown if any of the parameters are null
atg.commerce.IncompatibleSitesException - thrown if the sites for the new item and the order's old items can not share the cart
CommerceException - thrown if a CommerceItem is added and a DuplicateCommerceItemException is caught. This is an internal error and will get thrown only if the id of the CommerceItem being added already exists in the order. This should not happen under normal circumstances.

removeAllCommerceItemsFromOrder

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

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

removeItemFromOrder

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

Parameters:
pOrder - the Order to remove the CommerceItem fom
pCommerceItemId - the id of the CommerceItem to remove from the Order
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - thrown if the CommerceItem cannot be removed
CommerceException

removeAllRelationshipsFromCommerceItem

public void removeAllRelationshipsFromCommerceItem(Order pOrder,
                                                   java.lang.String pCommerceItemId)
                                            throws CommerceException
Removes all the relationships from the CommerceItem with the given id in the given order. Also removes any HandlingInstructions which reference this CommerceItem.

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

getAllCommerceItemRelationships

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

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

getCommerceItemsFromShippingGroup

public java.util.List getCommerceItemsFromShippingGroup(ShippingGroup pShippingGroup)
                                                 throws CommerceException
Returns a List of all the CommerceItems within the given ShippingGroup.

Parameters:
pShippingGroup - the ShippingGroup to retrieve the CommerceItems from
Returns:
a List of CommerceItems which are in the given ShippingGroup
Throws:
InvalidParameterException - thrown if any of the parameters are null
CommerceException

getCommerceItemsFromPaymentGroup

public java.util.List getCommerceItemsFromPaymentGroup(PaymentGroup pPaymentGroup)
                                                throws CommerceException
Returns a List of all the CommerceItems within the given PaymentGroup.

Parameters:
pPaymentGroup - the PaymentGroup to retrieve the CommerceItems from
Returns:
a List of CommerceItems which are in the given PaymentGroup
Throws:
InvalidParameterException - thrown if any of the parameters are null
CommerceException

getUnassignedQuantityForCommerceItem

public long getUnassignedQuantityForCommerceItem(CommerceItem pItem)
This method returns the unassigned quantity for a CommerceItem. If a CommerceItem contains a ShippingGroupRelationship with type ShippingRemaining, then the unassigned quantity will always be 0. To determine the remaining quantity call getRemainingQuantityForShippingGroup(CommerceItem). This method assumes that ShippingGroupCommerceItemRelationships have been created between the CommerceItem and ShippingGroup.

Parameters:
pItem - the CommerceItem we are checking
Returns:
the unassigned quantity.
See Also:
ShippingGroupManager.getRemainingQuantityForShippingGroup(CommerceItem)

addItemAmountToPaymentGroup

public void addItemAmountToPaymentGroup(Order pOrder,
                                        java.lang.String pCommerceItemId,
                                        java.lang.String pPaymentGroupId,
                                        double pAmount)
                                 throws CommerceException
Adds the given amount of the CommerceItem with the given id to the PaymentGroup with the given id. Underneath the surface, this method creates a PaymentGroupCommerceItemRelationship with type PAYMENTQUANTITY and sets the PaymentGroup, CommerceItem, and quantity 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 CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to add
pPaymentGroupId - the id of the PaymentGroup which the CommerceItem will be added to
pAmount - the amount of the CommerceItem which will be added
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:
PaymentGroupCommerceItemRelationship

addRemainingItemAmountToPaymentGroup

public void addRemainingItemAmountToPaymentGroup(Order pOrder,
                                                 java.lang.String pCommerceItemId,
                                                 java.lang.String pPaymentGroupId)
                                          throws CommerceException
Adds any unassigned amount of the CommerceItem with the given id to the ShippingGroup with the given id. Underneath the surface, this method creates a PaymentGroupCommerceItemRelationship with type PAYMENTAMOUNTREMAINING and sets the PaymentGroup and CommerceItem 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 CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to add
pPaymentGroupId - the id of the PaymentGroup which the CommerceItem 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:
ShippingGroupCommerceItemRelationship

addItemQuantityToShippingGroup

public void addItemQuantityToShippingGroup(Order pOrder,
                                           java.lang.String pCommerceItemId,
                                           java.lang.String pShippingGroupId,
                                           long pQuantity)
                                    throws CommerceException
Adds the given quantity of the CommerceItem with the given id to the ShippingGroup with the given id. Underneath the surface, this method creates a ShippingGroupCommerceItemRelationship with type SHIPPINGQUANTITY and sets the ShippingGroup, CommerceItem, and quantity 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 CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to add
pShippingGroupId - the id of the ShippingGroup which the CommerceItem will be added to
pQuantity - the quantity of the CommerceItem which will be added
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:
ShippingGroupCommerceItemRelationship

addRemainingItemQuantityToShippingGroup

public void addRemainingItemQuantityToShippingGroup(Order pOrder,
                                                    java.lang.String pCommerceItemId,
                                                    java.lang.String pShippingGroupId)
                                             throws CommerceException
Adds any unassigned quantity of the CommerceItem with the given id to the ShippingGroup with the given id. Underneath the surface, this method creates a ShippingGroupCommerceItemRelationship with type SHIPPINGQUANTITYREMAINING and sets the ShippingGroup and CommerceItem 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 CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to add
pShippingGroupId - the id of the ShippingGroup which the CommerceItem 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 ShippingGroup or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
ShippingGroupCommerceItemRelationship

removeItemQuantityFromShippingGroup

public void removeItemQuantityFromShippingGroup(Order pOrder,
                                                java.lang.String pCommerceItemId,
                                                java.lang.String pShippingGroupId,
                                                long pQuantity)
                                         throws CommerceException
Removes the given quantity of the CommerceItem with the given id from the ShippingGroup with the given id.

Parameters:
pOrder - the Order which the CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to to remove from the ShippingGroup
pShippingGroupId - the id of the ShippingGroup which the CommerceItem will be removed from
pQuantity - the quantity of the CommerceItem which will be removed
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - if the removal of the quantity fails
CommerceException

removeRemainingItemQuantityFromShippingGroup

public void removeRemainingItemQuantityFromShippingGroup(Order pOrder,
                                                         java.lang.String pCommerceItemId,
                                                         java.lang.String pShippingGroupId)
                                                  throws CommerceException
Removes the "remaining" quantity of the CommerceItem with the given id from the ShippingGroup with the given id.

Parameters:
pOrder - the Order which the CommerceItem and ShippingGroup exist
pCommerceItemId - the id of the CommerceItem to to remove from the ShippingGroup
pShippingGroupId - the id of the ShippingGroup which the CommerceItem will be removed from
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
CommerceItemNotFoundException - if a CommerceItem with the given id is not found in the given order
ObjectRemovalException - if the removal of the object fails
CommerceException

removeItemAmountFromPaymentGroup

public void removeItemAmountFromPaymentGroup(Order pOrder,
                                             java.lang.String pCommerceItemId,
                                             java.lang.String pPaymentGroupId,
                                             double pAmount)
                                      throws CommerceException
Removes the given amount of the CommerceItem with the given id from the PaymentGroup with the given id.

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

removeRemainingItemAmountFromPaymentGroup

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

Parameters:
pOrder - the Order which the CommerceItem and PaymentGroup exist
pCommerceItemId - the id of the CommerceItem
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 CommerceItem
ObjectRemovalException - if the removal of the object fails
CommerceException

addSubItemToConfigurableItem

public CommerceItem addSubItemToConfigurableItem(ConfigurableCommerceItem pItem,
                                                 SubSkuCommerceItem pSubItem)
                                          throws CommerceException
Adds a sub item to a configurable commerce item

Parameters:
pItem - the ConfigurableCommerceItem to add the sub item to
pSubItem - the SubSkuCommerceItem to add to the ConfigurableCommerceItem
Returns:
the sub item that was added to the ConfigurableCommerceItem
Throws:
InvalidParameterException - thrown if any of the parameters are null
atg.commerce.IncompatibleSitesException - thrown if the sites for the new subitem and the configurable commerce item can not share the cart
CommerceException
See Also:
SubSkuCommerceItem, ConfigurableCommerceItem

shouldMergeSubItems

protected boolean shouldMergeSubItems(ConfigurableCommerceItem pItem,
                                      CommerceItem pExistingSubItem,
                                      CommerceItem pNewSubItem)
Determine whether or not we should merge the quantity in one commerce subitem into the quantity in an already existing sibitem, rather than adding the new subitem to the ConfigurableCommerceItem as a separate subitem. The assumption is that the subitems' catalogRefIds are already known to be the same. By default we merge items if their product IDs and site IDs are equal. Subclasses can override this method or shouldMergeItems(pExistingItem, pNewItem) to alter the logic used to decide when to merge two subitems in a commerce item.

Parameters:
pItem - The configurable item to which pNewSubItem is being added. This is not used by the default implementation but is provided in case subclasses need it to implement alternative item-merging logic.
pExistingSubItem - A subitem already in the configurable item
pNewSubItem - The subitem being added to the configurable item
Returns:
true if pExistingSubItem and pNewSubItem should be merged in the configurable item

addAsSeparateSubItemToConfigurableItem

public CommerceItem addAsSeparateSubItemToConfigurableItem(ConfigurableCommerceItem pItem,
                                                           SubSkuCommerceItem pSubItem)
                                                    throws CommerceException
Adds the SubItem to the ConfigurableCommerceItem as a separate item.

Parameters:
pItem - the ConfigurableCommerceItem to add the sub item to
pSubItem - the SubSkuCommerceItem to add to the ConfigurableCommerceItem
Returns:
the sub item that was added to the ConfigurableCommerceItem
Throws:
InvalidParameterException - thrown if any of the parameters are null
atg.commerce.IncompatibleSitesException - thrown if the sites for the new subitem and the configurable commerce item can not share the cart
CommerceException
See Also:
SubSkuCommerceItem, ConfigurableCommerceItem

removeSubItemFromConfigurableItem

public void removeSubItemFromConfigurableItem(ConfigurableCommerceItem pItem,
                                              java.lang.String pSubItemId)
                                       throws CommerceException
Removes the SubItem with the given id from the ConfigurableCommerceItem.

Parameters:
pItem - the ConfigurableCommerceItem to remove the sub item from
pSubItemId - the SubSkuCommerceItem id to remove from the ConfigurableCommerceItem
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - if the removal of the object fails
CommerceException
See Also:
SubSkuCommerceItem, ConfigurableCommerceItem

removeAllSubItemsFromConfigurableItem

public void removeAllSubItemsFromConfigurableItem(ConfigurableCommerceItem pItem)
                                           throws CommerceException
Removes all the SubItems from the ConfigurableCommerceItem.

Parameters:
pItem - the ConfigurableCommerceItem to remove the SubSkuCommerceItems from
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - if the removal of the object fails
CommerceException
See Also:
SubSkuCommerceItem, ConfigurableCommerceItem

copySubItems

protected void copySubItems(ConfigurableCommerceItem pSrcItem,
                            ConfigurableCommerceItem pDstItem)
                     throws CommerceException
Deep copies all the sub items from the source ConfigurableCommerceItem to the destination ConfigurableCommerceItem.

Parameters:
pSrcItem - The source item to copy from.
pDstItem - The destination item to copy to.
Throws:
CommerceException - If the source or destination item parameters are null.

returnCommerceItem

public void returnCommerceItem(Order pOrder,
                               java.lang.String pCommerceItemId,
                               java.lang.String pShippingGroupId,
                               long pQuantity)
                        throws CommerceException
Marks a CommerceItem as returned in an Order. Marking it as returned sets the returnedQuantity in the ShippingGroupCommerceItemRelationship to pQuantity. It also reduces the quantity in the CommerceItem and the ShippingGroupCommerceItemRelationship by pQuantity.

Parameters:
pOrder - the Order which contains the CommerceItem to return
pCommerceItemId - the id of the CommerceItem to return
pShippingGroupId - the id of the ShippingGroup which contains the CommerceItem to return
pQuantity - the quantity of the CommerceItem to return. The quantity cannot be larger than the quantity in the ShippingGroupCommerceItemRelationship
Throws:
CommerceException - if an exception occurs while returning a CommerceItem

generateRangesForOrder

public void generateRangesForOrder(Order pOrder)
                            throws CommerceException
For each ShippingGroupCommerceItemRelationship in the order, update the Range

Parameters:
pOrder - The order to calculate the ranges for
Throws:
CommerceException

generateRangeForItem

public void generateRangeForItem(CommerceItem pItem)
                          throws CommerceException
For each ShippingGroupCommerceItemRelationship in the order, update the Range

Parameters:
pItem - The item to calculate the ranges for
Throws:
CommerceException

mergeOrdersCopyCommerceItem

protected CommerceItem mergeOrdersCopyCommerceItem(Order pSrcOrder,
                                                   Order pDstOrder,
                                                   CommerceItem pItem)
                                            throws CommerceException
This method is used by OrderManager.mergeOrders to copy a commerce item from a source order to a destination order. By default it copies the item's catalogRefId property and quantity, and the auxiliary data's catalogRef, productId, productRef, and siteId properties.

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

Parameters:
pSrcOrder - The source order from which commerce items are being copied.
pDstOrder - The destination order to which commerce items are being copied.
pItem - The item currently being copied.
Returns:
A new CommerceItem whose important properties have been set to the same values as in pItem.
Throws:
CommerceException

getProductDisplayName

protected java.lang.String getProductDisplayName(java.lang.Object pProduct)
Return the display name of a product to use when constructing user visible error messages about it, or a string indicating that the product's display name could not be found.


getSkuDisplayName

protected java.lang.String getSkuDisplayName(java.lang.Object pSku)
Return the display name of a sku to use when constructing user visible error messages about it, or a string indicating that the sku's display name could not be found.


getProductSkus

public java.util.Collection getProductSkus(java.lang.Object pProduct)
                                    throws CommerceException
Get a collection of SKU items from the specified product object

Parameters:
pProduct - the product
Returns:
a collection of SKU repository items or null
Throws:
CommerceException

productContainsSku

public boolean productContainsSku(java.lang.Object pProduct,
                                  java.lang.String pSkuId)
                           throws CommerceException
Verify that a specified sku ID is an ID of a child sku of the specified product.

Parameters:
pProduct - The product
pSkuId - The sku id to test
Returns:
Return true if the specified SKU ID is represented by one of the product's skus. Return false if the sku is not one of the child skus, or its status cannnot be determined either because we cannot locate the child skus property of the product, or we cannot examine the resulting object type to see if it contains the target sku.
Throws:
CommerceException - if unable to find or recognize the type of the product's child SKU property

productContainsSku

protected boolean productContainsSku(java.lang.String pCatalogId,
                                     java.lang.String pProductId,
                                     java.lang.Object pProduct,
                                     java.lang.String pSkuId,
                                     java.lang.Object pSku)
Verify that a specified sku is actually a child sku of the specified product during creation of a commerce item. Many of the parameters passed in to this method are not required by the default implementation, but are provided so that subclasses can implement more complex forms of checking.

Parameters:
pCatalogId - The catalog id of the particular catalog from which a commerce item is being created. May be null if custom catalogs are not in use.
pProductId - The product id of the product being examined. May be null if no product id was supplied in the call to createCommerceItem.
pProduct - The product object corresponding to pProductId, which may be null if pProductId is null.
pSkuId - The sku id of the sku being examined. This value should never be null.
pSku - The sku object corresponding to pSkuId
Returns:
Return true if the specified sku is one of the product's child skus, or of the product is null. Return false if the sku is not one of the child skus, or its status cannnot be determined either because we cannot locate the child skus property of the product, or we cannot examine the resulting object type to see if it contains the target sku.

getProductIdFromSkuId

public java.lang.String getProductIdFromSkuId(java.lang.String pSKUId)
Returns a Product ID for a given SKU, if one is found.

Parameters:
pSKUId - the sku to get a product for
Throws:
javax.servlet.ServletException - if there was an error while executing the code
java.io.IOException - if there was an error with servlet io