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

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.CSROrderRollBackCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, CSROrderRollBackCmd, ECCommand, ECTargetableCommand, ToolsControllerCommand

public class CSROrderRollBackCmdImpl
extends ToolsControllerCommandImpl
implements CSROrderRollBackCmd

This is the default implementation of the CSROrderProcessCmd command.

Behavior

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 ERRTASK_NAME
          Error handling viewname for this command.
static java.lang.String NOTEBOOK_URL
          The return url for a notebook 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. CSROrderRollBackCmd
defaultCommandClassName, NAME
 
Constructor Summary
CSROrderRollBackCmdImpl()
           
 
Method Summary
protected  java.util.Vector copyArrayToVector( OrderItemDataBean[] orderItemsArray)
          Creates a vector from a array.
protected  TypedProperty exceptionUtil( TypedProperty prop, java.lang.Exception ex, java.lang.String methodName, java.lang.String cmdName)
          This method sets up the response property when an exception occurs.
protected  void executeOrderCancelCmd(java.lang.String orderId)
          Calls the AdminOrderCancelCmd to cancel an order.
protected  void executeOrderDelete(java.lang.String orderId)
          Delete an order in database.
protected  void executeOrderItemAdd( OrderItemDataBean theOrderItem)
          Call OrderItemAddCmd to add an order item.
protected  void executeOrderItemDelete( OrderItemDataBean theOrderItem)
          Call OrderItemDeleteCmd to delete an order item.
protected  void executeOrderItemUpdate( OrderItemDataBean changedOrderItem, OrderItemDataBean originalOrderItem)
          Call OrderItemUpdateCmd to update an order item by using the values (cat entry ID, quantity, shipping mode ID, shipping address ID, contract ID) from the original order items.
protected  void executeOrderPrepare(java.lang.String orderId)
          Call OrderPrepareCmd to prepare an order.
protected  void executeOrderProcess(java.lang.String orderId, java.lang.String payInfoOrderId)
          This method calls OrderProcessCmd to complete an order by using the payment info from the backup order.
protected  void executeSetOrderLevelAdjustmentCmd(java.math.BigDecimal orderLevelMenuAdjustment, java.math.BigDecimal shippingCharge)
          This method call SetOrderLevelParameterCmd to set the shipping charge and menu adjustments.
protected   OrderDataBean getBackupOrder()
          Returns the backup order.
 java.lang.String getBackupOrderId()
          Returns backup order ID.
protected  java.util.Vector getBackupOrderItems()
          Returns the order items of the backup order.
 java.lang.String getCustomerId()
          Returns customer ID.
protected   OrderDataBean getFirstOrder()
          Returns the first order.
 java.lang.String getFirstOrderId()
          Returns first order ID.
protected  java.util.Vector getFirstOrderItems()
          Returns the order items of the first order.
 java.util.Hashtable getNLS()
          Returns NLS properties.
  CommandContext getOrgCmdContext()
          Returns original 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 getOrigOrderCouponIds()
          Returns the string of coupons IDs used in the original order.
 java.math.BigDecimal getOrigOrderGrandTotal()
          Returns original order grand total.
 java.lang.String getOrigOrderLastUpdate()
          Returns the origOrderLastUpdate.
 java.math.BigDecimal getOrigOrderLevelMenuAdjustment()
          Returns original order level menu adjustment.
 java.lang.String getOrigOrderStatus()
          Returns the origOrderStatus.
 java.math.BigDecimal getOrigShippingCharge()
          Returns the original shipping charge.
 java.lang.String getRedirectURL()
          Returns redirect URL.
  AccessVector getResources()
          Gets the access vector accessed by this command.
 java.lang.String getSecondOrderId()
          Returns the ID of the second order.
 java.lang.String getXMLFile()
          Returns XML file.
protected  boolean ifAttributeChanged(java.math.BigDecimal changedAttr, java.math.BigDecimal origAttr)
          Compares the values of two attributes with type BigDeciaml.
protected  boolean ifAttributeChanged(java.lang.String changedAttr, java.lang.String origAttr)
          Compares the values of two attributes with type String.
protected  boolean ifOrderItemChanged( OrderItemDataBean changedOrderItem, OrderItemDataBean originalOrderItem)
          Compares order items.
protected   OrderDataBean initOrderBean(java.lang.String orderId)
          Initializes an OrderDataBean.
 void performExecute()
          This method performs rollback changes done to the first order from the data in the backup order.
protected  void removeOrderItems(java.util.Vector orderItems)
          Deletes all the order items in the order item list.
