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

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

public class CSROrderRollBackCmdImpl
extends ToolsControllerCommandImpl
implements CSROrderRollBackCmd

Change the first order so that it will contain the same order items as those order items in the backup order.

If the first order has a order item with a SKU which does not exist in the backup order, this command will call OrderItemDelete command to delete this order item from the first order.

If the backup order has a order item with a SKU which does not exist in the first order, this command will call OrderItemAdd command to add the order item to the first order.

If the first order has a order item with a SKU which does exist in the backup order, this command will compare the following attributes of those two order items:

  1. Quantity
  2. Shipping address
  3. Shipping mode
  4. Contract ID

If there is any difference found, the command will call the OrderItemUpdate command to update the order item of the first order.

Set the shipping charge, menu adjustment and coupons of the first order as those values provided by the XML.

After the changes made to the first order is done, the command will do the following:

  1. Call OrderPrepare command to prepare the first order.
  2. Remove the payment of the first order.
  3. Call OrderProcess command to process the first order.

If the grand totoal of the first order is different from the value in the XML, the command will return a warning message.

If the second order exists, this command will cancel the second order.

This command will remove the backup order after all the changes are made to the first order successfully. If the command fail to remove the backup order, the command will return a warning message.


Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String ERRTASK_NAME
           
static java.lang.String NOTEBOOK_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.CSROrderRollBackCmd
defaultCommandClassName, NAME
 
Constructor Summary
CSROrderRollBackCmdImpl()
           
 
Method Summary
protected  java.util.Vector copyArrayToVector(OrderItemDataBean[] orderItemsArray)
          Create a vector from a array.
protected  TypedProperty exceptionUtil(TypedProperty prop, java.lang.Exception ex, java.lang.String methodName, java.lang.String cmdName)
          Common exception code.
protected  void executeOrderCancelCmd(java.lang.String orderId)
          Call the AdminOrderCancel command to cancel an order.
protected  void executeOrderDelete(java.lang.String orderId)
          Delete an order in database.
protected  void executeOrderItemAdd(OrderItemDataBean theOrderItem)
          Call OrderItemAdd command to add an order item.
protected  void executeOrderItemDelete(OrderItemDataBean theOrderItem)
          Call OrderItemDelete command to delete an order item.
protected  void executeOrderItemUpdate(OrderItemDataBean changedOrderItem, OrderItemDataBean originalOrderItem)
          Call OrderItemUpdate command 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 OrderPrepare command to prepare an order.
protected  void executeOrderProcess(java.lang.String orderId, java.lang.String payInfoOrderId)
          This method calls OrderProcess command to complete an order by using the payment info from another order (order is is payInfoOrderId).
protected  void executeSetOrderLevelAdjustmentCmd(java.math.BigDecimal orderLevelMenuAdjustment, java.math.BigDecimal shippingCharge)
          This method call SetOrderLevelParameter command to set the shipping charge and menu adjustments.
protected  OrderDataBean getBackupOrder()
          Return the backup order.
 java.lang.String getBackupOrderId()
          Return backup order ID.
protected  java.util.Vector getBackupOrderItems()
          Return the order items of the backup order.
 java.lang.String getCustomerId()
          Return customer ID.
protected  OrderDataBean getFirstOrder()
          Return the first order.
 java.lang.String getFirstOrderId()
          Return first order ID.
protected  java.util.Vector getFirstOrderItems()
          Return the order items of the first order.
 java.util.Hashtable getNLS()
          Return NLS properties.
 CommandContext getOrgCmdContext()
          Return original 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 getOrigOrderCouponIds()
          Returns the string of coupons IDs used in the original order.
 java.math.BigDecimal getOrigOrderGrandTotal()
          Return original order grand total.
 java.math.BigDecimal getOrigOrderLevelMenuAdjustment()
          Return original order level menu adjustment.
 java.math.BigDecimal getOrigShippingCharge()
          Return the original shipping charge.
 java.lang.String getRedirectURL()
          Return redirect URL.
 AccessVector getResources()
          Gets the access vector accessed by this command.
 java.lang.String getSecondOrderId()
          Return the ID of the second order.
 java.lang.String getXMLFile()
          Return XML file.
protected  boolean ifAttributeChanged(java.math.BigDecimal changedAttr, java.math.BigDecimal origAttr)
          Compare the values of two attributes with type BigDeciaml.
protected  boolean ifAttributeChanged(java.lang.String changedAttr, java.lang.String origAttr)
          Compare the values of two attributes with type String.
protected  boolean ifOrderItemChanged(OrderItemDataBean changedOrderItem, OrderItemDataBean originalOrderItem)
          Compare the following attributes of the two order items: Cat entry ID Quantity Contract ID Shipping address ID Shipping mode ID
protected  OrderDataBean initOrderBean(java.lang.String orderId)
          Initialize a 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)
          Delete all the order items in the order item list.
protected  void removePrevPayment(java.lang.String orderId)
          Remove 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)
          Set the shipping charge and the order level menu adjustments of the changed order to the original values.
protected  void setBackupOrder(OrderDataBean newOrder)
          Set backup order.
protected  void setBackupOrderId(java.lang.String newBackupOrderId)
          Set backup order ID.
protected  void setBackupOrderItems(java.util.Vector newOrderItems)
          Set order items of the backup order.
protected  void setCustomerId(java.lang.String newCustomerId)
          Set customer ID.
protected  void setFirstOrder(OrderDataBean newOrder)
          Set first order.
protected  void setFirstOrderId(java.lang.String newFirstOrderId)
          Set first order ID.
