atg.commerce.order.purchase
Class PurchaseProcessHelper

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

public class PurchaseProcessHelper
extends GenericService

PurchaseProcessHelper contains the common functionality required by the purchase process form handlers as well as commerce web services.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String ERROR_FETCHING_PROFILE
           
static java.lang.String MSG_ERROR_ADDING_CREDIT_CARD
           
static java.lang.String MSG_ERROR_ADDING_SHIPPINGGROUP
           
static java.lang.String MSG_ERROR_ADDING_TO_ORDER
           
static java.lang.String MSG_ERROR_CREATING_ORDER
           
static java.lang.String MSG_ERROR_MOVING_ITEM_BETWEEN_SHIPPING_GROUPS
           
static java.lang.String MSG_ERROR_REMOVING_ITEM
           
static java.lang.String MSG_ERROR_REMOVING_ITEM_FROM_SHIPPING_GROUP
           
static java.lang.String MSG_ERROR_SETTING_ORDER_AMOUNT
           
static java.lang.String MSG_INVALID_PROFILE_ID
           
 
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
PurchaseProcessHelper()
           
 
Method Summary
 CreditCard addCreditCardToOrder(Order pOrder, atg.payment.creditcard.BasicCreditCardInfoImpl pCreditCardInfo, java.lang.String pCreditCardPaymentGroupType)
          Adds a new CreditCard payment group to the order.
 java.util.List addItemsToOrder(Order pOrder, ShippingGroup pShippingGroup, RepositoryItem pProfile, atg.commerce.order.purchase.AddCommerceItemInfo[] pItemInfos, java.util.Locale pUserLocale, java.lang.String pCatalogKey, PricingModelHolder pUserPricingModels, atg.commerce.util.PipelineErrorHandler pErrorHandler)
          Add one or more items to the order (the shopping cart).
 java.util.List addItemsToOrder(Order pOrder, ShippingGroup pShippingGroup, RepositoryItem pProfile, atg.commerce.order.purchase.AddCommerceItemInfo[] pItemInfos, java.util.Locale pUserLocale, java.lang.String pCatalogKey, PricingModelHolder pUserPricingModels, atg.commerce.util.PipelineErrorHandler pErrorHandler, java.util.Map pExtraParameters)
          Add one or more items to the order (the shopping cart).
protected  void addItemToShippingGroup(CommerceItem pItem, atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo, Order pOrder, ShippingGroup pShippingGroup)
          Associate a commerce item with the shipping group specified by the shippingGroup property.
 ShippingGroup addShippingAddressToOrder(Order pOrder, Address pAddress)
          Adds a new HardgoodShippingGroup with the given address to the order.
 void adjustItemRelationshipsForQuantityChange(Order pOrder, CommerceItem pItem, long pNewQuantity)
          Adjusts the shipping group relationship quantities when an item's quantity is changed.
protected  void adjustNonGiftHandlingInstructionsForQuantityDecrease(Order pOrder, ShippingGroup pShippingGroup, CommerceItem pCommerceItem, long pNewQuantity, long pQuantityDecrease)
          Adjusts the non-gift handling instruction for a quantity decrease.
protected  void adjustNonGiftHandlingInstructionsForQuantityIncrease(Order pOrder, ShippingGroup pShippingGroup, CommerceItem pCommerceItem, long pNewQuantity, long pQuantityIncreasee)
          Adjusts the non-gift handling instruction for a quantity increase.
protected  void applyValueDictionary(java.lang.Object pBean, java.util.Dictionary pValues, java.lang.String pPropertyPathPrefix)
          Copy properties from the value dictionary or one of its descendents.
 void copyCreditCardInfo(atg.payment.creditcard.BasicCreditCardInfo pCreditCardInfo, CreditCard pCard)
          Copies credit card information into the credit card payment group.
protected  CommerceItem createCommerceItem(atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo, java.lang.String pCatalogKey, Order pOrder)
          Create a commerce item and add it to the order.
protected  void createConfigurableSubitems(CommerceItem pItem, atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo, Order pOrder)
          Create subitems for a base configurable commerce item.
 Order createOrder(java.lang.String pOrderType, java.lang.String pProfileId)
          Creates an Order of the given type for the given user within a transaction.
