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.AbsoluteNameable, atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameContextParentable, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.Configured, 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.

Version:
$Id: //hosting-blueprint/B2CBlueprint/version/10.2.1/EStore/src/atg/projects/store/order/StoreOrderManager.java#3 $
Author:
ATG

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.
 int checkStatus(atg.commerce.order.CommerceItem pCommItem)
          This method uses the inventory manager to query the availability status of the given commerce item.
 atg.commerce.order.Order cloneOrder(java.lang.String pOrderId, atg.repository.RepositoryItem pProfile)
          This method creates an order's duplicate with a new ID.
 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.
 atg.commerce.states.CommerceItemStates getCommerceItemStates()
           
 java.lang.String getCouponCode(StoreOrderImpl pOrder)
          This method calculates a coupon code used by the order pOrder.
 atg.commerce.gifts.GiftlistManager getGiftlistManager()
          The gift list 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.
protected  void priceOrderTotal(atg.commerce.order.Order pOrder)
          This method is a shortcut to the PricingTools.priceOrderTotal(atg.commerce.order.Order) method.
 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 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, compareInStorePickupShippingGroups, 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, getCostCenterItemDescriptorName, getCostCenterOrderPropertyName, getDateRangeQuery, getDebugOrderRepositoryItemUpdateTransaction, getDefaultLocale, getDefaultOrderByDirection, getDefaultOrderByProperty, getHandlingInstructionManager, getHandlingInstructionsForCommerceItem, getJNDIContext, getOrderCommerceItemsPropertyName, getOrderCostCentersPropertyName, getOrderCountForProfile, getOrderCountForProfileInState, getOrderForCommerceItem, getOrderForCostCenter, 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, loadOrders, 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, setCostCenterItemDescriptorName, setCostCenterOrderPropertyName, setCreateSGRelationshipsOnMerge, setDebugOrderRepositoryItemUpdateTransaction, setDefaultLocale, setDefaultOrderByDirection, setDefaultOrderByProperty, setHandlingInstructionManager, setOrderCommerceItemsPropertyName, setOrderCostCentersPropertyName, 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, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string.

See Also:
Constant Field Values
Constructor Detail

StoreOrderManager

public StoreOrderManager()
Method Detail

isAdjustInventoryOnCheckout

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

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 gift list manager.

Returns:
a GiftlistManager value.

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)
                           throws atg.commerce.CommerceException
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.
Throws:
atg.commerce.CommerceException

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.

cloneOrder

public atg.commerce.order.Order cloneOrder(java.lang.String pOrderId,
                                           atg.repository.RepositoryItem pProfile)
                                    throws atg.commerce.CommerceException
This method creates an order's duplicate with a new ID.
The new order will possess copies of original order's commerce items. Items created from a gift-list will be marked as created from gift-list. There will be created shipping groups to represent all gift-lists used and proper links will be set.
The new order will also be re-priced in order to user proper promotions and prices.

Parameters:
pOrderId - base order, specified by its ID.
pProfile - new order will be created on behalf of this user.
Returns:
a fully ready to work copy of input order.
Throws:
atg.commerce.CommerceException - if unable to create the order.

priceOrderTotal

protected final void priceOrderTotal(atg.commerce.order.Order pOrder)
                              throws atg.commerce.pricing.PricingException
This method is a shortcut to the PricingTools.priceOrderTotal(atg.commerce.order.Order) method.

Parameters:
pOrder - order to be re-priced.
Throws:
atg.commerce.pricing.PricingException - if unable to re-price the order specified.

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.
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 pre-orderable or back-orderable or in stock.
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 - indicates that a severe error occurred while performing a commerce operation.

getCouponCode

public java.lang.String getCouponCode(StoreOrderImpl pOrder)
                               throws atg.commerce.CommerceException
This method calculates a coupon code used by the order pOrder. It looks up an owner of the order (i.e. profile) and iterates over its active promotion statuses. It calculates all coupons linked by these statuses. First coupon with proper site ID (i.e. from the shared cart site group) will be returned.

Parameters:
pOrder - Order to be inspected.
Returns:
Coupon code used by the order or null if none of coupons used.
Throws:
atg.commerce.CommerceException - If we are unable to get the profile from the repository.