protected  void setFirstOrderItems(java.util.Vector newOrderItems)
          Set order items of the first order.
protected  void setNLS(java.util.Hashtable newNLS)
          Set NLS properties.
protected  void setOrgCmdContext(CommandContext newOrgCmdContext)
          Set original command context.
protected  void setOrgLangId(java.lang.Integer newOrgLangId)
          Set original language ID.
protected  void setOrgLocale(java.util.Locale newOrgLocale)
          Set original Locale.
protected  void setOrgReqProperties(TypedProperty newOrgReqProperties)
          Set original request properties.
 void setOrigOrderCouponIds(java.lang.String newOrigOrderCouponIds)
          Sets the list of coupons used in the original order
 void setOrigOrderLevelMenuAdjustment(java.lang.String tmpValue)
          Set original order level menu adjustment.
 void setOrigShippingCharge(java.lang.String tmpValue)
          Set original order shipping charge.
protected  void setRedirectURL(java.lang.String newRedirectURL)
          Set redirect URL.
protected  void setSecondOrderId(java.lang.String newSecondOrderId)
          Set second order ID.
protected  void setXMLFile(java.lang.String newXMLFile)
          Set XML file.
 void validateParameters()
          Set 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
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

ERRTASK_NAME

public static java.lang.String ERRTASK_NAME

NOTEBOOK_URL

public static final java.lang.String NOTEBOOK_URL
Constructor Detail

CSROrderRollBackCmdImpl

public CSROrderRollBackCmdImpl()
Method Detail

copyArrayToVector

protected java.util.Vector copyArrayToVector(OrderItemDataBean[] orderItemsArray)
Create 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)
Common exception code.
Parameters:
prop - com.ibm.commerce.datatype.TypedProperty
ex - java.lang.Exception
methodName - java.lang.String
cmdName - java.lang.String
Returns:
com.ibm.commerce.datatype.TypedProperty

executeOrderCancelCmd

protected void executeOrderCancelCmd(java.lang.String orderId)
                              throws ECApplicationException,
                                     ECException
Call the AdminOrderCancel command to cancel an order.
Parameters:
orderId - The order ID.
Throws:
ECApplicationException - The exception description
ECException -  

executeOrderDelete

protected void executeOrderDelete(java.lang.String orderId)
                           throws java.lang.Exception
Delete an order in database.
Throws:
java.lang.Exception -  

executeOrderItemAdd

protected void executeOrderItemAdd(OrderItemDataBean theOrderItem)
                            throws java.lang.Exception
Call OrderItemAdd command 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 OrderItemDelete command to delete an order item.
Parameters:
theOrderItem - The order item need to be deleted.
Throws:
java.lang.Exception -  

executeOrderItemUpdate

protected void executeOrderItemUpdate(OrderItemDataBean changedOrderItem,
                                      OrderItemDataBean originalOrderItem)
                               throws java.lang.Exception
Call OrderItemUpdate command 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 -  

executeOrderPrepare

protected void executeOrderPrepare(java.lang.String orderId)
                            throws ECException
Call OrderPrepare command to prepare an order.
Parameters:
orderId - The order ID.
Throws:
ECException -  

executeOrderProcess

protected void executeOrderProcess(java.lang.String orderId,
                                   java.lang.String payInfoOrderId)
                            throws java.lang.Exception
This method calls OrderProcess command to complete an order by using the payment info from another order (order is is payInfoOrderId).
Parameters:
orderId - The order ID.
payInfoOrderId - The ID of the order which the payment information stored.
Throws:
ECException -  

executeSetOrderLevelAdjustmentCmd

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

getBackupOrder

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

getBackupOrderId

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

getBackupOrderItems

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

getCustomerId

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

getFirstOrder

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

getFirstOrderId

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

getFirstOrderItems

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

getNLS

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

getOrgCmdContext

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

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.

getOrigOrderCouponIds

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

getOrigOrderGrandTotal

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

getOrigOrderLevelMenuAdjustment

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

getOrigShippingCharge

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

getRedirectURL

public java.lang.String getRedirectURL()
Return 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:
AccessVector A vector of resource action pairs

getSecondOrderId

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

getXMLFile

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

ifAttributeChanged

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

ifAttributeChanged

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

ifOrderItemChanged

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

initOrderBean

protected OrderDataBean initOrderBean(java.lang.String orderId)
                               throws java.lang.Exception
Initialize a OrderDataBean.
Parameters:
orderId - The order ID.
Returns:
The OrderDataBean.

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 -  

removeOrderItems

protected void removeOrderItems(java.util.Vector orderItems)
                         throws java.lang.Exception
Delete 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
Remove 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
Set 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)
Set backup order.
Parameters:
newOrder - The backup order.

setBackupOrderId

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

setBackupOrderItems

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

setCustomerId

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

setFirstOrder

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

setFirstOrderId

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

setFirstOrderItems

protected void setFirstOrderItems(java.util.Vector newOrderItems)
Set order items of the first order.
Parameters:
newFirstOrderId - The order items of the first order.

setNLS

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

setOrgCmdContext

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

setOrgLangId

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

setOrgLocale

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

setOrgReqProperties

protected void setOrgReqProperties(TypedProperty newOrgReqProperties)
Set 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)
Set original order level menu adjustment.
Parameters:
The - original order level menu adjustment.

setOrigShippingCharge

public void setOrigShippingCharge(java.lang.String tmpValue)
Set original order shipping charge.
Parameters:
The - original order shipping charge.

setRedirectURL

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

setSecondOrderId

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

setXMLFile

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

validateParameters

public void validateParameters()
                        throws ECApplicationException
Set 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 -