atg.commerce.order.edit
Class CloneEditHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.edit.CloneEditHandler
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
CollectionEditHandler, OrderPropertyEditHandler

public abstract class CloneEditHandler
extends GenericService

Components of this type are attached to the CloneEditManager and are called at various points in the clone edit process.

Each CloneEditHandler has access to its own state map stored in the CloneEditState.

See Also:
getStateData(CloneEditState, String), addStateData(CloneEditState, String, Object), cloneOrder(Order, Order), validateCloneOrder(Order, Order), initializeCloneEditState(CloneEditState), initializeReconciliationProcess(CloneEditState), applyChanges(CloneEditState)

Field Summary
static java.lang.String CLASS_VERSION
           
protected  MessageSender mFulfillmentMessageSender
           
protected  java.lang.String mKeyPropertyName
           
protected  OrderFulfillmentTools mOrderFulfillmentTools
           
protected  java.util.Map mPropertiesToCopyOnUpdate
           
protected static java.lang.String MY_RESOURCE_NAME
           
protected static java.util.ResourceBundle sResourceBundle
          Resource Bundle
protected static java.lang.String STATE_ADD_ITEMS
          the key used for storing the AddItem map in the clone order state
protected static java.lang.String STATE_DELETE_ITEMS
          the key used for storing the DeleteItem map in the clone order state
protected static java.lang.String STATE_UPDATE_ITEMS
          the key used for storing the UpdateItem map in the clone order state
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CloneEditHandler()
           
 
Method Summary
protected  void addAddItem(CloneEditState pCloneEditState, AddItem pAddItem)
          Adds a pAddItem to the add item map in the clone edit state.
protected  void addDeleteItem(CloneEditState pCloneEditState, DeleteItem pDeleteItem)
          Adds a DeleteItem to the delete item map in the clone edit state.
protected  void addItem(CloneEditState pCloneEditState, AddItem pAddItem)
          This is a noop impl
protected  void addStateData(CloneEditState pCloneEditState, java.lang.String pKey, java.lang.Object pStateData)
          adds an object to the state map maintained by this CloneEditHandler
protected  void addUpdateItem(CloneEditState pCloneEditState, UpdateItem pUpdateItem)
          Adds a UpdateItem to the update item map in the clone edit state.
 void adjustCloneCommerceIdReferences(CloneEditState pCloneEditState)
          This API is called once the clone order is created so each handler can update any references to commerce ids in the clone order to the clone counterpart ids.
 void adjustOriginalCommerceIdReferences(CloneEditState pCloneEditState)
          This API is called once after the reconciliation so each handler can update any references to commerce ids in the original order to the clone counterpart ids.
abstract  void applyChanges(CloneEditState pCloneEditState)
          This method is called during the reconciliation process to reconcile the data between the original and clone object.
 void cloneOrder(Order pOriginalOrder, Order pCloneOrder)
          This method is called just after the original order is cloned at the repository level.
protected  void copyPricingModels(java.lang.Object pOriginalObject, java.lang.Object pCloneObject, java.lang.String pPriceInfoPropertyName)
          Util method for copying the pricing models from the original price info to the clone price info.
 AddItem createAddItem(CloneEditState pCloneEditState, java.lang.Object pItem, java.lang.Object pOriginalContainter, java.lang.Object pCloneContainer, int pOrdinalPosition, java.lang.String pPropertyName, boolean pAutoRecoveredItem)
          Creates an AddItem object that represents an object that's been added to a container.
 DeleteItem createDeleteItem(CloneEditState pCloneEditState, java.lang.Object pItem, java.lang.Object pOriginalContainter, java.lang.Object pCloneContainer, java.lang.String pPropertyName, int pOrdinalPosition, boolean pAutoDeletedItem)
          Creates a DeleteItem object that represents an object that's been removed to a particular list.
 UpdateItem createUpdateItem(CloneEditState pCloneEditState, java.lang.Object pOriginalItem, java.lang.Object pCloneItem, int pOrdinalPosition, java.lang.String pPropertyName, java.lang.Object pOriginalContainter, java.lang.Object pCloneContainer)
          Creates an UpdateItem object that represents an updated object.
protected  void deleteItem(CloneEditState pCloneEditState, DeleteItem pDeleteItem)
          This is a noop impl.
 java.util.List generateModifications(CloneEditState pCloneEditState)
          Generates the list of Modification objects that are sent to fulfillment
protected  java.util.Map getAddItems(CloneEditState pCloneEditState)
          Returns the AddItem map.
 CloneEditManager getCloneEditManager()
           