protected  void decreaseRelationshipQuantity(Order pOrder, ShippingGroupCommerceItemRelationship pRelationship, long pQuantityDecrease)
          Decrease the quantity of a relationship by the given amount.
 java.util.List deleteItems(Order pOrder, java.lang.String[] pRemovalCommerceIds, PricingModelHolder pUserPricingModels, java.util.Locale pUserLocale, RepositoryItem pProfile, atg.commerce.util.PipelineErrorHandler pErrorHandler)
          Delete all items from the order whose id appears in the RemovalCommerceIds property.
 java.util.List deleteItems(Order pOrder, java.lang.String[] pRemovalCommerceIds, PricingModelHolder pUserPricingModels, java.util.Locale pUserLocale, RepositoryItem pProfile, atg.commerce.util.PipelineErrorHandler pErrorHandler, java.util.Map pExtraParameters)
          Delete all items from the order whose id appears in the RemovalCommerceIds property.
 java.lang.String getAddItemToOrderChainId()
          Gets the addItemToOrder pipeline chain id.
 java.lang.String getAddItemToOrderPricingOp()
          Gets the addItemToOrder pricing operation.
 CommerceItemManager getCommerceItemManager()
          Gets the CommerceItemManager component.
 java.lang.String getDefaultHardgoodShippingGroupType()
          Gets the DefaultHardgoodShippingGroupType.
 java.lang.String getDeleteItemsFromOrderPricingOp()
          Gets the deleteItemsToOrder pricing operation.
 GiftlistManager getGiftlistManager()
          Gets the GiftlistManager component.
 OrderManager getOrderManager()
          Sets the OrderManager component.
 PipelineManager getPipelineManager()
          Gets the PipelineManager component.
 java.lang.String getRepriceOrderChainId()
          Gets the reprice order pipeline chain id.
 ShippingGroup getShippingGroupForItem(Order pOrder, atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo, ShippingGroup pShippingGroup, java.lang.String pCatalogKey)
          This method returns a shipping group whose type is appropriate for a new item being added to an order.
 ShippingGroupManager getShippingGroupManager()
          Gets the ShippingGroupManager component.
 javax.transaction.TransactionManager getTransactionManager()
          Gets the TransactionManager component.
protected  void increaseRelationshipQuantity(Order pOrder, ShippingGroupCommerceItemRelationship pRelationship, long pQuantityIncrease)
          Increases the relationship quantity by the given amount.
 boolean isAddItemToDefaultShippingGroup()
          This property tells addItemsToOrder whether to add new items to a default shipping group that is passed in or to shipping groups whose types are appropriate for the items.
 void moveItemBetweenShippingGroups(Order pOrder, java.lang.String pCommerceItemId, long pQuantity, java.lang.String pSourceShippingGroupId, java.lang.String pTargetShippingGroupId)
          Move the given quantity of the commerce item from one shipping group into another.
protected  void processGiftAddition(CommerceItem pItem, atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo, Order pOrder, RepositoryItem pProfile, ShippingGroup pShippingGroup)
          Perform giftlist related processing for an item being ordered from a giftlist.
 void processPipelineErrors(PipelineResult pResult, atg.commerce.util.PipelineErrorHandler pErrorHandler)
           
protected  void removeEntireRelationshipQuantity(Order pOrder, ShippingGroupCommerceItemRelationship pRelationship)
          Decreases the quantity of a relationship to zero Called by adjustItemRelationshipsForQuantityChange when the quantity of a relationship is being decreased to zero.
 void removeItemQuantityFromShippingGroup(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pShippingGroupId, long pQuantity)
          Remove the quantity of the given item from the shipping group.
protected  PipelineResult runProcess(java.lang.String pChainId, java.util.Map pParameters)
          Executes a Pipeline Chain.
