atg.projects.store.order
Class StoreOrderTools

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

This is the OrderTools class for the Store ecommerce site. Order manipulations happen in this class. This is also the holder for information about commerce item and order types.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
static java.lang.String MSG_DUPLICATE_NICKNAME
          Error keys
static java.lang.String MSG_ERROR_SHIPPING_ADDRESS
           
static java.lang.String RESOURCE_NAME
          Resource bundle name.
 
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
StoreOrderTools()
           
 
Method Summary
 void assignOmsOrderId(StoreOrderImpl pOrder)
          This method assigns an OMS order id, and sets it on the order.
protected  void assignPostRegistrationProperties(java.util.Map pPropertiesToCopy, atg.userprofiling.Profile pProfile)
          This method copies the properties in the incoming Map to the profile item.
 boolean copyAddressToAddressBook(atg.repository.RepositoryItem pProfile, atg.core.util.Address pAddress, java.lang.String pNickname)
          Get the profile from the order, and update the address book with the shipping group address.
 boolean copyCreditCardToProfile(atg.repository.RepositoryItem pProfile, atg.commerce.order.Order pOrder, java.lang.String pCardNickname)
          This method gets the credit card from the order, and adds it to the list of credit cards for this user.
 boolean copyProfileAddressToCreditCard(atg.repository.RepositoryItem pProfile, atg.commerce.order.Order pOrder, java.lang.String pNickname)
          This method will get an address from the profile's address book, and set the credit card's billing address.
 void copyShippingToBilling(atg.core.util.Address pAddress, atg.commerce.order.Order pOrder)
          Copies an address to the credit card billing address.
 java.lang.String createCreditCardNickname(java.lang.Object pCreditCard)
          This utility method creates an address nickname for the credit card address.
 atg.repository.MutableRepositoryItem createNewCreditCard(atg.repository.RepositoryItem pProfile)
          Creates a new credit card repository item for the given profile, but does not assign a billing address.
protected  java.util.Map generatePropertiesToCopy(java.lang.String[] pProperties, atg.userprofiling.Profile pProfile)
          This method is used when registering a new user.
 StoreCatalogProperties getCatalogProperties()
           
 atg.commerce.order.CommerceItemManager getCommerceItemManager()
           
 atg.commerce.order.CreditCard getCreditCard(atg.commerce.order.Order pOrder)
          Returns the CreditCard payment group for the order.
 java.lang.String getCreditCardVerificationNumberFromCard(atg.commerce.order.Order pOrder)
          Gets the verification number from the order's credit card payment group.
 java.lang.String getGiftWrapCommerceItemType()
           
 double getGiftWrapPrice(StoreOrderImpl pOrder)
          Gets the gift wrap price from the order.
 atg.service.idgen.IdGenerator getIdGenerator()
           
 java.lang.String getOmsOrderIdSpace()
           
 java.lang.String[] getPropertiesToCopyOnRegistration()
           
 java.util.ResourceBundle getResourceBundle()
           
 java.util.ResourceBundle getResourceBundle(java.util.Locale pLocale)
           
 atg.commerce.order.HardgoodShippingGroup getShippingGroup(atg.commerce.order.Order pOrder)
          Returns the ShippingGroup.
 atg.commerce.order.ShippingGroupManager getShippingGroupManager()
           
 java.util.List getStoreCreditPaymentGroups(atg.commerce.order.Order pOrder)
          Get the store credit payment groups from the order.
 java.lang.String getTestSkuId()
           
 boolean isTestOrder(StoreOrderImpl pOrder)
          Checks to see if order is a Test order.
 boolean registerNewUserDuringCheckout(atg.userprofiling.Profile pProfile, atg.commerce.order.Order pOrder, java.util.Map pProfileValues)
           This method will register a new user during the checkout process.
 void saveAddressToAddressBook(atg.repository.RepositoryItem pProfile, atg.core.util.Address pAddress, java.lang.String pNickName)
          Saves the address to address book and makes it the default shipping address if it hasn't already been set.
 boolean saveAddressToDefaultBilling(atg.core.util.Address pAddress, atg.repository.RepositoryItem pProfile)
          Saves the address in the pAddress parameter to the default billing address of the user in the pProfile parameter.
 void saveDefaultShippingMethod(atg.repository.RepositoryItem pProfile, java.lang.String pShippingMethod)
          Sets the default shipping method for a profile, but only if it hasn't been set already.
 void setCatalogProperties(StoreCatalogProperties pProperties)
           
 void setCommerceItemManager(atg.commerce.order.CommerceItemManager pCommerceItemManager)
           
 void setCreditCardVerificationNumber(atg.commerce.order.Order pOrder, java.lang.String pVerificationNumber)
          Sets the verification number on the order's credit card payment group.
 void setGiftWrapCommerceItemType(java.lang.String pGiftWrapCommerceItemType)
           
 void setIdGenerator(atg.service.idgen.IdGenerator pIdGenerator)
           
 void setOmsOrderIdSpace(java.lang.String pOmsOrderIdSpace)
           
 void setPropertiesToCopyOnRegistration(java.lang.String[] pPropertiesToCopyOnRegistration)
           
 void setShippingGroupManager(atg.commerce.order.ShippingGroupManager pShippingGroupManager)
           
 void setTestSkuId(java.lang.String pTestSkuId)
           
