atg.projects.store.order
Class StoreOrderManager

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

public class StoreOrderManager
extends atg.commerce.order.SimpleOrderManager

The class extends the ATG SimpleOrderManager. The main functionality added to this class is related to gift services. The business logic for addition and removal of gift message and gift wrap is here.

Also included in this class is the logic for building a set of AddCommerceItemInfo objects based on an Order.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
 
Fields inherited from class atg.commerce.order.OrderManager
mOrderManager, mOrderMergeListeners, mUserPricingModelsPath, sResourceBundle
 
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
StoreOrderManager()
           
 
Method Summary
 void addGiftMessage(StoreOrderImpl pOrder, java.lang.String pMessageTo, java.lang.String pMessage, java.lang.String pMessageFrom)
          Adds the gift message to the order's special instructions.
 void addGiftWrap(StoreOrderImpl pOrder, java.lang.String pSkuId, java.lang.String pProductId)
          Creates and adds the gift wrap commerce item to the order.
 void addRemoveGiftServices(StoreOrderImpl pOrder, boolean pAddGiftWrap, boolean pAddGiftMessage, java.lang.String pGiftWrapSkuId, java.lang.String pGiftWrapProductId)
          This method can be used by form handlers to add / remove gift message or gift wrap from the order.
 java.util.List buildItemInfos(atg.commerce.order.Order pOrder)
          Returns a List of AddCommerceItemInfos based on the order param.
 int checkStatus(atg.commerce.order.CommerceItem pCommItem)
          This method uses the inventory manager to query the availability status of the given commerce item.
protected  StoreAddCommerceItemInfo createAddCommerceItemInfo(atg.commerce.order.CommerceItem pItem)
          Creates a StoreAddCommerceItemInfo object for an item.
protected  java.util.Collection createItemsForGift(atg.commerce.order.Order pOrder, atg.commerce.order.CommerceItem pItem)
          Creates a collection of AddCommerceItemInfo objects for each gift relationship for an item.
 atg.commerce.order.Order createOrder(java.lang.String pProfileId, java.lang.String pOrderId, atg.commerce.pricing.OrderPriceInfo pOrderPriceInfo, atg.commerce.pricing.TaxPriceInfo pTaxPriceInfo, atg.commerce.pricing.ShippingPriceInfo pShippingPriceInfo, java.lang.String pOrderType)
          Calls OrderManager.createOrder to create a new Order object using the class mapped to the given name in pOrderType and whose id will be that which is supplied in pOrderId.
 java.lang.String getAddItemInfoClass()
           
 atg.commerce.states.CommerceItemStates getCommerceItemStates()
           
 atg.commerce.gifts.GiftlistManager getGiftlistManager()
          The giftlist manager.
 java.lang.String getOMSTransactionId()
          Use the OMSTransactionIdGenerator to get the next Transaction Id.
 atg.service.idgen.IdGenerator getOMSTransactionIdGenerator()
          The OMSTransactionIdGenerator.
 java.lang.String getOMSTransactionIdSpace()
          The OMSTransactionIdSpace.
 boolean isAdjustInventoryOnCheckout()
           
 void manageInventoryOnCheckout(atg.commerce.order.Order pOrder)
          This method sets the state of each commerce item based on the sku's current inventory availability.
 void removeGiftMessage(StoreOrderImpl pOrder)
          Removes the gift message from the order.
 void removeGiftWrap(StoreOrderImpl pOrder)
          Removes the gift wrap commerce item from the order.
 void setAddItemInfoClass(java.lang.String pAddItemInfoClass)
          Sets the name of the class to be used for elements in the items array.
 void setAdjustInventoryOnCheckout(boolean pAdjustInventoryOnCheckout)
           
 void setCommerceItemStates(atg.commerce.states.CommerceItemStates pCommerceItemStates)
           
 void setGiftlistManager(atg.commerce.gifts.GiftlistManager pGiftlistManager)
          Specifies the GiftlistManager.
 void setOMSTransactionIdGenerator(atg.service.idgen.IdGenerator pOMSTransactionIdGenerator)
          Specifies the OMSTransactionIdGenerator.
 void setOMSTransactionIdSpace(java.lang.String pOMSTransactionIdSpace)
          Specifies the OMSTransactionIdSpace.
 