protected  java.util.Map getDeleteItems(CloneEditState pCloneEditState)
          Returns the DeleteItem clone map.
 MessageSender getFulfillmentMessageSender()
          Return the FulfillmentMessageSender property.
protected  java.lang.Object getKeyForObject(java.lang.Object pObject)
          Returns the key that should be used for the given object.
 java.lang.String getKeyPropertyName()
          The value of this property is used to map objects in the cloneToOriginal, originalToClone, addItem, updateItem and deleteItem maps
protected  java.lang.String getObjectType(java.lang.Object pObject)
          Returns the type of the object.
 OrderFulfillmentTools getOrderFulfillmentTools()
           
protected  java.lang.String[] getPropertiesToCopy(java.lang.Object pObject)
          Returns the property names for the given object.
 java.util.Map getPropertiesToCopyOnUpdate()
          get the map of property names to copy when reconciling a clone object item with its original order counterpart.
protected  java.lang.Object getStateData(CloneEditState pCloneEditState, java.lang.String pKey)
          gets an object from the state map maintained by this CloneEditHandler
protected  java.util.Map getStateMap(CloneEditState pCloneEditState)
          Gets the state data map for this clone edit handler from the CloneEditState
protected  java.util.Map getUpdateItems(CloneEditState pCloneEditState)
          Returns the UpdateItem clone map.
abstract  void initializeCloneEditState(CloneEditState pCloneEditState)
          This method is called to initialize the CloneEditState object after cloning.
 void initializeReconciliationProcess(CloneEditState pCloneEditState)
          Reinitializes the AddItem, UpdateItem and DeleteItem maps in the clon edit state.
protected  boolean isAddedItem(CloneEditState pCloneEditState, java.lang.Object pKey)
          Determines if an AddItem is mapped to the given key.
protected  java.lang.String[] parseConfigString(java.lang.String pConfigString)
          Parses a comma delimited string into a string array.
protected  void processAddItems(CloneEditState pCloneEditState)
          Processes each AddItem object in the clone edit state.
protected  void processDeleteItems(CloneEditState pCloneEditState)
          Processes each DeleteItem object in the clone edit state.
protected  void processUpdateItems(CloneEditState pCloneEditState)
          Processes each UpdateItem object in the clone edit state.
protected  java.util.Collection reconcileObjectProperties(java.lang.Object pClone, java.lang.Object pOrig, java.lang.String[] pProperties)
          Reconciles the original with the clone object
 void sendFulfillmentNotifications(CloneEditState pCloneEditState)
          This method is called to send the fulfillment messages.
 void sendMessage(CloneEditState pCloneEditState, java.util.List pModificationList)
          Sends the list of modifications.
 void setCloneEditManager(CloneEditManager pCloneEditManager)
           
 void setFulfillmentMessageSender(MessageSender pFulfillmentMessageSender)
          Set the FulfillmentMessageSender property.
 void setKeyPropertyName(java.lang.String pKeyPropertyName)
           
 void setOrderFulfillmentTools(OrderFulfillmentTools pOrderFulfillmentTools)
          Sets the OrderFulfillmentTools component
 void setPropertiesToCopyOnUpdate(java.util.Map pPropertiesToCopyOnUpdate)
          Set the map of properties to copy when updating a clone commerce item to its original order counterpart.
protected  void updateItem(CloneEditState pCloneEditState, UpdateItem pUpdateItem)
          Reconciles the pUpdateItem by copying property values from the clone to original object.
abstract  void validateCloneOrder(Order pOriginalOrder, Order pCloneOrder)
          This method is called to validate the clone order after it is created.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

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

MY_RESOURCE_NAME

protected static final java.lang.String MY_RESOURCE_NAME
See Also:
Constant Field Values

STATE_UPDATE_ITEMS

protected static final java.lang.String STATE_UPDATE_ITEMS
the key used for storing the UpdateItem map in the clone order state

See Also:
Constant Field Values

STATE_DELETE_ITEMS

protected static final java.lang.String STATE_DELETE_ITEMS
the key used for storing the DeleteItem map in the clone order state

See Also:
Constant Field Values

STATE_ADD_ITEMS

protected static final java.lang.String STATE_ADD_ITEMS
the key used for storing the AddItem map in the clone order state

See Also:
Constant Field Values

sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle


mOrderFulfillmentTools

protected OrderFulfillmentTools mOrderFulfillmentTools

mFulfillmentMessageSender

protected MessageSender mFulfillmentMessageSender

