com.ibm.commerce.tools.optools.order.commands
Class CSROrderProcessCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.ControllerCommandImpl
                    |
                    +--com.ibm.commerce.tools.command.ToolsControllerCommandImpl
                          |
                          +--com.ibm.commerce.tools.optools.order.commands.CSRBaseControllerCommandImpl
                                |
                                +--com.ibm.commerce.tools.optools.order.commands.CSROrderProcessCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, CSROrderProcessCmd, ECCommand, ECTargetableCommand, ToolsControllerCommand

public class CSROrderProcessCmdImpl
extends CSRBaseControllerCommandImpl
implements CSROrderProcessCmd

This is the default implementation of the CSROrderProcessCmd command.

This command calls the following Commands:

This command uses the following AccessBeans:

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          IBM copyright notice field.
static java.lang.String NOTEBOOK_URL
          The return url for a notebook widget.
static java.lang.String WIZARD_URL
          The return url for a wizard widget.
 
Fields inherited from class com.ibm.commerce.command. ControllerCommandImpl
requestProperties, responseProperties, retriable, viewReqProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.tools.optools.order.commands. CSROrderProcessCmd
defaultCommandClassName, NAME
 
Constructor Summary
CSROrderProcessCmdImpl()
           
 
Method Summary
protected  void addComments()
          This method generates comments for order(s) and prepares email for notification.
protected  void checkOrderAdjustment()
          Checks if order level adjustments are positive.
protected  void exceptionUtil( TypedProperty prop, java.lang.Exception ex, java.lang.String methodName, java.lang.String cmdName, java.lang.String errMsg)
          Common exception code for this command.
protected  void executeBackupOrderDelete()
          Deletes backup order in database.
protected  void executeCSROrderAdjustmentUpdate()
          This method calls CSROrderAdjustmentUpdateCmd to reprepare the order(s) if there are some manual adjustments.
protected  void executeCSROrderPrepare()
          This method calls CSROrderPrepareCmd to prepare order(s).