Methods inherited from class atg.commerce.order.SimpleOrderManager
addItemToShippingGroup, addItemToShippingGroup, moveItemToShippingGroup, moveItemToShippingGroup, removeItemFromShippingGroup, removeItemFromShippingGroup
 
Methods inherited from class atg.commerce.order.OrderManager
addAsSeparateItemToOrder, addHandlingInstructionToShippingGroup, addItemAmountToPaymentGroup, addItemQuantityToShippingGroup, addItemToOrder, addOrder, addOrderAmountToPaymentGroup, addOrderMergeListener, addPaymentGroupToOrder, addPaymentGroupToOrder, addRemainingItemAmountToPaymentGroup, addRemainingItemQuantityToShippingGroup, addRemainingOrderAmountToPaymentGroup, addRemainingShippingCostToPaymentGroup, addRemainingTaxAmountToPaymentGroup, addShippingCostAmountToPaymentGroup, addShippingGroupToOrder, addTaxAmountToPaymentGroup, areOrdersMergeable, cloneShippingGroup, compareElectronicShippingGroups, compareGiftlistHandlingInstructions, compareHandlingInstructions, compareHardgoodShippingGroups, copyAddress, copyAddress, copyAddress, copyHandlingInstruction, createCommerceItem, createCommerceItem, createCommerceItem, createCommerceItem, createCommerceItem, createCommerceItem, createCommerceItem, createCommerceItem, createHandlingInstruction, createHandlingInstruction, createHandlingInstruction, createHandlingInstruction, createOrder, createOrder, createOrder, createOrder, createOrder, createPaymentGroup, createPaymentGroup, createRelationship, createShippingGroup, createShippingGroup, createShippingGroup, doStartService, getAllCommerceItemRelationships, getAllOrderRelationships, getAllPaymentGroupRelationships, getAllShippingGroupRelationships, getCatalogTools, getCommerceItemItemDescriptorName, getCommerceItemManager, getCommerceItemOrderPropertyName, getCommerceItemsFromPaymentGroup, getCommerceItemsFromShippingGroup, getDateRangeQuery, getDebugOrderRepositoryItemUpdateTransaction, getDefaultLocale, getDefaultOrderByDirection, getDefaultOrderByProperty, getHandlingInstructionManager, getHandlingInstructionsForCommerceItem, getJNDIContext, getOrderCommerceItemsPropertyName, getOrderCountForProfile, getOrderCountForProfileInState, getOrderForCommerceItem, getOrderForPaymentGroup, getOrderForRelationship, getOrderForShippingGroup, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfile, getOrderIdsForProfileWithinDateRange, getOrderIdsWithinDateRange, getOrderItemDescriptorName, getOrderManager, getOrderPaymentGroupsPropertyName, getOrderQueries, getOrderRelationshipsPropertyName, getOrdersForProfile, getOrdersForProfile, getOrdersForProfile, getOrdersForProfile, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrdersForProfileInState, getOrderShippingGroupsPropertyName, getOrderTools, getOrderVersionPropertyName, getPaymentGroupCommerceItemRelationship, getPaymentGroupItemDescriptorName, getPaymentGroupManager, getPaymentGroupOrderPropertyName, getPaymentGroupOrderRelationship, getPaymentGroupShippingGroupRelationship, getPipelineManager, getProcessOrderMap, getRelationshipItemDescriptorName, getRelationshipOrderPropertyName, getRemainingQuantityForShippingGroup, getShipItemRelsForRange, getShippingGroupByDescription, getShippingGroupCommerceItemRelationship, getShippingGroupItemDescriptorName, getShippingGroupManager, getShippingGroupOrderPropertyName, getSiteGroupManager, getUnassignedQuantityForCommerceItem, getUniqueCatalogRefIds, getUserPricingModelsPath, getValidOrderProcessingStates, getValidProcessOrderErrorStates, initializeCreditCard, initializeDefaultPropertyValues, initializeGiftCertificate, isCreateSGRelationshipsOnMerge, isOrderStateValidForProcessing, isTransactionMarkedAsRollBack, loadOrder, markTransactionForRollback, mergeOrders, mergeOrders, orderExists, processOrder, processOrder, processOrder, processOrder, processOrderWithReprice, processOrderWithReprice, recalculatePaymentGroupAmounts, removeAllCommerceItemsFromOrder, removeAllHandlingInstructionsFromShippingGroup, removeAllPaymentGroupsFromOrder, removeAllRelationshipsFromCommerceItem, removeAllRelationshipsFromPaymentGroup, removeAllRelationshipsFromShippingGroup, removeAllShippingGroupsFromOrder, removeEmptyPaymentGroups, removeEmptyShippingGroups, removeHandlingInstructionFromShippingGroup, removeHandlingInstructionsFromShippingGroup, removeItemAmountFromPaymentGroup, removeItemFromOrder, removeItemFromPaymentGroupInternal, removeItemQuantityFromShippingGroup, removeOrder, removeOrderAmountFromPaymentGroup, removeOrderFromPaymentGroupInternal, removeOrderMergeListener, removePaymentGroupFromOrder, removeRemainingItemAmountFromPaymentGroup, removeRemainingItemQuantityFromShippingGroup, removeRemainingOrderAmountFromPaymentGroup, removeRemainingShippingCostFromPaymentGroup, removeRemainingTaxAmountFromPaymentGroup, removeShippingCostAmountFromPaymentGroup, removeShippingCostFromPaymentGroupInternal, removeShippingGroupFromOrder, removeTaxAmountFromPaymentGroup, resetOrder, resetOrderCommerceItemRelationships, returnCommerceItem, sendOrderMergeEvent, setCommerceItemItemDescriptorName, setCommerceItemManager, setCommerceItemOrderPropertyName, setCreateSGRelationshipsOnMerge, setDebugOrderRepositoryItemUpdateTransaction, setDefaultLocale, setDefaultOrderByDirection, setDefaultOrderByProperty, setHandlingInstructionManager, setOrderCommerceItemsPropertyName, setOrderItemDescriptorName, setOrderPaymentGroupsPropertyName, setOrderQueries, setOrderRelationshipsPropertyName, setOrderShippingGroupsPropertyName, setOrderTools, setOrderVersionPropertyName, setPaymentGroupItemDescriptorName, setPaymentGroupManager, setPaymentGroupOrderPropertyName, setRelationshipItemDescriptorName, setRelationshipOrderPropertyName, setShippingGroupItemDescriptorName, setShippingGroupManager, setShippingGroupOrderPropertyName, setSiteGroupManager, setUserPricingModelsPath, setValidOrderProcessingStates, setValidProcessOrderErrorStates, splitShippingGroup, splitShippingGroup, splitShippingGroupWithImplicitRelationships, updateOrder, validateOrder, validateOrder, validateOrder
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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, reResolveThis, 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 java.lang.String CLASS_VERSION
Class version string.