protected  void updateProfileInRepository(atg.userprofiling.Profile pProfile)
          Convenience method to update the profile item in the repository.
 boolean validateCreditCardAuthorizationNumber(java.lang.String pAuthNumber)
          Verifies that the auth number is valued and a number.
 
Methods inherited from class atg.commerce.order.OrderTools
addManualAdjustment, addManualAdjustment, convertStateStringsToInts, copyAddress, copyAddress, copyAddress, createCommerceItem, createCostCenter, createHandlingInstruction, createManualAdjustmentItem, createOrder, createOrder, createOrder, createOrder, createOrderFixedAmountAdjustment, createPaymentGroup, createRelationship, createShippingGroup, createShippingGroup, deleteManualAdjustment, doStartService, findShippingGroupsWithAddress, getBeanNameToItemDescriptorMap, getCatalogTools, getCommerceItemTypeClassMap, getCostCenterTypeClassMap, getCreateDefaultCostCenter, getCreateDefaultPaymentGroup, getCreateDefaultShippingGroup, getDefaultCommerceItemType, getDefaultCostCenterType, getDefaultHandlingInstructionType, getDefaultItemPriceInfoClass, getDefaultOrderPriceInfoClass, getDefaultOrderType, getDefaultPaymentGroupAddressType, getDefaultPaymentGroupType, getDefaultProfileType, getDefaultShippingGroupAddressType, getDefaultShippingGroupType, getDefaultShippingPriceInfoClass, getDefaultTaxPriceInfoClass, getGiftlistManager, getHandlingTypeClassMap, getInventoryManager, getItemDescriptorForCommerceItemType, getItemDescriptorForOrderType, getItemDescriptorForPaymentType, getItemDescriptorForShippingType, getItemDescriptorToBeanNameMap, getMappedBeanName, getMappedItemDescriptorName, getOrderFixedAmountAdjustmentType, getOrderItemDescriptorName, getOrderLookupService, getOrderRepository, getOrderTypeClassMap, getPaymentGroupBillingAddressClassNameMap, getPaymentTypeClassMap, getPipelineManager, getProfileRepository, getProfileTools, getRelationshipTypeClassMap, getShippingGroupShippingAddressClassNameMap, getShippingTypeClassMap, getTransactionManager, initializeRelationship, initializeRelationship, initializeRelationship, initializeRelationship, initializeRelationship, initializeRelationship, initializeRelationship, invertBeanToItemMap, isAssignCatalogInCommerceItem, isNullAddress, isNullCreditCard, isOrderState, registerSynchronization, setAssignCatalogInCommerceItem, setBeanNameToItemDescriptorMap, setCatalogTools, setCommerceItemTypeClassMap, setCostCenterTypeClassMap, setCreateDefaultCostCenter, setCreateDefaultPaymentGroup, setCreateDefaultShippingGroup, setDefaultCommerceItemType, setDefaultCostCenterType, setDefaultHandlingInstructionType, setDefaultItemPriceInfoClass, setDefaultOrderPriceInfoClass, setDefaultOrderType, setDefaultPaymentGroupAddressType, setDefaultPaymentGroupType, setDefaultProfileType, setDefaultShippingGroupAddressType, setDefaultShippingGroupType, setDefaultShippingPriceInfoClass, setDefaultTaxPriceInfoClass, setGiftlistManager, setHandlingTypeClassMap, setInventoryManager, setItemDescriptorToBeanNameMap, setOrderFixedAmountAdjustmentType, setOrderItemDescriptorName, setOrderLookupService, setOrderRepository, setOrderTypeClassMap, setPaymentGroupBillingAddressClassNameMap, setPaymentTypeClassMap, setPipelineManager, setProfileRepository, setProfileTools, setRelationshipTypeClassMap, setShippingGroupShippingAddressClassNameMap, setShippingTypeClassMap, setTransactionManager
 
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