protected  void executeOrderProcess(java.lang.String orderId, java.lang.String billingAddressId, java.util.Hashtable payment)
          This method calls OrderProcessCmd to complete an order.
 java.lang.String getAdminId()
          Returns the administrator's ID.
 java.lang.String getBackupOrderId()
          Returns backup order ID.
 java.util.Hashtable getComment()
          Returns comment as a Hashtable.
 java.lang.String getCustomerId()
          Returns customer ID.
 java.lang.String getEditOrderInfo()
          Returns "true" if it is called from an edit order notebook.
 java.lang.String getFirstBillingAddressId()
          Returns first billing address ID.
 java.lang.String getFirstDirtyBit()
          Returns the first order dirty status.
 java.lang.String getFirstOrderId()
          Returns first order ID.
 java.util.Hashtable getFirstPayment()
          Returns the payment information for the first order as a Hashtable.
 java.util.Hashtable getNLS()
          Returns the properties containing all translatable messages for this command.
 java.lang.String getNotifyMerchant()
          Gets notify merchant option.
 java.lang.String getNotifyOrderSubmitted()
          Gets order submitted notification option.
 java.lang.String getNotifyShopper()
          Gets notify customer option.
  CommandContext getOrgCmdContext()
          Returns the original commandContext (administrator's command context).
 java.lang.Integer getOrgLangId()
          Returns original language ID.
 java.util.Locale getOrgLocale()
          Returns original locale.
  TypedProperty getOrgReqProperties()
          Returns original request properties.
 java.lang.String getRedirectURL()
          Returns the redirect URL that is to be executed after this controller command terminates.
  AccessVector getResources()
          Gets the access vector accessed by this command.
 java.lang.String getSecondBillingAddressId()
          Returns second billing address ID.
 java.lang.String getSecondOrderId()
          Returns second order ID.
 java.util.Hashtable getSecondPayment()
          Returns the payment information for the second order as a Hashtable.
protected  java.lang.String getSuccessMsg(java.util.Hashtable orderMgmtNLS)
          Returns final success message.
 java.lang.String getXMLFile()
          Returns XML file.
 boolean isBackupOrderDeleteError()
          Returns error flag for deleting backup order error.
 boolean isEmailError()
          Retures error flag for email comment error.
protected  boolean isEmptyOrder(java.lang.String orderRefNum)
          Determines if an order has order items or not.
 boolean isFirstOrderExist()
          Returns true if the first order exits.
 boolean isSecondOrderExist()
          Returns true if the Second order exits.
 void performExecute()
          This method performs the execution for process the new order(s) and cancel old order if neccessary.
protected  void removePrevPayment()
          When editing an order, remove the original payment for the first order.
protected  void setAdminId(java.lang.String newAdminId)
          Set administrator's ID.
protected  void setBackupOrderDeleteError(boolean newBackupOrderDeleteError)
          Set setBackupOrderDeleteError flag.
protected  void setBackupOrderId(java.lang.String newBackupOrderId)
          Sets backup order ID.
protected  void setComment(java.util.Hashtable newComment)
          Sets comment.
protected  void setCustomerId(java.lang.String newCustomerId)
          Sets customer ID.
protected  void setEditOrderInfo(java.lang.String newEditOrderInfo)
          Sets "true" if it is edit order info notebook.
protected  void setEmailError(boolean newEmailError)
          Sets "true" if there is an email error.
protected  void setFirstBillingAddressId(java.lang.String newBillingAddressId)
          Sets first billing address ID.
protected  void setFirstDirtyBit(java.lang.String newFirstDirtyBit)
          Sets "true" if there are some adjustments in the first order, "false" if not.
protected  void setFirstOrderExist(boolean newFirstOrderExist)
          Sets if there are some order items in first order.
protected  void setFirstOrderId(java.lang.String newFirstOrderId)
          Sets first order ID.
protected  void setFirstPayment(java.util.Hashtable newPayment)
          Sets first payment information.
protected  void setIsSecondOrderExist(boolean newIsSecondOrderExist)
          Sets if there are some order items in second order.
protected  void setNLS(java.util.Hashtable newNLS)
          Sets NLS properties.
 void setNotifyMerchant(java.lang.String notifyMerchant)
          Sets notify merchant option.
 void setNotifyOrderSubmitted(java.lang.String notifyOrderSubmitted)
          Sets order submitted notification option.
 void setNotifyShopper(java.lang.String notifyShopper)
          Sets notify customer option.
protected  void setOrgCmdContext( CommandContext newOrgCmdContext)
          Sets original commandContext.
protected  void setOrgLangId(java.lang.Integer newOrgLangId)
          Sets the original language ID.
protected  void setOrgLocale(java.util.Locale newOrgLocale)
          Sets original locale.
protected  void setOrgReqProperties( TypedProperty newOrgReqProperties)
          Sets original request properties.
protected  void setRedirectURL(java.lang.String newRedirectURL)
          Sets redirect URL.
protected  void setSecondBillingAddressId(java.lang.String newBillingAddressId)
          Sets second billing address ID.
protected  void setSecondOrderExist(boolean newSecondOrderExist)
          Sets second order exist flag.
protected  void setSecondOrderId(java.lang.String newSecondOrderId)
          Sets second order ID.
protected  void setSecondPayment(java.util.Hashtable newPayment)
          Sets second payment information.
protected  void setSuccessMsg(java.lang.String newSuccessMsg)
          Sets final success message.
protected  void setXMLFile(java.lang.String newXMLFile)
          Sets XML file.
 void validateParameters()
          This method gets XMLObject from the GUI Notebook or Wizard and get ready to parse it.
 
Methods inherited from class com.ibm.commerce.tools.optools.order.commands. CSRBaseControllerCommandImpl
callPreCommands, findCmdInterfaceName, getIfExePreCmdChains, getPreCmdChain, setIfExePreCmdChains, setPreCmdChain
 
Methods inherited from class com.ibm.commerce.tools.command. ToolsControllerCommandImpl
getViewInputProperties, setRequestProperties
 
Methods inherited from class com.ibm.commerce.command. ControllerCommandImpl
checkPermission, fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResourceOwners, getResponseProperties, getRetriable, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setResponseProperties, setRetriable, setViewInputProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command. ControllerCommand
checkPermission, execute, getGeneric, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setGeneric, setRequestProperties, setRetriable, setViewInputProperties
 
Methods inherited from interface com.ibm.commerce.command. AccCommand
accessControlCheck, getAccCheck, getForUserId, getResourceOwners, setAccCheck, setForUserId, setOwner
 
Methods inherited from interface com.ibm.commerce.command. ECCommand
checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 

Field Detail
public static final java.lang.String COPYRIGHT
IBM copyright notice field.
See Also:
Constant Field Values

NOTEBOOK_URL

public static final java.lang.String NOTEBOOK_URL
The return url for a notebook widget.
See Also:
Constant Field Values

WIZARD_URL

public static final java.lang.String WIZARD_URL
The return url for a wizard widget.
See Also:
Constant Field Values
Constructor Detail

CSROrderProcessCmdImpl

public CSROrderProcessCmdImpl()
Method Detail

addComments

protected void addComments()
                    throws ECException
This method generates comments for order(s) and prepares email for notification.
Throws:
ECApplicationException - if fails to add comments or email notification.
ECException

checkOrderAdjustment

protected void checkOrderAdjustment()
                             throws ECApplicationException
Checks if order level adjustments are positive.
Throws:
ECApplicationException - if tax, shipping, shipping tax and grand total of the order is less than zero.

exceptionUtil

protected void exceptionUtil(TypedProperty prop,
                             java.lang.Exception ex,
                             java.lang.String methodName,
                             java.lang.String cmdName,
                             java.lang.String errMsg)
                      throws ECApplicationException
Common exception code for this command.
Parameters:
prop - The response typed property.
ex - The catched exception.
methodName - The name of the method with exception.
cmdName - The name of the command.
errMsg - The translated error message string.
Throws:
ECApplicationException - The exception to be sent to the error handling view.

executeBackupOrderDelete

protected void executeBackupOrderDelete()
                                 throws java.lang.Exception
Deletes backup order in database.
Throws:
java.lang.Exception - if order can not be deleted.

executeCSROrderAdjustmentUpdate

protected void executeCSROrderAdjustmentUpdate()
                                        throws ECException
This method calls CSROrderAdjustmentUpdateCmd to reprepare the order(s) if there are some manual adjustments.
Throws:
ECException - if adjustment can not be applied.

executeCSROrderPrepare

protected void executeCSROrderPrepare()
                               throws ECException
This method calls CSROrderPrepareCmd to prepare order(s).
Throws:
ECException - if unable to prepare order.

executeOrderProcess

protected void executeOrderProcess(java.lang.String orderId,
                                   java.lang.String billingAddressId,
                                   java.util.Hashtable payment)
                            throws ECException
This method calls OrderProcessCmd to complete an order.
Parameters:
orderId - The order ID to process.
billingAddressId - The address ID used for this order.
payment - The payment name-value pairs for this order.
Throws:
ECException - if unable to process order.

getAdminId

public java.lang.String getAdminId()
Returns the administrator's ID.
Returns:
The administrator's ID that is performing the action on behalf of the customer.

getBackupOrderId

public java.lang.String getBackupOrderId()
Returns backup order ID.
Returns:
The backup order ID created for this order.

getComment

public java.util.Hashtable getComment()
Returns comment as a Hashtable.
Returns:
The comment name-value pair with the comment details.

getCustomerId

public java.lang.String getCustomerId()
Returns customer ID.
Returns:
The customer's ID.

getEditOrderInfo

public java.lang.String getEditOrderInfo()
Returns "true" if it is called from an edit order notebook.
Returns:
"true" if it is called from an edit order notebook; "false" otherwise.

getFirstBillingAddressId

public java.lang.String getFirstBillingAddressId()
Returns first billing address ID.
Returns:
The billing address ID for the first order.

getFirstDirtyBit

public java.lang.String getFirstDirtyBit()
Returns the first order dirty status.
Returns:
Return String "true" if there are some adjustments for the first order, "false" if not.

getFirstOrderId

public java.lang.String getFirstOrderId()
Returns first order ID.
Returns:
The order ID of the first order.

getFirstPayment

public java.util.Hashtable getFirstPayment()
Returns the payment information for the first order as a Hashtable.
Returns:
The name-value pairs containing the payment information for the first order.

getNLS

public java.util.Hashtable getNLS()
Returns the properties containing all translatable messages for this command.
Returns:
Name value pairs of translatable messages.

getOrgCmdContext

public CommandContext getOrgCmdContext()
Returns the original commandContext (administrator's command context).
Returns:
The original command context when calling this command.

getOrgLangId

public java.lang.Integer getOrgLangId()
Returns original language ID.
Returns:
The original language ID.

getOrgLocale

public java.util.Locale getOrgLocale()
Returns original locale.
Returns:
The original locale.

getOrgReqProperties

public TypedProperty getOrgReqProperties()
Returns original request properties.
Returns:
The original request properties.

getRedirectURL

public java.lang.String getRedirectURL()
Returns the redirect URL that is to be executed after this controller command terminates.
Returns:
The name of the view to be redirected to.

getResources

public AccessVector getResources()
                          throws ECException
Gets the access vector accessed by this command. The default implementation returns null indicating that no protectable resource is accessed by this command.
Specified by:
getResources in interface ECCommand
Overrides:
getResources in class AbstractECTargetableCommand
Returns:
The vector of resource action pairs
Throws:
ECException - If the resource can not be retrieved.

getSecondBillingAddressId

public java.lang.String getSecondBillingAddressId()
Returns second billing address ID.
Returns:
The billing address ID for the second order.

getSecondOrderId

public java.lang.String getSecondOrderId()
Returns second order ID.
Returns:
The order ID of the second order.

getSecondPayment

public java.util.Hashtable getSecondPayment()
Returns the payment information for the second order as a Hashtable.
Returns:
The name-value pairs containing the payment information for the second order.

getSuccessMsg

protected java.lang.String getSuccessMsg(java.util.Hashtable orderMgmtNLS)
Returns final success message.
Parameters:
orderMgmtNLS - The hashtable with the translated messages.
Returns:
The correct success message to be used for the order(s).

getXMLFile

public java.lang.String getXMLFile()
Returns XML file.
Returns:
The entire XML file.

isBackupOrderDeleteError

public boolean isBackupOrderDeleteError()
Returns error flag for deleting backup order error.
Returns:
true if there is an error to delete a backup order.

isEmailError

public boolean isEmailError()
Retures error flag for email comment error.
Returns:
true if there is an email error.

isEmptyOrder

protected boolean isEmptyOrder(java.lang.String orderRefNum)
                        throws java.lang.Exception
Determines if an order has order items or not.
Parameters:
orderRefNum - An order ID.
Returns:
Return true if there is no order item in the order.
Throws:
java.lang.Exception - if unable to instantiate order accessbean.

isFirstOrderExist

public boolean isFirstOrderExist()
Returns true if the first order exits.
Returns:
Return true if the first order exists (i.e. has order items).

isSecondOrderExist

public boolean isSecondOrderExist()
Returns true if the Second order exits.
Returns:
Return true if the second order exists (i.e. has order items).

performExecute

public void performExecute()
                    throws ECException
This method performs the execution for process the new order(s) and cancel old order if neccessary.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException - if unable to process the orders.

removePrevPayment

protected void removePrevPayment()
                          throws ECApplicationException
When editing an order, remove the original payment for the first order.
Throws:
ECApplicationException - if unable to cancel payment.

setAdminId

protected void setAdminId(java.lang.String newAdminId)
Set administrator's ID.
Parameters:
newAdminId - The administrator's ID.

setBackupOrderDeleteError

protected void setBackupOrderDeleteError(boolean newBackupOrderDeleteError)
Set setBackupOrderDeleteError flag.
Parameters:
newBackupOrderDeleteError - Set true if there is an error to delete a backup order, false if no delete error.

setBackupOrderId

protected void setBackupOrderId(java.lang.String newBackupOrderId)
Sets backup order ID.
Parameters:
newBackupOrderId - The backup order ID for the first order.

setComment

protected void setComment(java.util.Hashtable newComment)
Sets comment.
Parameters:
newComment - The hashtable containing the comment details.

setCustomerId

protected void setCustomerId(java.lang.String newCustomerId)
Sets customer ID.
Parameters:
newCustomerId - The customer ID.

setEditOrderInfo

protected void setEditOrderInfo(java.lang.String newEditOrderInfo)
Sets "true" if it is edit order info notebook.
Parameters:
newEditOrderInfo -

setEmailError

protected void setEmailError(boolean newEmailError)
Sets "true" if there is an email error.
Parameters:
newEmailError - Set true if there is an email error, false if no email error.

setFirstBillingAddressId

protected void setFirstBillingAddressId(java.lang.String newBillingAddressId)
Sets first billing address ID.
Parameters:
newBillingAddressId - The billing address ID of the first order.

setFirstDirtyBit

protected void setFirstDirtyBit(java.lang.String newFirstDirtyBit)
Sets "true" if there are some adjustments in the first order, "false" if not.
Parameters:
newFirstDirtyBit -

setFirstOrderExist

protected void setFirstOrderExist(boolean newFirstOrderExist)
Sets if there are some order items in first order.
Parameters:
newFirstOrderExist - true if there are some order items in first order.

setFirstOrderId

protected void setFirstOrderId(java.lang.String newFirstOrderId)
Sets first order ID.
Parameters:
newFirstOrderId - The first order ID.

setFirstPayment

protected void setFirstPayment(java.util.Hashtable newPayment)
Sets first payment information.
Parameters:
newPayment - The name-value pairs with the first order payment information.

setIsSecondOrderExist

protected void setIsSecondOrderExist(boolean newIsSecondOrderExist)
Sets if there are some order items in second order.
Parameters:
newIsSecondOrderExist - true if there are some order items in second order.

setNLS

protected void setNLS(java.util.Hashtable newNLS)
Sets NLS properties.
Parameters:
newNLS - The name-value pairs containing the messages to be used by this command.

setOrgCmdContext

protected void setOrgCmdContext(CommandContext newOrgCmdContext)
Sets original commandContext.
Parameters:
newOrgCmdContext - The original command context (admin command context).

setOrgLangId

protected void setOrgLangId(java.lang.Integer newOrgLangId)
Sets the original language ID.
Parameters:
newOrgLangId - The original language ID.

setOrgLocale

protected void setOrgLocale(java.util.Locale newOrgLocale)
Sets original locale.
Parameters:
newOrgLocale - The locale from the original command context.

setOrgReqProperties

protected void setOrgReqProperties(TypedProperty newOrgReqProperties)
Sets original request properties.
Parameters:
newOrgReqProperties - The original request properties.

setRedirectURL

protected void setRedirectURL(java.lang.String newRedirectURL)
Sets redirect URL.
Parameters:
newRedirectURL - The name of the redirect page.

setSecondBillingAddressId

protected void setSecondBillingAddressId(java.lang.String newBillingAddressId)
Sets second billing address ID.
Parameters:
newBillingAddressId - The billing address ID of the second order.

setSecondOrderExist

protected void setSecondOrderExist(boolean newSecondOrderExist)
Sets second order exist flag.
Parameters:
newSecondOrderExist - Set true if there are some order items in second order.

setSecondOrderId

protected void setSecondOrderId(java.lang.String newSecondOrderId)
Sets second order ID.
Parameters:
newSecondOrderId - The second order ID.

setSecondPayment

protected void setSecondPayment(java.util.Hashtable newPayment)
Sets second payment information.
Parameters:
newPayment - The name-value pairs with the second order payment information.

setSuccessMsg

protected void setSuccessMsg(java.lang.String newSuccessMsg)
Sets final success message.
Parameters:
newSuccessMsg - The translated success message for the order(s).

setXMLFile

protected void setXMLFile(java.lang.String newXMLFile)
Sets XML file.
Parameters:
newXMLFile - The XML file used.

validateParameters

public void validateParameters()
                        throws ECApplicationException
This method gets XMLObject from the GUI Notebook or Wizard and get ready to parse it. It also gets the success redirect URL.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class CSRBaseControllerCommandImpl
Throws:
ECException - If cannot parse the XMLObject, throw ECApplicationException
ECApplicationException

getNotifyMerchant

public java.lang.String getNotifyMerchant()
Gets notify merchant option.
Returns:
notify merchant option.

setNotifyMerchant

public void setNotifyMerchant(java.lang.String notifyMerchant)
Sets notify merchant option.
Parameters:
notifyMerchant - "1" to notify merchant; "0" not to notif merchant.

getNotifyShopper

public java.lang.String getNotifyShopper()
Gets notify customer option.
Returns:
notify shopper option.

setNotifyShopper

public void setNotifyShopper(java.lang.String notifyShopper)
Sets notify customer option.
Parameters:
notifyShopper - "1" to notify customer; "0" not to notif customer.

getNotifyOrderSubmitted

public java.lang.String getNotifyOrderSubmitted()
Gets order submitted notification option.
Returns:
Returns a java.lang.String

setNotifyOrderSubmitted

public void setNotifyOrderSubmitted(java.lang.String notifyOrderSubmitted)
Sets order submitted notification option.
Parameters:
notifyOrderSubmitted - "1" to notify order submission; "0" not to notify order submission.