Constructor Detail

StoreOrderManager

public StoreOrderManager()
Method Detail

isAdjustInventoryOnCheckout

public boolean isAdjustInventoryOnCheckout()
Returns:
true if inventory should be decremented on checkout, false - otherwise.

setAdjustInventoryOnCheckout

public void setAdjustInventoryOnCheckout(boolean pAdjustInventoryOnCheckout)
Parameters:
pAdjustInventoryOnCheckout - - boolean indicating if inventory should be decremented on checkout.

getCommerceItemStates

public atg.commerce.states.CommerceItemStates getCommerceItemStates()
Returns:
the commerce item states component.

setCommerceItemStates

public void setCommerceItemStates(atg.commerce.states.CommerceItemStates pCommerceItemStates)
Parameters:
pCommerceItemStates - - the commerce item states component.

setGiftlistManager

public void setGiftlistManager(atg.commerce.gifts.GiftlistManager pGiftlistManager)
Specifies the GiftlistManager.

Parameters:
pGiftlistManager - a GiftlistManager value

getGiftlistManager

public atg.commerce.gifts.GiftlistManager getGiftlistManager()
The giftlist manager.

Returns:
a GiftlistManager value

setAddItemInfoClass

public void setAddItemInfoClass(java.lang.String pAddItemInfoClass)
Sets the name of the class to be used for elements in the items array.