protected  void removePrevPayment(java.lang.String orderId)
          Removes original payment from the order.
protected  void rollbackDeletedOrUpdatedOrderItems( OrderDataBean changedOrder, java.util.Vector changedOrderItems, OrderDataBean originalOrder, java.util.Vector originalOrderItems)
          Add or update the order items in the changedOrder so that it will have the same order items as the originalOrder.
protected  void rollbackOrderAdjustment( OrderDataBean changedOrder)
          Sets the shipping charge and the order level menu adjustments of the changed order to the original values.
protected  void setBackupOrder( OrderDataBean newOrder)
          Sets backup order.
protected  void setBackupOrderId(java.lang.String newBackupOrderId)
          Sets backup order ID.
protected  void setBackupOrderItems(java.util.Vector newOrderItems)
          Sets order items of the backup order.
protected  void setCustomerId(java.lang.String newCustomerId)
          Sets customer ID.
protected  void setFirstOrder( OrderDataBean newOrder)
          Sets first order.
protected  void setFirstOrderId(java.lang.String newFirstOrderId)
          Sets first order ID.
protected  void setFirstOrderItems(java.util.Vector newOrderItems)
          Sets order items of the first order.
protected  void setNLS(java.util.Hashtable newNLS)
          Sets NLS properties.
protected  void setOrgCmdContext( CommandContext newOrgCmdContext)
          Sets original command context.
protected  void setOrgLangId(java.lang.Integer newOrgLangId)
          Sets original language ID.
protected  void setOrgLocale(java.util.Locale newOrgLocale)
          Sets original Locale.
protected  void setOrgReqProperties( TypedProperty newOrgReqProperties)
          Sets original request properties.
 void setOrigOrderCouponIds(java.lang.String newOrigOrderCouponIds)
          Sets the list of coupons used in the original order
 void setOrigOrderLastUpdate(java.lang.String inOrigOrderLastUpdate)
          Sets the origOrderLastUpdate.
 void setOrigOrderLevelMenuAdjustment(java.lang.String tmpValue)
          Sets original order level menu adjustment.
 void setOrigOrderStatus(java.lang.String inOrigOrderStatus)
          Sets the origOrderStatus.
 void setOrigShippingCharge(java.lang.String tmpValue)
          Sets original order shipping charge.
protected  void setRedirectURL(java.lang.String newRedirectURL)
          Sets redirect URL.
protected  void setSecondOrderId(java.lang.String newSecondOrderId)
          Sets second order ID.
protected  void setXMLFile(java.lang.String newXMLFile)
          Sets XML file.
 void validateParameters()
          Sets the NLS properties, the redirect URL and parse the input XML parameters.
 
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

ERRTASK_NAME

public static java.lang.String ERRTASK_NAME
Error handling viewname for this command.
Constructor Detail

CSROrderRollBackCmdImpl

public CSROrderRollBackCmdImpl()
Method Detail

copyArrayToVector

protected java.util.Vector copyArrayToVector(OrderItemDataBean[] orderItemsArray)
Creates a vector from a array.
Parameters:
orderItemsArray - The array
Returns:
The vector

exceptionUtil

protected TypedProperty exceptionUtil(TypedProperty prop,
                                      java.lang.Exception ex,
                                      java.lang.String methodName,
                                      java.lang.String cmdName)
This method sets up the response property when an exception occurs.
Parameters:
prop - The response typed property.
ex - The catched exception.
methodName - The name of the method with exception.
cmdName - The name of the command.
Returns:
The proper typed property with redirection to the error page.

executeOrderCancelCmd

protected void executeOrderCancelCmd(java.lang.String orderId)
                              throws ECApplicationException,
ECException
Calls the AdminOrderCancelCmd to cancel an order.
Parameters:
orderId - The order ID.
Throws:
ECApplicationException - If the order can not be canceled.
ECException - If the order can not be canceled.

executeOrderDelete

protected void executeOrderDelete(java.lang.String orderId)
                           throws java.lang.Exception
Delete an order in database.
Parameters:
orderId - The order ID.
Throws:
java.lang.Exception - If order can not be deleted.

executeOrderItemAdd

protected void executeOrderItemAdd(OrderItemDataBean theOrderItem)
                            throws java.lang.Exception
Call OrderItemAddCmd to add an order item.
Parameters:
theOrderItem - The order item need to be added.
Throws:
java.lang.Exception

executeOrderItemDelete

protected void executeOrderItemDelete(OrderItemDataBean theOrderItem)
                               throws java.lang.Exception