protected  PipelineResult runProcess(java.lang.String pChainId, Order pOrder, PricingModelHolder pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.
protected  PipelineResult runProcess(java.lang.String pChainId, Order pOrder, PricingModelHolder pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pParameters, java.util.Map pExtraParameters)
          Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.
protected  void runProcessAddItemToOrder(Order pOrder, CommerceItem pCommerceItem, PricingModelHolder pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters, atg.commerce.util.PipelineErrorHandler pErrorHandler)
          Run the pipeline which should be executed when the handleAddItemToOrder method is invoked This method will add pCommerceItem to pExtraParameters unless the key PipelineConstants.COMMERCEITEM is already in the map
 void runProcessRepriceOrder(java.lang.String pPricingOperation, Order pOrder, PricingModelHolder pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters, atg.commerce.util.PipelineErrorHandler pErrorHandler)
          Run the pipeline which should be executed when the order needs to be repriced
protected  void runProcessSendScenarioEvent(Order pOrder, CommerceItem pItem, long pQuantity, java.lang.String pType, atg.commerce.util.PipelineErrorHandler pErrorHandler)
          The runProcessSendScenarioEvent method sends a scenario event.
protected  PipelineResult runRepricingProcess(java.lang.String pChainId, java.lang.String pPricingOperation, Order pOrder, PricingModelHolder pPricingModels, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.
 void setAddItemToDefaultShippingGroup(boolean pAddItemToDefaultShippingGroup)
          This property tells addItemsToOrder whether to add new items to a default shipping group that is passed in or to shipping groups whose types are appropriate for the items.
 void setAddItemToOrderChainId(java.lang.String pAddItemToOrderChainId)
          Sets the addItemToOrder pipeline chain id.
 void setAddItemToOrderPricingOp(java.lang.String pAddItemToOrderPricingOp)
          Sets the addItemToOrder pricing operation.
 void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
          Sets the CommerceItemManager component.
protected  void setCommerceItemProperties(CommerceItem pItem, atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo)
          Fill in "extra" commerce item properties.
 void setDefaultHardgoodShippingGroupType(java.lang.String pDefaultHardgoodShippingGroupType)
          Sets the defaultHardgoodShippingGroupType.
 void setDeleteItemsFromOrderPricingOp(java.lang.String pDeleteItemsFromOrderPricingOp)
          Sets the deleteItemsToOrder pricing operation.
 void setGiftlistManager(GiftlistManager pGiftlistManager)
          Sets the GiftlistManager component.
 void setOrderAmountToPaymentGroup(Order pOrder, java.lang.String pPaymentGroupId, double pAmount)
          Sets the given order amount to the given payment group.
 void setOrderManager(OrderManager pOrderManager)
          Gets the OrderManager component.
 void setPipelineManager(PipelineManager pPipelineManager)
          Sets the PipelineManager component.
 void setRepriceOrderChainId(java.lang.String pRepriceOrderChainId)
          Sets the reprice order pipeline chain id.
 void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
          Sets the ShippingGroupManager component.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets the TransactionManager component.
 
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

MSG_ERROR_ADDING_TO_ORDER

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

MSG_ERROR_REMOVING_ITEM

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

MSG_ERROR_CREATING_ORDER

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

MSG_ERROR_ADDING_SHIPPINGGROUP

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

MSG_ERROR_SETTING_ORDER_AMOUNT

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

MSG_ERROR_ADDING_CREDIT_CARD

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

MSG_ERROR_REMOVING_ITEM_FROM_SHIPPING_GROUP

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

MSG_ERROR_MOVING_ITEM_BETWEEN_SHIPPING_GROUPS

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

ERROR_FETCHING_PROFILE

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

MSG_INVALID_PROFILE_ID

public static final java.lang.String MSG_INVALID_PROFILE_ID
See Also:
Constant Field Values
Constructor Detail

PurchaseProcessHelper

public PurchaseProcessHelper()
Method Detail

getRepriceOrderChainId

public java.lang.String getRepriceOrderChainId()
Gets the reprice order pipeline chain id.


setRepriceOrderChainId

public void setRepriceOrderChainId(java.lang.String pRepriceOrderChainId)
Sets the reprice order pipeline chain id.


getOrderManager

public OrderManager getOrderManager()
Sets the OrderManager component.


setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Gets the OrderManager component.


getPipelineManager

public PipelineManager getPipelineManager()
Gets the PipelineManager component.


setPipelineManager

public void setPipelineManager(PipelineManager pPipelineManager)
Sets the PipelineManager component.


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Gets the TransactionManager component.


setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets the TransactionManager component.


setCommerceItemManager

public void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
Sets the CommerceItemManager component.


getCommerceItemManager

public CommerceItemManager getCommerceItemManager()
Gets the CommerceItemManager component.


setGiftlistManager

public void setGiftlistManager(GiftlistManager pGiftlistManager)
Sets the GiftlistManager component.


getGiftlistManager

public GiftlistManager getGiftlistManager()
Gets the GiftlistManager component.


setShippingGroupManager

public void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
Sets the ShippingGroupManager component.


getShippingGroupManager

public ShippingGroupManager getShippingGroupManager()
Gets the ShippingGroupManager component.


setAddItemToOrderPricingOp

public void setAddItemToOrderPricingOp(java.lang.String pAddItemToOrderPricingOp)
Sets the addItemToOrder pricing operation.


getAddItemToOrderPricingOp

public java.lang.String getAddItemToOrderPricingOp()
Gets the addItemToOrder pricing operation.


setAddItemToOrderChainId

public void setAddItemToOrderChainId(java.lang.String pAddItemToOrderChainId)
Sets the addItemToOrder pipeline chain id.


getAddItemToOrderChainId

public java.lang.String getAddItemToOrderChainId()
Gets the addItemToOrder pipeline chain id.


setDeleteItemsFromOrderPricingOp

public void setDeleteItemsFromOrderPricingOp(java.lang.String pDeleteItemsFromOrderPricingOp)
Sets the deleteItemsToOrder pricing operation.


getDeleteItemsFromOrderPricingOp

public java.lang.String getDeleteItemsFromOrderPricingOp()
Gets the deleteItemsToOrder pricing operation.


setDefaultHardgoodShippingGroupType

public void setDefaultHardgoodShippingGroupType(java.lang.String pDefaultHardgoodShippingGroupType)
Sets the defaultHardgoodShippingGroupType.


getDefaultHardgoodShippingGroupType

public java.lang.String getDefaultHardgoodShippingGroupType()
Gets the DefaultHardgoodShippingGroupType.


isAddItemToDefaultShippingGroup

public boolean isAddItemToDefaultShippingGroup()
This property tells addItemsToOrder whether to add new items to a default shipping group that is passed in or to shipping groups whose types are appropriate for the items.

This property is used only if the AddCommerceItemInfo does not supply the shipping group type and this property is used in getShippingGroupForItem(Order, AddCommerceItemInfo, ShippingGroup, String).

The default value for this property is true. If the property is false, then the system will identify shipping groups based on the new items' shipping group types. Otherwise the system will use the default shipping group that is passed in.

Returns:
the addItemToDefaultShippingGroup value
See Also:
getShippingGroupForItem(Order, AddCommerceItemInfo, ShippingGroup, String)

setAddItemToDefaultShippingGroup

public void setAddItemToDefaultShippingGroup(boolean pAddItemToDefaultShippingGroup)
This property tells addItemsToOrder whether to add new items to a default shipping group that is passed in or to shipping groups whose types are appropriate for the items.

This property is used only if the AddCommerceItemInfo does not supply the shipping group type and this property is used in getShippingGroupForItem(Order, AddCommerceItemInfo, ShippingGroup, String).

The default value for this property is true. If the property is false, then the system will identify shipping groups based on the new items' shipping group types. Otherwise the system will use the default shipping group that is passed in.

Parameters:
pAddItemToDefaultShippingGroup - the value to set
See Also:
getShippingGroupForItem(Order, AddCommerceItemInfo, ShippingGroup, String)

runProcessRepriceOrder

public void runProcessRepriceOrder(java.lang.String pPricingOperation,
                                   Order pOrder,
                                   PricingModelHolder pPricingModels,
                                   java.util.Locale pLocale,
                                   RepositoryItem pProfile,
                                   java.util.Map pExtraParameters,
                                   atg.commerce.util.PipelineErrorHandler pErrorHandler)
                            throws RunProcessException
Run the pipeline which should be executed when the order needs to be repriced

Parameters:
pPricingOperation - the pricing operation (e.g. order total, subtotal, shipping, etc) that should be performed.
pOrder - the order to reprice
pPricingModels - the set of all pricing models for the user (item, order, shipping, tax)
pLocale - the locale that the order should be priced within
pProfile - the user who owns the order
pExtraParameters - A Map of extra parameters to be used in the pricing
Throws:
RunProcessException - if an error occurs

runRepricingProcess

protected PipelineResult runRepricingProcess(java.lang.String pChainId,
                                             java.lang.String pPricingOperation,
                                             Order pOrder,
                                             PricingModelHolder pPricingModels,
                                             java.util.Locale pLocale,
                                             RepositoryItem pProfile,
                                             java.util.Map pExtraParameters)
                                      throws RunProcessException
Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.

Parameters:
pChainId - the pipeline chain to execute
pPricingOperation - a String value
pOrder - the order to reprice
pPricingModels - the set of all pricing models for the user (item, order, shipping, tax)
pLocale - the locale that the order should be priced within
pProfile - the user who owns the order
pExtraParameters - A Map of extra parameters to be used in the pricing
Returns:
a PipelineResult value
Throws:
RunProcessException - if an error occurs

runProcess

protected PipelineResult runProcess(java.lang.String pChainId,
                                    Order pOrder,
                                    PricingModelHolder pPricingModels,
                                    java.util.Locale pLocale,
                                    RepositoryItem pProfile,
                                    java.util.Map pParameters,
                                    java.util.Map pExtraParameters)
                             throws RunProcessException
Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.

Parameters:
pChainId - the pipeline chain to execute
pOrder - the order to reprice
pPricingModels - the set of all pricing models for the user (item, order, shipping, tax)
pLocale - the locale that the order should be priced within
pProfile - the user who owns the order
pParameters - A Map of parameters to be used when calling the PipelineChain
pExtraParameters - A Map of extra parameters to be used in the pricing
Returns:
a PipelineResult value
Throws:
RunProcessException - if an error occurs

runProcess

protected PipelineResult runProcess(java.lang.String pChainId,
                                    Order pOrder,
                                    PricingModelHolder pPricingModels,
                                    java.util.Locale pLocale,
                                    RepositoryItem pProfile,
                                    java.util.Map pExtraParameters)
                             throws RunProcessException
Executes a Pipeline Chain and places the supplies method parameters into a HashMap which is supplied to the chain to execute.

Parameters:
pChainId - the pipeline chain to execute
pOrder - the order to reprice
pPricingModels - the set of all pricing models for the user (item, order, shipping, tax)
pLocale - the locale that the order should be priced within
pProfile - the user who owns the order
pExtraParameters - A Map of extra parameters to be used in the pricing
Returns:
a PipelineResult value
Throws:
RunProcessException - if an error occurs

runProcess

protected PipelineResult runProcess(java.lang.String pChainId,
                                    java.util.Map pParameters)
                             throws RunProcessException
Executes a Pipeline Chain.

Parameters:
pChainId - the pipeline chain to execute
pParameters - A Map of parameters to be passed to the chain during execution
Returns:
a PipelineResult value
Throws:
RunProcessException - if an error occurs

createOrder

public Order createOrder(java.lang.String pOrderType,
                         java.lang.String pProfileId)
                  throws CommerceException
Creates an Order of the given type for the given user within a transaction. If a failure occurs, the transaction will be rolled back.

Parameters:
pOrderType - The type of order to create. Null will use the default order type.
pProfileId - The profile of the user for whom the order is created.
Returns:
the newly created Order
Throws:
CommerceException - if an error occurs while creating the order.

addShippingAddressToOrder

public ShippingGroup addShippingAddressToOrder(Order pOrder,
                                               Address pAddress)
                                        throws CommerceException
Adds a new HardgoodShippingGroup with the given address to the order. This uses the defaultHardgoodShippingGroupType when creating the shipping group If a failure occurs, the transaction will be rolled back.

Parameters:
pOrder - The order which will be given the new shipping group.
pAddress - The address of the shipping group.
Returns:
The newly created shipping group.
Throws:
CommerceException - If the operation fails.

setOrderAmountToPaymentGroup

public void setOrderAmountToPaymentGroup(Order pOrder,
                                         java.lang.String pPaymentGroupId,
                                         double pAmount)
                                  throws CommerceException
Sets the given order amount to the given payment group. If a failure occurs, the transaction will be rolled back.

Parameters:
pOrder - The order containing the payment group.
pPaymentGroupId - The id of the payment group.
pAmount - The amount to assign to the payment group.
Throws:
CommerceException - if the operation fails.

addCreditCardToOrder

public CreditCard addCreditCardToOrder(Order pOrder,
                                       atg.payment.creditcard.BasicCreditCardInfoImpl pCreditCardInfo,
                                       java.lang.String pCreditCardPaymentGroupType)
                                throws CommerceException
Adds a new CreditCard payment group to the order. If a failure occurs, the transaction will be rolled back.

Parameters:
pOrder - The order which will be given the new credit card payment group.
pCreditCardInfo - The number, expiration date, and address of the credit card.
Returns:
The newly created credit card payment group.
Throws:
CommerceException - If the operation fails.

copyCreditCardInfo

public void copyCreditCardInfo(atg.payment.creditcard.BasicCreditCardInfo pCreditCardInfo,
                               CreditCard pCard)
                        throws CommerceException
Copies credit card information into the credit card payment group. Subclasses can extend this method to copy additional data from the info object to the payment group.

Parameters:
pCreditCardInfo - the credit card information
pCard - the credit card payment group
Throws:
CommerceException - in subclasses, if the copy cannot be completed.

removeItemQuantityFromShippingGroup

public void removeItemQuantityFromShippingGroup(Order pOrder,
                                                java.lang.String pCommerceItemId,
                                                java.lang.String pShippingGroupId,
                                                long pQuantity)
                                         throws CommerceException
Remove the quantity of the given item from the shipping group. If the quantity to be removed is greater than or equal to the quantity of the item within the shipping group, the item is removed from the shipping group.

Parameters:
pOrder - the order containing the shipping group.
pCommerceItemId - the id of the item to be removed.
pQuantity - the quantity of item to remove.
pShippingGroupId - the id of the shipping group from which the item will be removed.
Throws:
CommerceException - if an error occurs.

moveItemBetweenShippingGroups

public void moveItemBetweenShippingGroups(Order pOrder,
                                          java.lang.String pCommerceItemId,
                                          long pQuantity,
                                          java.lang.String pSourceShippingGroupId,
                                          java.lang.String pTargetShippingGroupId)
                                   throws CommerceException
Move the given quantity of the commerce item from one shipping group into another.

Parameters:
pOrder - the order containing the item to move.
pCommerceItemId - the id of the item to move.
pQuantity - the quantity of item to move.
pSourceShippingGroupId - the id of the source shipping group.
pTargetShippingGroupId - the id of the target shipping group.
Throws:
CommerceException - if there is an error moving the item.

addItemsToOrder

public java.util.List addItemsToOrder(Order pOrder,
                                      ShippingGroup pShippingGroup,
                                      RepositoryItem pProfile,
                                      atg.commerce.order.purchase.AddCommerceItemInfo[] pItemInfos,
                                      java.util.Locale pUserLocale,
                                      java.lang.String pCatalogKey,
                                      PricingModelHolder pUserPricingModels,
                                      atg.commerce.util.PipelineErrorHandler pErrorHandler,
                                      java.util.Map pExtraParameters)
                               throws CommerceException
Add one or more items to the order (the shopping cart). Details about the items are found in the pItemInfos array. Items with a quantity of 0 or less are not added.

Each commerce item is created by calling a series of small methods:

Input property validation is the caller's responsibility.

Parameters:
pOrder - the Order to which the items will be added.
pShippingGroup - the shipping group to which the items will be added.
pProfile - the owner of the order, used for repricing.
pItemInfos - the array of informational objects about the items to add.
pUserLocale - the locale of the user.
pCatalogKey - the key of the catalog of the items.
pUserPricingModels - the promotions for the user
pErrorHandler - the object that will handle pipelne errors.
Returns:
the list of newly created commerce item ids.
Throws:
CommerceException - if an error occurs.

addItemsToOrder

public java.util.List addItemsToOrder(Order pOrder,
                                      ShippingGroup pShippingGroup,
                                      RepositoryItem pProfile,
                                      atg.commerce.order.purchase.AddCommerceItemInfo[] pItemInfos,
                                      java.util.Locale pUserLocale,
                                      java.lang.String pCatalogKey,
                                      PricingModelHolder pUserPricingModels,
                                      atg.commerce.util.PipelineErrorHandler pErrorHandler)
                               throws CommerceException
Add one or more items to the order (the shopping cart). Details about the items are found in the pItemInfos array. Items with a quantity of 0 or less are not added.

Throws:
CommerceException
See Also:
addItemsToOrder(atg.commerce.order.Order, atg.commerce.order.ShippingGroup, atg.repository.RepositoryItem, atg.commerce.order.purchase.AddCommerceItemInfo[], java.util.Locale, java.lang.String, atg.commerce.pricing.PricingModelHolder, atg.commerce.util.PipelineErrorHandler, java.util.Map)

deleteItems

public java.util.List deleteItems(Order pOrder,
                                  java.lang.String[] pRemovalCommerceIds,
                                  PricingModelHolder pUserPricingModels,
                                  java.util.Locale pUserLocale,
                                  RepositoryItem pProfile,
                                  atg.commerce.util.PipelineErrorHandler pErrorHandler,
                                  java.util.Map pExtraParameters)
                           throws CommerceException
Delete all items from the order whose id appears in the RemovalCommerceIds property.

Parameters:
pOrder - the order from which the items will be removed.
pRemovalCommerceIds - the array of commerce items ids to be removed.
pUserPricingModels - the promotions for the user.
pUserLocale - the locale of the user.
pProfile - the user profile.
pErrorHandler - the object which will handle pipeline errors.
Returns:
the list of sku ids that were removed.
Throws:
CommerceException - if an error occurs.

deleteItems

public java.util.List deleteItems(Order pOrder,
                                  java.lang.String[] pRemovalCommerceIds,
                                  PricingModelHolder pUserPricingModels,
                                  java.util.Locale pUserLocale,
                                  RepositoryItem pProfile,
                                  atg.commerce.util.PipelineErrorHandler pErrorHandler)
                           throws CommerceException
Delete all items from the order whose id appears in the RemovalCommerceIds property.

Throws:
CommerceException
See Also:
deleteItems(atg.commerce.order.Order, java.lang.String[], atg.commerce.pricing.PricingModelHolder, java.util.Locale, atg.repository.RepositoryItem, atg.commerce.util.PipelineErrorHandler, java.util.Map)

createCommerceItem

protected CommerceItem createCommerceItem(atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo,
                                          java.lang.String pCatalogKey,
                                          Order pOrder)
                                   throws CommerceException
Create a commerce item and add it to the order.

Parameters:
pItemIndex - the index of the items array element that supplies input for the new item
pCatalogKey - the catalog key reference (locale) for the new item
Returns:
CommerceItem that was created
Throws:
CommerceException - if there was an error while executing the code

setCommerceItemProperties

protected void setCommerceItemProperties(CommerceItem pItem,
                                         atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo)
                                  throws CommerceException
Fill in "extra" commerce item properties. This implementation copies properties from the optional value dictionary to the commerce item.

Parameters:
pItem - the CommerceItem
pItemIndex - the index of the items array element that supplies input for the commerce item
Throws:
CommerceException - if there was an error while executing the code

applyValueDictionary

protected void applyValueDictionary(java.lang.Object pBean,
                                    java.util.Dictionary pValues,
                                    java.lang.String pPropertyPathPrefix)
                             throws CommerceException
Copy properties from the value dictionary or one of its descendents.

Parameters:
pBean - the object to which to copy dictionary values
pValues - the dictionary from which to copy values
pPropertyPathPrefix - the name prefix for dictionary entries (null for the top level dictionary)
Throws:
CommerceException - if there was an error while executing the code

addItemToShippingGroup

protected void addItemToShippingGroup(CommerceItem pItem,
                                      atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo,
                                      Order pOrder,
                                      ShippingGroup pShippingGroup)
                               throws CommerceException
Associate a commerce item with the shipping group specified by the shippingGroup property.

Parameters:
pItem - the CommerceItem
pItemIndex - the index of the items array element that supplies input for the commerce item
Throws:
CommerceException - if there was an error while executing the code

createConfigurableSubitems

protected void createConfigurableSubitems(CommerceItem pItem,
                                          atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo,
                                          Order pOrder)
                                   throws CommerceException
Create subitems for a base configurable commerce item. This method does nothing and can be overridden by a subclass if needed.

Parameters:
pItem - the base CommerceItem
pItemIndex - the index of the items array element that supplies input for the base commerce item
Throws:
CommerceException - if there was an error while executing the code

processGiftAddition

protected void processGiftAddition(CommerceItem pItem,
                                   atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo,
                                   Order pOrder,
                                   RepositoryItem pProfile,
                                   ShippingGroup pShippingGroup)
                            throws CommerceException
Perform giftlist related processing for an item being ordered from a giftlist. An item is considered ordered from a giftlist if either its input giftlistId or giftlistItemId is non-null.

Parameters:
pItem - the CommerceItem
pItemIndex - the index of the items array element that supplies input for the commerce item
Throws:
CommerceException - if there was an error while executing the code

runProcessAddItemToOrder

protected void runProcessAddItemToOrder(Order pOrder,
                                        CommerceItem pCommerceItem,
                                        PricingModelHolder pPricingModels,
                                        java.util.Locale pLocale,
                                        RepositoryItem pProfile,
                                        java.util.Map pExtraParameters,
                                        atg.commerce.util.PipelineErrorHandler pErrorHandler)
                                 throws RunProcessException
Run the pipeline which should be executed when the handleAddItemToOrder method is invoked This method will add pCommerceItem to pExtraParameters unless the key PipelineConstants.COMMERCEITEM is already in the map

Parameters:
pOrder - the order to reprice
pPricingModels - the set of all pricing models for the user (item, order, shipping, tax)
pLocale - the locale that the order should be priced within
pProfile - the user who owns the order
pExtraParameters - A Map of extra parameters to be used in the pricing
Throws:
RunProcessException

runProcessSendScenarioEvent

protected void runProcessSendScenarioEvent(Order pOrder,
                                           CommerceItem pItem,
                                           long pQuantity,
                                           java.lang.String pType,
                                           atg.commerce.util.PipelineErrorHandler pErrorHandler)
                                    throws RunProcessException
The runProcessSendScenarioEvent method sends a scenario event.

Parameters:
pOrder - an Order value
pItem - a CommerceItem value
pQuantity - the quantity affected
pType - a String value
Throws:
RunProcessException - if an error occurs

processPipelineErrors

public void processPipelineErrors(PipelineResult pResult,
                                  atg.commerce.util.PipelineErrorHandler pErrorHandler)

adjustItemRelationshipsForQuantityChange

public void adjustItemRelationshipsForQuantityChange(Order pOrder,
                                                     CommerceItem pItem,
                                                     long pNewQuantity)
                                              throws CommerceException
Adjusts the shipping group relationship quantities when an item's quantity is changed.

Parameters:
pOrder - the order which contains the item
pItem - the item
pNewQuantity -
Throws:
CommerceException
See Also:
increaseRelationshipQuantity(Order, ShippingGroupCommerceItemRelationship, long), decreaseRelationshipQuantity(Order, ShippingGroupCommerceItemRelationship, long), removeEntireRelationshipQuantity(Order, ShippingGroupCommerceItemRelationship)

increaseRelationshipQuantity

protected void increaseRelationshipQuantity(Order pOrder,
                                            ShippingGroupCommerceItemRelationship pRelationship,
                                            long pQuantityIncrease)
                                     throws CommerceException
Increases the relationship quantity by the given amount.

Called by adjustItemRelationshipsForQuantityChange when the quantity of an item is being increased for a relationship. Gift quantity is also increased, if necessary.

Gift quantities and other handling isntructions are also adjusted

Parameters:
pOrder -
pRelationship -
pQuantity - to quantity by which to increase
Throws:
CommerceException
See Also:
GiftlistManager.adjustGiftsForQuantityIncrease(Order, ShippingGroup, CommerceItem, long, long), adjustNonGiftHandlingInstructionsForQuantityIncrease(Order, ShippingGroup, CommerceItem, long, long)

removeEntireRelationshipQuantity

protected void removeEntireRelationshipQuantity(Order pOrder,
                                                ShippingGroupCommerceItemRelationship pRelationship)
                                         throws CommerceException
Decreases the quantity of a relationship to zero Called by adjustItemRelationshipsForQuantityChange when the quantity of a relationship is being decreased to zero. This method removes all handling instructions before removing the item's quantity from the shipping group.

Parameters:
pOrder -
pShippingGroup -
pCommerceItem -
Throws:
CommerceException

decreaseRelationshipQuantity

protected void decreaseRelationshipQuantity(Order pOrder,
                                            ShippingGroupCommerceItemRelationship pRelationship,
                                            long pQuantityDecrease)
                                     throws CommerceException
Decrease the quantity of a relationship by the given amount.

Called by adjustItemRelationshipsForQuantityChange when the quantity of a relationship is being partially decreased by the given value.

Gift quantities and other handling instructions are also adjusted

Parameters:
pOrder -
pRelationship -
pQuantityDecrease -
Throws:
CommerceException
See Also:
GiftlistManager.adjustGiftsForQuantityDecrease(Order, ShippingGroup, CommerceItem, long, long), adjustNonGiftHandlingInstructionsForQuantityDecrease(Order, ShippingGroup, CommerceItem, long, long)

adjustNonGiftHandlingInstructionsForQuantityDecrease

protected void adjustNonGiftHandlingInstructionsForQuantityDecrease(Order pOrder,
                                                                    ShippingGroup pShippingGroup,
                                                                    CommerceItem pCommerceItem,
                                                                    long pNewQuantity,
                                                                    long pQuantityDecrease)
                                                             throws CommerceException
Adjusts the non-gift handling instruction for a quantity decrease.

This method adjusts the quantity of the handling instruction to the given new quantity if its quantity currently higher than the new quantity.

Applications should extend this method to handle custom handling instructions accordlingly.

Parameters:
pOrder -
pShippingGroup -
pCommerceItem -
pNewQuantity -
pQuantityDecrease -
Throws:
CommerceException

adjustNonGiftHandlingInstructionsForQuantityIncrease

protected void adjustNonGiftHandlingInstructionsForQuantityIncrease(Order pOrder,
                                                                    ShippingGroup pShippingGroup,
                                                                    CommerceItem pCommerceItem,
                                                                    long pNewQuantity,
                                                                    long pQuantityIncreasee)
                                                             throws CommerceException
Adjusts the non-gift handling instruction for a quantity increase.

This method increases the quantity of all non-gift handling instructions by the given quantity increase.

Applications should extend this method to handle custom handling instructions accordlingly.

Parameters:
pOrder -
pShippingGroup -
pCommerceItem -
pNewQuantity -
pQuantityIncreasee -
Throws:
CommerceException

getShippingGroupForItem

public ShippingGroup getShippingGroupForItem(Order pOrder,
                                             atg.commerce.order.purchase.AddCommerceItemInfo pItemInfo,
                                             ShippingGroup pShippingGroup,
                                             java.lang.String pCatalogKey)
                                      throws CommerceException
This method returns a shipping group whose type is appropriate for a new item being added to an order. If a shipping group type is supplied in AddCommerceItemInfo, that type is used. Otherwise, this method checks to see if the addItemToDefaultShippingGroup flag is turned on/off. If the addItemToDefaultShippingGroup flag value is true, this method returns the default shipping group pShippingGroup. If the addItemToDefaultShippingGroup flag is false, this method calls getShippingGroupManager().getFirstShippingGroupType() to identify the right shipping group type for the item.

Once the item's shipping group type has been identified, this method uses the following logic to locate an appropriate shipping group in the order or to create a new shipping group:

This method is used to get a shipping group for gift or normal commerce item. If the AddCommerceItemInfo#getGiftlistId() or AddCommerceItemInfo#getGiftlistItemId() is not empty a commerce item is considered as a gift item. For gift items, this method checks only the shipping group type.
The following logic is used for a gift item to find an appropriate shipping group:

The following logic is used for a NON-GIFT item to find an appropriate shipping group:

Parameters:
pOrder - the Order to which the item will be added.
pItemInfo - detailed information about the item to be added.
pShippingGroup - a candidate or default shipping group to use.
pCatalogKey - the key of the catalog of the items.
Returns:
a shipping group whose type is appropriate for the new item.
Throws:
CommerceException
See Also:
GiftlistManager.isGiftShippingGroup(ShippingGroup)