mPropertiesToCopyOnUpdate

protected java.util.Map mPropertiesToCopyOnUpdate

mKeyPropertyName

protected java.lang.String mKeyPropertyName
Constructor Detail

CloneEditHandler

public CloneEditHandler()
Method Detail

setOrderFulfillmentTools

public void setOrderFulfillmentTools(OrderFulfillmentTools pOrderFulfillmentTools)
Sets the OrderFulfillmentTools component

Parameters:
pOrderFulfillmentTools - the OrderFulfillmentTools component

getOrderFulfillmentTools

public OrderFulfillmentTools getOrderFulfillmentTools()
Returns:
the OrderFulfillmentTools components

setFulfillmentMessageSender

public void setFulfillmentMessageSender(MessageSender pFulfillmentMessageSender)
Set the FulfillmentMessageSender property.

Parameters:
pFulfillmentMessageSender - a FulfillmentMessageSender value

getFulfillmentMessageSender

public MessageSender getFulfillmentMessageSender()
Return the FulfillmentMessageSender property.

Returns:
a FulfillmentMessageSender value

getPropertiesToCopyOnUpdate

public java.util.Map getPropertiesToCopyOnUpdate()
get the map of property names to copy when reconciling a clone object item with its original order counterpart.

the map contains the object class types mapped to a comma delimited string of property names.

Returns:
Map

setPropertiesToCopyOnUpdate

public void setPropertiesToCopyOnUpdate(java.util.Map pPropertiesToCopyOnUpdate)
Set the map of properties to copy when updating a clone commerce item to its original order counterpart.


getKeyPropertyName

public java.lang.String getKeyPropertyName()
The value of this property is used to map objects in the cloneToOriginal, originalToClone, addItem, updateItem and deleteItem maps

Returns:
property name

setKeyPropertyName

public void setKeyPropertyName(java.lang.String pKeyPropertyName)

getPropertiesToCopy

protected java.lang.String[] getPropertiesToCopy(java.lang.Object pObject)
Returns the property names for the given object.

Parameters:
pObject - object for which to get properties
Returns:
property names to copy
See Also:
parseConfigString(String)

parseConfigString

protected java.lang.String[] parseConfigString(java.lang.String pConfigString)
Parses a comma delimited string into a string array.

This method is used to convert map configurations into string arrays.

Parameters:
pConfigString -
Returns:
String []

getObjectType

protected java.lang.String getObjectType(java.lang.Object pObject)
Returns the type of the object. By default the objects class name is returned.

Parameters:
pObject -
Returns:
string represent the objects type.

getCloneEditManager

public CloneEditManager getCloneEditManager()
Returns:
the clone edit manager component instance

setCloneEditManager

public void setCloneEditManager(CloneEditManager pCloneEditManager)

getStateMap

protected java.util.Map getStateMap(CloneEditState pCloneEditState)
Gets the state data map for this clone edit handler from the CloneEditState

Parameters:
pCloneEditState -
Returns:
the state map for this CloneEditHandler. Lazily instantiates the map if necessary.

addStateData

protected void addStateData(CloneEditState pCloneEditState,
                            java.lang.String pKey,
                            java.lang.Object pStateData)
adds an object to the state map maintained by this CloneEditHandler

Parameters:
pCloneEditState -
pKey -
pStateData -

getStateData

protected java.lang.Object getStateData(CloneEditState pCloneEditState,
                                        java.lang.String pKey)
gets an object from the state map maintained by this CloneEditHandler

Parameters:
pCloneEditState -
pKey -

cloneOrder

public void cloneOrder(Order pOriginalOrder,
                       Order pCloneOrder)
                throws CommerceException
This method is called just after the original order is cloned at the repository level.

This is a noop implementation.

Applications can extend this method to perform application specific cloning of data here.

Parameters:
pOriginalOrder -
pCloneOrder -
Throws:
CommerceException

initializeCloneEditState

public abstract void initializeCloneEditState(CloneEditState pCloneEditState)
                                       throws CommerceException
This method is called to initialize the CloneEditState object after cloning. Implemenations can perform application specific state initialization here.

Parameters:
pCloneEditState -
Throws:
CommerceException

applyChanges

public abstract void applyChanges(CloneEditState pCloneEditState)
                           throws CommerceException
This method is called during the reconciliation process to reconcile the data between the original and clone object.

Parameters:
pCloneEditState -
Throws:
CommerceException

initializeReconciliationProcess

public void initializeReconciliationProcess(CloneEditState pCloneEditState)
                                     throws CommerceException