Call OrderItemDeleteCmd to delete an order item.
Parameters:
theOrderItem - The order item need to be deleted.
Throws:
java.lang.Exception - If order item can not be deleted.

executeOrderItemUpdate

protected void executeOrderItemUpdate(OrderItemDataBean changedOrderItem,
OrderItemDataBean originalOrderItem)
                               throws java.lang.Exception
Call OrderItemUpdateCmd to update an order item by using the values (cat entry ID, quantity, shipping mode ID, shipping address ID, contract ID) from the original order items.
Parameters:
changedOrderItem - The order item needs to be updated.
originalOrderItem - The order item contain the saved attribute values which will be used for update.
Throws:
java.lang.Exception - If order item can not be updated.

executeOrderPrepare

protected void executeOrderPrepare(java.lang.String orderId)
                            throws ECException
Call OrderPrepareCmd to prepare an order.
Parameters:
orderId - The order ID.
Throws:
ECException - If order can not be prepared.

executeOrderProcess

protected void executeOrderProcess(java.lang.String orderId,
                                   java.lang.String payInfoOrderId)
                            throws java.lang.Exception
This method calls OrderProcessCmd to complete an order by using the payment info from the backup order.
Parameters:
orderId - The order ID.
payInfoOrderId - The ID of the order which the payment information stored.
Throws:
ECException - If order can not be processed.
java.lang.Exception

executeSetOrderLevelAdjustmentCmd

protected void executeSetOrderLevelAdjustmentCmd(java.math.BigDecimal orderLevelMenuAdjustment,
                                                 java.math.BigDecimal shippingCharge)
                                          throws ECException,
                                                 java.lang.Exception
This method call SetOrderLevelParameterCmd to set the shipping charge and menu adjustments.
Parameters:
orderLevelMenuAdjustment - The order level menu adjustment.
shippingCharge - The shipping charge.
Throws:
ECException - If fails to set order adjustment.
java.lang.Exception - If fails to set order adjustment.

getBackupOrder

protected OrderDataBean getBackupOrder()
Returns the backup order.
Returns:
The backup order.

getBackupOrderId

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

getBackupOrderItems

protected java.util.Vector getBackupOrderItems()
Returns the order items of the backup order.
Returns:
The vector of backup order items.

getCustomerId

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

getFirstOrder

protected OrderDataBean getFirstOrder()
Returns the first order.
Returns:
The first order.

getFirstOrderId

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

getFirstOrderItems

protected java.util.Vector getFirstOrderItems()
Returns the order items of the first order.
Returns:
The vector of first order items.

getNLS

public java.util.Hashtable getNLS()
Returns NLS properties.
Returns:
The NLS properties.

getOrgCmdContext

public CommandContext getOrgCmdContext()
Returns original command context.
Returns:
The original command context.

getOrgLangId

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

getOrigOrderLastUpdate

public java.lang.String getOrigOrderLastUpdate()
Returns the origOrderLastUpdate.
Returns:
java.lang.String

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.

getOrigOrderCouponIds

public java.lang.String getOrigOrderCouponIds()
Returns the string of coupons IDs used in the original order.
Returns:
The coupoun IDs used in the original order.

getOrigOrderGrandTotal

public java.math.BigDecimal getOrigOrderGrandTotal()
Returns original order grand total.
Returns:
The original order grand total.

getOrigOrderLevelMenuAdjustment

public java.math.BigDecimal getOrigOrderLevelMenuAdjustment()
Returns original order level menu adjustment.
Returns:
The original order level menu adjustment.

getOrigOrderStatus

public java.lang.String getOrigOrderStatus()
Returns the origOrderStatus.
Returns:
java.lang.String

getOrigShippingCharge

public java.math.BigDecimal getOrigShippingCharge()
Returns the original shipping charge.
Returns:
The original shipping charge.

getRedirectURL

public java.lang.String getRedirectURL()
Returns redirect URL.
Returns:
The redirect URL.

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.

getSecondOrderId

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

getXMLFile

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

ifAttributeChanged

protected boolean ifAttributeChanged(java.lang.String changedAttr,
                                     java.lang.String origAttr)
Compares the values of two attributes with type String.
Parameters:
changedAttr - The changed attribute
origAttr - The original attribute
Returns:
false if both attribute contain the same String value or both attributes are null. Otherwise, return true.

ifAttributeChanged

protected boolean ifAttributeChanged(java.math.BigDecimal changedAttr,
                                     java.math.BigDecimal origAttr)
Compares the values of two attributes with type BigDeciaml.
Parameters:
changedAttr - The changed attribute
origAttr - The original attribute
Returns:
false if both attribute contain the same BigDecimal value or both attributes are null. Otherwise, return true.

