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

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, Protectable, ToolsControllerCommand

public class CSROrderProcessCmdImpl
extends CSRBaseControllerCommandImpl
implements CSROrderProcessCmd

 If the process is creating order(finish action in the Place Order wizard), this 
 command will first do the adjustments by calling CSROrderAdustmentUpdateCmd if 
 applicable, then process the pending order(s) and complete the order(s) by calling 
 OrderProcessCmd, finally add comments. 

 If the process is editing old order(ok button in the Change Order notebook), this 
 command will do the order prepare by calling CSROrderPrepareCmd if it's needed, 
 then process the order and complete the original Order by calling OrderProcessCmd,
 finally add comments and delete the backup order.
 


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String NOTEBOOK_URL
           
static java.lang.String WIZARD_URL
           
 
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()
          Check 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()
          Delete 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 call 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()
          Return the administrator's ID.
 java.lang.String getBackupOrderId()
          Return backup order ID.
 java.util.Hashtable getComment()
          Return comment as a Hashtable.
 java.lang.String getCustomerId()
          Return customer ID.
 java.lang.String getEditOrderInfo()
           
 java.lang.String getFirstBillingAddressId()
          Return first billing address ID.
 java.lang.String getFirstDirtyBit()
           
 java.lang.String getFirstOrderId()
          Return first order ID.
 java.util.Hashtable getFirstPayment()
          Return the payment information for the first order as a Hashtable.
 java.util.Hashtable getNLS()
          Return the properties containing all translatable messages for this command.
 CommandContext getOrgCmdContext()
          Returns the original commandContext (administrator's command context).
 java.lang.Integer getOrgLangId()
          Return original language ID.
 java.util.Locale getOrgLocale()
          Return original locale.
 TypedProperty getOrgReqProperties()
          Return 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()
          Return second billing address ID.
 java.lang.String getSecondOrderId()
          Return second order ID.
 java.util.Hashtable getSecondPayment()
          Return the payment information for the second order as a Hashtable.
protected  java.lang.String getSuccessMsg(java.util.Hashtable orderMgmtNLS)
          Return final success message.
 java.lang.String getXMLFile()
          Return XML file.
 boolean isBackupOrderDeleteError()
           
 boolean isEmailError()
           
protected  boolean isEmptyOrder(java.lang.String orderRefNum)
          Determines if an order has order items or not.
 boolean isFirstOrderExist()
           
 boolean isSecondOrderExist()
           
 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)
           
protected  void setBackupOrderId(java.lang.String newBackupOrderId)
          Set backup order ID.
protected  void setComment(java.util.Hashtable newComment)
          Set comment.
protected  void setCustomerId(java.lang.String newCustomerId)
          Set customer ID.
protected  void setEditOrderInfo(java.lang.String newEditOrderInfo)
          Set "true" if it is edit order info notebook.
protected  void setEmailError(boolean newEmailError)
           
protected  void setFirstBillingAddressId(java.lang.String newBillingAddressId)
          Set first billing address ID.
protected  void setFirstDirtyBit(java.lang.String newFirstDirtyBit)
          Set "true" if there are some adjustments in the first order, "false" if not.
protected  void setFirstOrderExist(boolean newFirstOrderExist)
           
protected  void setFirstOrderId(java.lang.String newFirstOrderId)
          Set first order ID.
protected  void setFirstPayment(java.util.Hashtable newPayment)
          Set first payment information.
protected  void setIsSecondOrderExist(boolean newIsSecondOrderExist)
           
protected  void setNLS(java.util.Hashtable newNLS)
          Set NLS properties.
protected  void setOrgCmdContext(CommandContext newOrgCmdContext)
          Set original commandContext.
protected  void setOrgLangId(java.lang.Integer newOrgLangId)
          Set the original language ID.
protected  void setOrgLocale(java.util.Locale newOrgLocale)
          Set original locale.
protected  void setOrgReqProperties(TypedProperty newOrgReqProperties)
          Set original request properties.
protected  void setRedirectURL(java.lang.String newRedirectURL)
          Set redirect URL.
protected  void setSecondBillingAddressId(java.lang.String newBillingAddressId)
          Set second billing address ID.
protected  void setSecondOrderExist(boolean newSecondOrderExist)
           
protected  void setSecondOrderId(java.lang.String newSecondOrderId)
          Set second order ID.
protected  void setSecondPayment(java.util.Hashtable newPayment)
          Set second payment information.
protected  void setSuccessMsg(java.lang.String newSuccessMsg)
          Set final success message.
protected  void setXMLFile(java.lang.String newXMLFile)
          Set 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
fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setResponseProperties, setRetriable, setViewInputProperties
 
Methods inherited from class com.ibm.commerce.command.AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 
Methods inherited from interface com.ibm.commerce.command.ControllerCommand
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, setAccCheck, setForUserId, setOwner
 
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setDefaultProperties
 
Methods inherited from interface com.ibm.commerce.security.Protectable
fulfills, getOwner
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT

NOTEBOOK_URL

public static final java.lang.String NOTEBOOK_URL

WIZARD_URL

public static final java.lang.String WIZARD_URL
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 -  

checkOrderAdjustment

protected void checkOrderAdjustment()
                             throws ECApplicationException
Check if order level adjustments are positive.
Throws:
ECApplicationException -  

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
Delete backup order in database.
Throws:
java.lang.Exception -  

executeCSROrderAdjustmentUpdate

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

executeCSROrderPrepare

protected void executeCSROrderPrepare()
                               throws ECException
This method call CSROrderPrepareCmd to prepare order(s).
Throws:
ECException - The exception description.

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 -  

getAdminId

public java.lang.String getAdminId()
Return 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()
Return backup order ID.
Returns:
The backup order ID created for this order.

getComment

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

getCustomerId

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

getEditOrderInfo

public java.lang.String getEditOrderInfo()
Returns:
Return "true" if it's a notebook for edit order info. Return "false" otherwise.

getFirstBillingAddressId

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

getFirstDirtyBit

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

getFirstOrderId

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

getFirstPayment

public java.util.Hashtable getFirstPayment()
Return 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()
Return 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()
Return original language ID.
Returns:
The original language ID.

getOrgLocale

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

getOrgReqProperties

public TypedProperty getOrgReqProperties()
Return 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:
A vector of resource action pairs

getSecondBillingAddressId

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

getSecondOrderId

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

getSecondPayment

public java.util.Hashtable getSecondPayment()
Return 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)
Return 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()
Return XML file.
Returns:
The entire XML file.

isBackupOrderDeleteError

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

isEmailError

public boolean isEmailError()
Returns:
Return 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 - The exception description.

isFirstOrderExist

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

isSecondOrderExist

public boolean isSecondOrderExist()
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 -  

removePrevPayment

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

setAdminId

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

setBackupOrderDeleteError

protected void setBackupOrderDeleteError(boolean newBackupOrderDeleteError)
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)
Set backup order ID.
Parameters:
newBackupOrderId - The backup order ID for the first order.

setComment

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

setCustomerId

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

setEditOrderInfo

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

setEmailError

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

setFirstBillingAddressId

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

setFirstDirtyBit

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

setFirstOrderExist

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

setFirstOrderId

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

setFirstPayment

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

setIsSecondOrderExist

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

setNLS

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

setOrgCmdContext

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

setOrgLangId

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

setOrgLocale

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

setOrgReqProperties

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

setRedirectURL

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

setSecondBillingAddressId

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

setSecondOrderExist

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

setSecondOrderId

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

setSecondPayment

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

setSuccessMsg

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

setXMLFile

protected void setXMLFile(java.lang.String newXMLFile)
Set 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