Reinitializes the AddItem, UpdateItem and DeleteItem maps in the clon edit state.

Throws:
CommerceException

validateCloneOrder

public abstract void validateCloneOrder(Order pOriginalOrder,
                                        Order pCloneOrder)
                                 throws CommerceException
This method is called to validate the clone order after it is created.

Parameters:
pOriginalOrder -
pCloneOrder -
Throws:
CommerceException

sendFulfillmentNotifications

public void sendFulfillmentNotifications(CloneEditState pCloneEditState)
                                  throws CommerceException,
                                         javax.jms.JMSException
This method is called to send the fulfillment messages. It executes generateModifications to generate the List of Modification objects for the changes made by this CloneEditHandler. It then sends the list of modifications in a single event using sendMessage

Parameters:
pCloneEditState -
Throws:
CommerceException
javax.jms.JMSException
See Also:
generateModifications(CloneEditState), sendMessage(CloneEditState, List)

generateModifications

public java.util.List generateModifications(CloneEditState pCloneEditState)
Generates the list of Modification objects that are sent to fulfillment

Handlers should override this method to generate the appropriate Modification objects.

This impl returns null by default.

Parameters:
pCloneEditState -
Returns:
List of modification objects

adjustCloneCommerceIdReferences

public void adjustCloneCommerceIdReferences(CloneEditState pCloneEditState)
                                     throws CommerceException
This API is called once the clone order is created so each handler can update any references to commerce ids in the clone order to the clone counterpart ids. For example, a reference to a shipping group id can be updated to the shipping group's clone counterpart id.

Parameters:
pCloneEditState -
Throws:
CommerceException

adjustOriginalCommerceIdReferences

public void adjustOriginalCommerceIdReferences(CloneEditState pCloneEditState)
                                        throws CommerceException
This API is called once after the reconciliation so each handler can update any references to commerce ids in the original order to the clone counterpart ids. For example, a reference to a shipping group id can be updated to the shipping group's original counterpart id.

Parameters:
pCloneEditState -
Throws:
CommerceException

sendMessage

public void sendMessage(CloneEditState pCloneEditState,
                        java.util.List pModificationList)
                 throws javax.jms.JMSException
Sends the list of modifications.

Parameters:
pCloneEditState -
pModificationList - the list of Modificiatios
Throws:
javax.jms.JMSException

reconcileObjectProperties

protected java.util.Collection reconcileObjectProperties(java.lang.Object pClone,
                                                         java.lang.Object pOrig,
                                                         java.lang.String[] pProperties)
Reconciles the original with the clone object

Parameters:
pClone - clone object
pOrig - original object
pProperties - the properties to reconcile
Returns:
PropertyUpdates
See Also:
CloneEditManager.reconcileProperties(Object, Object, String[])

getUpdateItems

protected java.util.Map getUpdateItems(CloneEditState pCloneEditState)
Returns the UpdateItem clone map. This method will lazily create the map if one doesn't already exist.

Parameters:
pCloneEditState -
Returns:
map of UpdatedItem objects.

deleteItem

protected void deleteItem(CloneEditState pCloneEditState,
                          DeleteItem pDeleteItem)
                   throws CommerceException
This is a noop impl.

Parameters:
pCloneEditState -
pDeleteItem - the DeleteItem object
Throws:
CommerceException

updateItem

protected void updateItem(CloneEditState pCloneEditState,
                          UpdateItem pUpdateItem)
                   throws CommerceException
Reconciles the pUpdateItem by copying property values from the clone to original object.

The properties that are are copied are configurable.

Parameters:
pCloneEditState -
pUpdateItem -
Throws:
CommerceException
See Also:
reconcileObjectProperties(Object, Object, String[]), getPropertiesToCopy(Object)

addItem

protected void addItem(CloneEditState pCloneEditState,
                       AddItem pAddItem)
                throws CommerceException
This is a noop impl

Parameters:
pCloneEditState -
pAddItem -
Throws:
CommerceException

getAddItems

protected java.util.Map getAddItems(CloneEditState pCloneEditState)
Returns the AddItem map. This method will lazily create the map if one doesn't already exist.

Parameters:
pCloneEditState -
Returns:
map of AddItem objects

getDeleteItems

protected java.util.Map getDeleteItems(CloneEditState pCloneEditState)
Returns the DeleteItem clone map. This method will lazily create the map if one doesn't already exist.

Parameters:
pCloneEditState -
Returns:
map of DeleteItem objects.