ifOrderItemChanged

protected boolean ifOrderItemChanged(OrderItemDataBean changedOrderItem,
OrderItemDataBean originalOrderItem)
                              throws java.lang.Exception
Compares order items. They are the same if the following attributes of the two order items are the same:
Parameters:
changedOrderItem - The changed order item
originalOrderItem - The original order item
Returns:
false if both order item contain the same attributes. Otherwise, return true.
Throws:
java.lang.Exception

initOrderBean

protected OrderDataBean initOrderBean(java.lang.String orderId)
                               throws java.lang.Exception
Initializes an OrderDataBean.
Parameters:
orderId - The order ID.
Returns:
The OrderDataBean.
Throws:
java.lang.Exception - If fails to initialize the order databean.

performExecute

public void performExecute()
                    throws ECException
This method performs rollback changes done to the first order from the data in the backup order. Once the rollback is done successfully, the command will delete the back up order. If the second order exists, this method will cancel the second order.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException - If fails to roolback order.

removeOrderItems

protected void removeOrderItems(java.util.Vector orderItems)
                         throws java.lang.Exception
Deletes all the order items in the order item list.
Parameters:
orderItems - The order items need to be deleted.
Throws:
java.lang.Exception

removePrevPayment

protected void removePrevPayment(java.lang.String orderId)
                          throws ECApplicationException
Removes original payment from the order.
Parameters:
orderId - The order Id.
Throws:
ECApplicationException

rollbackDeletedOrUpdatedOrderItems

protected void rollbackDeletedOrUpdatedOrderItems(OrderDataBean changedOrder,
                                                  java.util.Vector changedOrderItems,
OrderDataBean originalOrder,
                                                  java.util.Vector originalOrderItems)
                                           throws java.lang.Exception
Add or update the order items in the changedOrder so that it will have the same order items as the originalOrder.
Parameters:
changedOrder - The order which has been changed.
changedOrderItems - The order items of the changedOrder.
originalOrder - The original order which contains the saved value.
originalOrderItems - The order items of the original order.
Throws:
java.lang.Exception

rollbackOrderAdjustment

protected void rollbackOrderAdjustment(OrderDataBean changedOrder)
                                throws java.lang.Exception
Sets the shipping charge and the order level menu adjustments of the changed order to the original values.
Parameters:
changedOrder - The order which has been changed.
Throws:
java.lang.Exception

setBackupOrder

protected void setBackupOrder(OrderDataBean newOrder)
Sets backup order.
Parameters:
newOrder - The backup order.

setBackupOrderId

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

setBackupOrderItems

protected void setBackupOrderItems(java.util.Vector newOrderItems)
Sets order items of the backup order.
Parameters:
newOrderItems - The order items of the backup order.

setCustomerId

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

setFirstOrder

protected void setFirstOrder(OrderDataBean newOrder)
Sets first order.
Parameters:
newOrder - The first order.

setFirstOrderId

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

setFirstOrderItems

protected void setFirstOrderItems(java.util.Vector newOrderItems)
Sets order items of the first order.

setNLS

protected void setNLS(java.util.Hashtable newNLS)
Sets NLS properties.
Parameters:
newNLS - The NLS properties.

setOrgCmdContext

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

setOrgLangId

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

setOrigOrderLastUpdate

public void setOrigOrderLastUpdate(java.lang.String inOrigOrderLastUpdate)
Sets the origOrderLastUpdate.

setOrgLocale

protected void setOrgLocale(java.util.Locale newOrgLocale)
Sets original Locale.
Parameters:
newOrgLocale - The original Locale.

setOrgReqProperties

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

setOrigOrderCouponIds

public void setOrigOrderCouponIds(java.lang.String newOrigOrderCouponIds)
Sets the list of coupons used in the original order
Parameters:
newOrigOrderCouponIds - IDs of coupons used in the original order

setOrigOrderLevelMenuAdjustment

public void setOrigOrderLevelMenuAdjustment(java.lang.String tmpValue)
Sets original order level menu adjustment.

setOrigShippingCharge

public void setOrigShippingCharge(java.lang.String tmpValue)
Sets original order shipping charge.

setOrigOrderStatus

public void setOrigOrderStatus(java.lang.String inOrigOrderStatus)
Sets the origOrderStatus.

setRedirectURL

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

setSecondOrderId

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

setXMLFile

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

validateParameters

public void validateParameters()
                        throws ECApplicationException
Sets the NLS properties, the redirect URL and parse the input XML parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
ECApplicationException