MSG_DUPLICATE_NICKNAME

public static final java.lang.String MSG_DUPLICATE_NICKNAME
Error keys

See Also:
Constant Field Values

MSG_ERROR_SHIPPING_ADDRESS

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

RESOURCE_NAME

public static final java.lang.String RESOURCE_NAME
Resource bundle name.

See Also:
Constant Field Values
Constructor Detail

StoreOrderTools

public StoreOrderTools()
Method Detail

setShippingGroupManager

public void setShippingGroupManager(atg.commerce.order.ShippingGroupManager pShippingGroupManager)
Parameters:
pShippingGroupManager - - a shipping group manager value.

getShippingGroupManager

public atg.commerce.order.ShippingGroupManager getShippingGroupManager()
Returns:
a shipping group manager value.

getGiftWrapCommerceItemType

public java.lang.String getGiftWrapCommerceItemType()
Returns:
gift wrap commerce item type.

setGiftWrapCommerceItemType

public void setGiftWrapCommerceItemType(java.lang.String pGiftWrapCommerceItemType)
Parameters:
pGiftWrapCommerceItemType - - gift wrap commerce item type.

getCommerceItemManager

public atg.commerce.order.CommerceItemManager getCommerceItemManager()
Returns:
commerce item manager.

setCommerceItemManager

public void setCommerceItemManager(atg.commerce.order.CommerceItemManager pCommerceItemManager)
Parameters:
pCommerceItemManager - - commerce item manager.

getIdGenerator

public atg.service.idgen.IdGenerator getIdGenerator()
Returns:
id generator.

setIdGenerator

public void setIdGenerator(atg.service.idgen.IdGenerator pIdGenerator)
Parameters:
pIdGenerator - - id genetator.

setPropertiesToCopyOnRegistration

public void setPropertiesToCopyOnRegistration(java.lang.String[] pPropertiesToCopyOnRegistration)
Parameters:
pPropertiesToCopyOnRegistration - - properties to copy on registration.

getPropertiesToCopyOnRegistration

public java.lang.String[] getPropertiesToCopyOnRegistration()
Returns:
properties to copy on registration.

getOmsOrderIdSpace

public java.lang.String getOmsOrderIdSpace()
Returns:
the name of the id space for OMS order ids.

setOmsOrderIdSpace

public void setOmsOrderIdSpace(java.lang.String pOmsOrderIdSpace)
Parameters:
pOmsOrderIdSpace - - the name of the id space for OMS order ids.

getTestSkuId

public java.lang.String getTestSkuId()
Returns:
the id of the test sku.

setTestSkuId

public void setTestSkuId(java.lang.String pTestSkuId)
Parameters:
pTestSkuId - - the id of the test sku.

getCatalogProperties

public StoreCatalogProperties getCatalogProperties()
Returns:
catalog properties.

setCatalogProperties

public void setCatalogProperties(StoreCatalogProperties pProperties)
Parameters:
pProperties - - catalog properties.

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Returns:
resource bundle.

getResourceBundle

public java.util.ResourceBundle getResourceBundle(java.util.Locale pLocale)
Parameters:
pLocale - the local of resource bundle
Returns:
resource bundle.

getCreditCard

public atg.commerce.order.CreditCard getCreditCard(atg.commerce.order.Order pOrder)
Returns the CreditCard payment group for the order. This is a utility method so form handlers can easily get the credit card payment group. This method returns the first payment group of type CreditCard. If multiple credit cards are supported, this method needs to be updated.