isAddedItem

protected boolean isAddedItem(CloneEditState pCloneEditState,
                              java.lang.Object pKey)
Determines if an AddItem is mapped to the given key.

Parameters:
pCloneEditState -
pKey -
Returns:
true if the key is found in the map

processDeleteItems

protected void processDeleteItems(CloneEditState pCloneEditState)
                           throws CommerceException
Processes each DeleteItem object in the clone edit state.

Parameters:
pCloneEditState -
Throws:
CommerceException
See Also:
deleteItem(CloneEditState, DeleteItem)

processAddItems

protected void processAddItems(CloneEditState pCloneEditState)
                        throws CommerceException
Processes each AddItem object in the clone edit state.

Parameters:
pCloneEditState -
Throws:
CommerceException
See Also:
addItem(CloneEditState, AddItem)

processUpdateItems

protected void processUpdateItems(CloneEditState pCloneEditState)
                           throws CommerceException
Processes each UpdateItem object in the clone edit state.

Parameters:
pCloneEditState -
Throws:
CommerceException
See Also:
updateItem(CloneEditState, UpdateItem)

getKeyForObject

protected java.lang.Object getKeyForObject(java.lang.Object pObject)
                                    throws PropertyNotFoundException
Returns the key that should be used for the given object. By default, this method returns the value of the property defined by keyPropertyName.

If keyPropertyName is not valued then the original object is returned.

Parameters:
pObject -
Returns:
key object
Throws:
PropertyNotFoundException

addDeleteItem

protected void addDeleteItem(CloneEditState pCloneEditState,
                             DeleteItem pDeleteItem)
Adds a DeleteItem to the delete item map in the clone edit state. The key is derived by calling getKeyForObject for the original item.

Parameters:
pCloneEditState -
pDeleteItem -

addUpdateItem

protected void addUpdateItem(CloneEditState pCloneEditState,
                             UpdateItem pUpdateItem)
Adds a UpdateItem to the update item map in the clone edit state. The key is derived by calling getKeyForObject for the original item.

Parameters:
pCloneEditState -
pUpdateItem -

addAddItem

protected void addAddItem(CloneEditState pCloneEditState,
                          AddItem pAddItem)
Adds a pAddItem to the add item map in the clone edit state. The key is derived by calling getKeyForObject for the original item.

Parameters:
pCloneEditState -
pAddItem -

createAddItem

public AddItem createAddItem(CloneEditState pCloneEditState,
                             java.lang.Object pItem,
                             java.lang.Object pOriginalContainter,
                             java.lang.Object pCloneContainer,
                             int pOrdinalPosition,
                             java.lang.String pPropertyName,
                             boolean pAutoRecoveredItem)
Creates an AddItem object that represents an object that's been added to a container.

Parameters:
pCloneEditState -
pItem -
pOriginalContainter -
pCloneContainer -
pOrdinalPosition -
pAutoRecoveredItem -
Returns:
an AddItem object

createDeleteItem

public DeleteItem createDeleteItem(CloneEditState pCloneEditState,
                                   java.lang.Object pItem,
                                   java.lang.Object pOriginalContainter,
                                   java.lang.Object pCloneContainer,
                                   java.lang.String pPropertyName,
                                   int pOrdinalPosition,
                                   boolean pAutoDeletedItem)
Creates a DeleteItem object that represents an object that's been removed to a particular list.

Parameters:
pCloneEditState -
pItem -
pOriginalContainter -
pOrdinalPosition -
pAutoDeletedItem -
Returns:
DeleteItem object

createUpdateItem

public UpdateItem createUpdateItem(CloneEditState pCloneEditState,
                                   java.lang.Object pOriginalItem,
                                   java.lang.Object pCloneItem,
                                   int pOrdinalPosition,
                                   java.lang.String pPropertyName,
                                   java.lang.Object pOriginalContainter,
                                   java.lang.Object pCloneContainer)
Creates an UpdateItem object that represents an updated object.

Parameters:
pCloneEditState -
pOriginalItem - the original object that was updated
pOrdinalPosition - the position in the container
pOriginalContainter - the original object container
pCloneContainer - the clone object container
Returns:
UpdateItem

copyPricingModels

protected void copyPricingModels(java.lang.Object pOriginalObject,
                                 java.lang.Object pCloneObject,
                                 java.lang.String pPriceInfoPropertyName)
Util method for copying the pricing models from the original price info to the clone price info.

Parameters:
pOriginalObject -
pCloneObject -
pPriceInfoPropertyName -