Parameters:
pAddItemInfoClass - - the name of the class to be used for elements in the items array

getAddItemInfoClass

public java.lang.String getAddItemInfoClass()
Returns:
the name of the class to be used for elements in the items array.

setOMSTransactionIdGenerator

public void setOMSTransactionIdGenerator(atg.service.idgen.IdGenerator pOMSTransactionIdGenerator)
Specifies the OMSTransactionIdGenerator.

Parameters:
pOMSTransactionIdGenerator - a OMSTransactionIdGenerator value

getOMSTransactionIdGenerator

public atg.service.idgen.IdGenerator getOMSTransactionIdGenerator()
The OMSTransactionIdGenerator.

Returns:
a OMSTransactionIdGenerator value

setOMSTransactionIdSpace

public void setOMSTransactionIdSpace(java.lang.String pOMSTransactionIdSpace)
Specifies the OMSTransactionIdSpace.

Parameters:
pOMSTransactionIdSpace - a OMSTransactionIdSpace value

getOMSTransactionIdSpace

public java.lang.String getOMSTransactionIdSpace()
The OMSTransactionIdSpace.

Returns:
a OMSTransactionIdSpace value

addGiftMessage

public void addGiftMessage(StoreOrderImpl pOrder,
                           java.lang.String pMessageTo,
                           java.lang.String pMessage,
                           java.lang.String pMessageFrom)
                    throws atg.commerce.CommerceException
Adds the gift message to the order's special instructions.

Parameters:
pOrder - - the order to remove gift wrap from
pMessageTo - - the "message to:" field
pMessage - - the message body
pMessageFrom - - the "message from:" field
Throws:
atg.commerce.CommerceException - if an error occurs removing item from order

removeGiftMessage

public void removeGiftMessage(StoreOrderImpl pOrder)
                       throws atg.commerce.CommerceException
Removes the gift message from the order.

Parameters:
pOrder - - the order to remove gift wrap from
Throws:
atg.commerce.CommerceException - if an error occurs removing item from order

addRemoveGiftServices

public void addRemoveGiftServices(StoreOrderImpl pOrder,
                                  boolean pAddGiftWrap,
                                  boolean pAddGiftMessage,
                                  java.lang.String pGiftWrapSkuId,
                                  java.lang.String pGiftWrapProductId)
This method can be used by form handlers to add / remove gift message or gift wrap from the order.

Parameters:
pOrder - - The order
pAddGiftWrap - - boolean value indicating whether or not to add gift wrap
pAddGiftMessage - - boolean value indicating whether or not to add gift message
pGiftWrapSkuId - - String value indicating Sku Id of the gift wrapped
pGiftWrapProductId - - String value indicating Product Id of the gift wrapped

addGiftWrap

public void addGiftWrap(StoreOrderImpl pOrder,
                        java.lang.String pSkuId,
                        java.lang.String pProductId)
                 throws atg.commerce.CommerceException
Creates and adds the gift wrap commerce item to the order.

Parameters:
pOrder - - the order to add gift wrap to
pSkuId - - sku id
pProductId - - product id
Throws:
atg.commerce.CommerceException - if error creating item or adding item to order

removeGiftWrap

public void removeGiftWrap(StoreOrderImpl pOrder)
                    throws atg.commerce.CommerceException
Removes the gift wrap commerce item from the order.