Parameters:
pOrder - - order to get credit card from
Returns:
credit card for this order

getStoreCreditPaymentGroups

public java.util.List getStoreCreditPaymentGroups(atg.commerce.order.Order pOrder)
Get the store credit payment groups from the order. This will return the actual payment groups, not the Claimable items.

Parameters:
pOrder - - the order
Returns:
list of store credit payment groups

copyShippingToBilling

public void copyShippingToBilling(atg.core.util.Address pAddress,
                                  atg.commerce.order.Order pOrder)
Copies an address to the credit card billing address. This method uses the superclass' copyAddress method, but first pulls the billing address from the credit card.

Parameters:
pAddress - - the address that is copied the order's credit card payment group address
pOrder - - order to copy address info

copyAddressToAddressBook

public boolean copyAddressToAddressBook(atg.repository.RepositoryItem pProfile,
                                        atg.core.util.Address pAddress,
                                        java.lang.String pNickname)
                                 throws atg.commerce.CommerceException
Get the profile from the order, and update the address book with the shipping group address.

Parameters:
pProfile - profile to copy address to
pAddress - the address to copy
pNickname - key for address book map
Returns:
true on success, false - otherwise
Throws:
atg.commerce.CommerceException - if error with copy

copyProfileAddressToCreditCard

public boolean copyProfileAddressToCreditCard(atg.repository.RepositoryItem pProfile,
                                              atg.commerce.order.Order pOrder,
                                              java.lang.String pNickname)
                                       throws atg.commerce.CommerceException
This method will get an address from the profile's address book, and set the credit card's billing address.

Parameters:
pProfile - to get address from
pOrder - the order to set the billing address on.
pNickname - the nickname of the Address book address
Returns:
true if success, false - otherwise
Throws:
atg.commerce.CommerceException - if error storing address

copyCreditCardToProfile

public boolean copyCreditCardToProfile(atg.repository.RepositoryItem pProfile,
                                       atg.commerce.order.Order pOrder,
                                       java.lang.String pCardNickname)
This method gets the credit card from the order, and adds it to the list of credit cards for this user. The nickname passed as a param is used to identify the card. The address to be used for this credit card passed in the pStoredAddressKey parameter. The OOB copyCreditCardToProfile method does not take a parameter for the nickname.

Parameters:
pOrder - order to find shipping address
pCardNickname - key for address book map
pProfile - profile to copy address to
Returns:
true if success, false - otherwise

createNewCreditCard

public atg.repository.MutableRepositoryItem createNewCreditCard(atg.repository.RepositoryItem pProfile)
                                                         throws atg.repository.RepositoryException
Creates a new credit card repository item for the given profile, but does not assign a billing address.

Parameters:
pProfile - - the customer profile
Returns:
The new credit card repository item.
Throws:
atg.repository.RepositoryException - if there was an error when creating the new repository item.

saveAddressToDefaultBilling

public boolean saveAddressToDefaultBilling(atg.core.util.Address pAddress,
                                           atg.repository.RepositoryItem pProfile)
Saves the address in the pAddress parameter to the default billing address of the user in the pProfile parameter. A new address item is created and stored in the default billing address, not just a reference to the incoming address.

Parameters:
pAddress - - address
pProfile - - profile
Returns:
true if successful, false if failure

createCreditCardNickname

public java.lang.String createCreditCardNickname(java.lang.Object pCreditCard)
This utility method creates an address nickname for the credit card address. All credit card nicknames are auto-generated in this manner. The type of card and the last 4 digits become the nickname.

As an example, Visa 4111111111111111 will be converted to Visa - 1111 for a nickname.

Parameters:
pCreditCard - - credit card to base nickname on
Returns:
card nickname based on type and last 4 digits of card

getShippingGroup

public atg.commerce.order.HardgoodShippingGroup getShippingGroup(atg.commerce.order.Order pOrder)
Returns the ShippingGroup. We only have one shipping group, and this method relies on this fact. It will throw a warning if an extra shipping group ever sneaks onto the order.

If multiple ship-tos are supported, then this method should not be used.

Parameters:
pOrder - - the order object
Returns:
the hardgood shipping group for this order

registerNewUserDuringCheckout

public boolean registerNewUserDuringCheckout(atg.userprofiling.Profile pProfile,
                                             atg.commerce.order.Order pOrder,
                                             java.util.Map pProfileValues)
                                      throws atg.commerce.CommerceException

This method will register a new user during the checkout process. There are a number of steps to register the user: Copy profile properties before registration. Create the hashed password Register the user Copy the previously transient profiles to the new user

This method copies the billing address first and last name to the profile. This is because we don't have any other information about the user at this point.

Parameters:
pProfile - - profile to register
pOrder - - order to pull registration info from
pProfileValues - - profile values
Returns:
true on success, false on failure
Throws:
atg.commerce.CommerceException - if errors occurs

generatePropertiesToCopy

protected java.util.Map generatePropertiesToCopy(java.lang.String[] pProperties,
                                                 atg.userprofiling.Profile pProfile)
This method is used when registering a new user. It will create a Map of property names to property values which will be set on the profile after registration.

Parameters:
pProperties - - the properties to copy
pProfile - - the profile to get the properties from
Returns:
map of property names to property values

assignPostRegistrationProperties

protected void assignPostRegistrationProperties(java.util.Map pPropertiesToCopy,
                                                atg.userprofiling.Profile pProfile)
This method copies the properties in the incoming Map to the profile item.

Parameters:
pPropertiesToCopy - - the map of properties to copy
pProfile - - profile to copy properties to

updateProfileInRepository

protected void updateProfileInRepository(atg.userprofiling.Profile pProfile)
                                  throws atg.repository.RepositoryException
Convenience method to update the profile item in the repository.

Parameters:
pProfile - - the profile to update
Throws:
atg.repository.RepositoryException - if update fails

assignOmsOrderId

public void assignOmsOrderId(StoreOrderImpl pOrder)
This method assigns an OMS order id, and sets it on the order.

By default, the omsOrderId is set same as the order's id.

Parameters:
pOrder - - the order parameter

getGiftWrapPrice

public double getGiftWrapPrice(StoreOrderImpl pOrder)
Gets the gift wrap price from the order. This is used by Fulfillment. Gift wrap is unusual because it is a SKU in the ATG system, but it is sent to SAP as an order header level price. Therefore, this method was added to retrieve the cost of gift wrap.

Parameters:
pOrder - - order to get GW price from
Returns:
price of gift wrap

isTestOrder

public boolean isTestOrder(StoreOrderImpl pOrder)
Checks to see if order is a Test order. If this order has other items in it, then a critical error is thrown, and the result is that it is not a test order. If the order has a single "test SKU", then it should have no other items.

Parameters:
pOrder - - order
Returns:
true if success, false - otherwise

saveAddressToAddressBook

public void saveAddressToAddressBook(atg.repository.RepositoryItem pProfile,
                                     atg.core.util.Address pAddress,
                                     java.lang.String pNickName)
                              throws atg.commerce.CommerceException
Saves the address to address book and makes it the default shipping address if it hasn't already been set.

Parameters:
pProfile - - profile
pAddress - - address
pNickName - - nickname
Throws:
atg.commerce.CommerceException - if commerce error occurs

saveDefaultShippingMethod

public void saveDefaultShippingMethod(atg.repository.RepositoryItem pProfile,
                                      java.lang.String pShippingMethod)
Sets the default shipping method for a profile, but only if it hasn't been set already.

Parameters:
pProfile - - profile
pShippingMethod - - shipping method

validateCreditCardAuthorizationNumber

public boolean validateCreditCardAuthorizationNumber(java.lang.String pAuthNumber)
Verifies that the auth number is valued and a number.

Parameters:
pAuthNumber - - authentication number
Returns:
true if auth number is a valid, false - otherwise

setCreditCardVerificationNumber

public void setCreditCardVerificationNumber(atg.commerce.order.Order pOrder,
                                            java.lang.String pVerificationNumber)
Sets the verification number on the order's credit card payment group.

Parameters:
pOrder - - order
pVerificationNumber - - verification number

getCreditCardVerificationNumberFromCard

public java.lang.String getCreditCardVerificationNumberFromCard(atg.commerce.order.Order pOrder)
Gets the verification number from the order's credit card payment group.

Parameters:
pOrder - - order
Returns:
the verification number from the order's credit card payment group