Parameters:
pOrder - - the order to remove gift wrap from
Throws:
atg.commerce.CommerceException - if an error occurs removing item from order

buildItemInfos

public java.util.List buildItemInfos(atg.commerce.order.Order pOrder)
Returns a List of AddCommerceItemInfos based on the order param. This is used when logging the user out, and copying all the commerce items, but not the Shipping and Payment groups to the new order. This method builds the list of AddCommerceItemInfos to send to the copyItems method.

Parameters:
pOrder - order
Returns:
list of AddCommerceItemInfos

createItemsForGift

protected java.util.Collection createItemsForGift(atg.commerce.order.Order pOrder,
                                                  atg.commerce.order.CommerceItem pItem)
                                           throws atg.commerce.CommerceException
Creates a collection of AddCommerceItemInfo objects for each gift relationship for an item.

Parameters:
pOrder - - order
pItem - - item
Returns:
collection of AddCommerceItemInfo objects for each gift relationship for an item
Throws:
atg.commerce.CommerceException - If an error occurs creating item for gift

createAddCommerceItemInfo

protected StoreAddCommerceItemInfo createAddCommerceItemInfo(atg.commerce.order.CommerceItem pItem)
                                                      throws atg.commerce.CommerceException
Creates a StoreAddCommerceItemInfo object for an item. The (sub)class of AddCommerceItemInfo is configurable. Our caller is responsible for filling in the quantity property in the returned object.

Parameters:
pItem - the item whose properties should be copied
Returns:
an object containing properties needed to recreate a commerce item
Throws:
atg.commerce.CommerceException - if an error occurs

manageInventoryOnCheckout

public void manageInventoryOnCheckout(atg.commerce.order.Order pOrder)
                               throws atg.commerce.inventory.InventoryException
This method sets the state of each commerce item based on the sku's current inventory availability. If adjustInventoryOnCheckout = true, it also decrements the inventory levels of the items in the order.

Parameters:
pOrder - Order whose commerce items statuses are to be updated in inventory. description: This method takes the order and iterates through commerce items to update the inventory status
Throws:
atg.commerce.inventory.InventoryException - if an error occurs

checkStatus

public int checkStatus(atg.commerce.order.CommerceItem pCommItem)
                throws atg.commerce.inventory.InventoryException
This method uses the inventory manager to query the availability status of the given commerce item.

Parameters:
pCommItem - commerce item whose status is to be checked in inventory.
Returns:
return status either preoderable or backorderable or instock
Throws:
atg.commerce.inventory.InventoryException - if an error occurs

getOMSTransactionId

public java.lang.String getOMSTransactionId()
Use the OMSTransactionIdGenerator to get the next Transaction Id.

Returns:
New transactionId generated by OMSTransactionIdGenerator

createOrder

public atg.commerce.order.Order createOrder(java.lang.String pProfileId,
                                            java.lang.String pOrderId,
                                            atg.commerce.pricing.OrderPriceInfo pOrderPriceInfo,
                                            atg.commerce.pricing.TaxPriceInfo pTaxPriceInfo,
                                            atg.commerce.pricing.ShippingPriceInfo pShippingPriceInfo,
                                            java.lang.String pOrderType)
                                     throws atg.commerce.CommerceException
Calls OrderManager.createOrder to create a new Order object using the class mapped to the given name in pOrderType and whose id will be that which is supplied in pOrderId. Populates the Order with the supplied data.

Sets shipping method to the shipping groups the same as profile's default shipping method.

Overrides:
createOrder in class atg.commerce.order.OrderManager
Parameters:
pProfileId - the id of the Profile object which this Order belongs to
pOrderId - the id which will be assigned to the Order
pOrderPriceInfo - the OrderPriceInfo object for this Order
pTaxPriceInfo - the TaxPriceInfo object for this Order
pShippingPriceInfo - the ShippingPriceInfo object for the default ShippingGroup
pOrderType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
Returns:
the Order object which was created
Throws:
atg.commerce.CommerceException