atg.commerce.order.edit
Class CloneEditManager

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

public class CloneEditManager
extends atg.nucleus.GenericService

This class contains the api for applying updates to a persisted order by making a clone of the order and then reconciling the original order with the clone after updates are made.

The advantage of making order updates this way is that all the changes to the clone can be discarded leaving the original order in its original state or all changes can be applied to the original order at once in a single transaction.

The edit process is done in two phases. Both phases are defined as pipelines that consist of several steps. Pipelines are mapped and executed based on the state of the order being edited using the initializeEditChains and reconcileOrderChains, which allows for executing custom pipelines for orders in different states.

The CloneEditHandler components, which are mapped to property cloneEditHandlers are executed in various steps of both phases. Each handler is responsible for handling specific facets of the order during both phases. This is the main integration point for handling customizations to the Order.

In the first phase, the original order is cloned at the repository level. The OrderManager is used to load the clone order, which creates the Commerce Order objects. The clone edit state object is created in this phase and each clone edit is executed.

The second phase reconciles the changes in the clone order with the original order.

See Also:
initializeOrderEdit(Order), reconcileOrder(CloneEditState, Map), CloneEditHandler, CloneEditState

Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String CLONEDITMANAGER
           
static java.lang.String CLONEEDITSTATE
           
static java.lang.String CLONEORDER
           
protected  atg.commerce.catalog.CatalogTools mCatalogTools
           
protected  CloneEditHandler[] mCloneEditHandlers
           
protected  java.util.Map mInitializeEditChains
           
protected  atg.commerce.inventory.InventoryManager mInventoryManager
           
protected  atg.commerce.order.OrderManager mOrderManager
           
protected  java.util.Map mReconcileOrderChains
           
protected  javax.transaction.TransactionManager mTransactionManager
           
 
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
CloneEditManager()
           
 
Method Summary
 void applyChanges(CloneEditState pCloneEditState)
          Applies all the changes in the clone to the original order.
 java.util.Map buildPropertyValueMap(java.lang.Object pObject)
          Iterates over all the properties of the object and creates a map of their values.
 atg.commerce.order.Order cloneOrder(atg.commerce.order.Order pOrder, java.util.Map pPropExceptions, java.util.Map pExcludedProperties)
          Clones the order at the repository level and then calls the OrderManager to load the order and return it.
 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.
 CloneEditState createCloneEditStateObject()
          Retuns a new CloneEditState.
 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  java.util.List detectUpdatesInFinalAmountInfo(java.lang.Object pClonedlPricedObject, java.lang.Object pOriginalPricedObject, java.lang.String pPropertyName)
          Creates a list of PropertyUpdates that reflect changes of amount and amountIsFinal in the price info property
 atg.userprofiling.PropertyUpdate findPropertyUpdate(java.lang.String pPropertyName, java.util.Collection pPropertyUpdates)
          Finds the PropertyUpdate object for the given property name.
 atg.commerce.catalog.CatalogTools getCatalogTools()
          Returns the CatalogTools that's passed into the reconcileOrder pipeline execution.
 CloneEditHandler[] getCloneEditHandlers()
          Returns the clone edit handlers
 java.util.Map getInitializeEditChains()
          Map of init edit order chain ids.
 java.lang.String getInitializeOrderEditChainId(atg.commerce.order.Order pOrder)
          Returns the init edit order chain id based on the state of the given order.
 atg.commerce.inventory.InventoryManager getInventoryManager()
          Returns the InventoryManager that's passed into the reconcileOrder pipeline execution.
 atg.commerce.order.OrderManager getOrderManager()
           
 atg.service.pipeline.PipelineManager getPipelineManager()
          Returns the pipelineManager
 java.lang.String getReconcileOrderChainId(atg.commerce.order.Order pOrder)
          Returns the reconcile order chain id based on the state of the given order.
 java.util.Map getReconcileOrderChains()
          Map of reconcile chain ids.
 javax.transaction.TransactionManager getTransactionManager()
          Transaction Manager
 void initializeCloneEditState(CloneEditState pCloneEditState, atg.commerce.order.Order pOriginalOrder, atg.commerce.order.Order pCloneOrder)
          Initializes the CloneEditState using the original and clone order
 CloneEditState initializeOrderEdit(atg.commerce.order.Order pOrder)
          Executes the pipeline chain that initializes the order edit process.
 void initializeReconciliationProcess(CloneEditState pCloneEditState)
          Prepares the CloneEditState for the reconciliation process.
 atg.service.pipeline.PipelineResult reconcileOrder(CloneEditState pCloneEditState, java.util.Map pExtraParameters)
          Runs the pipeline to reconcile the original order with the clone order.
protected  java.util.List reconcileProperties(java.lang.Object pClone, java.lang.Object pOrig, java.lang.String[] pProperties)
          Reconciles the properties between the original and clone objects by copying the property values from the clone to the original.
 void sendFulfillmentNotifications(CloneEditState pCloneEditState)
          Sends the ModifyOrderNotification for changes made to the original order.
 void setCatalogTools(atg.commerce.catalog.CatalogTools pCatalogTools)
           
 void setCloneEditHandlers(CloneEditHandler[] pCloneEditHandlers)
          Sets the clone edit handlers
 void setInitializeEditChains(java.util.Map pInitializeEditChains)
          Sets the map of order edit chain ids
 void setInventoryManager(atg.commerce.inventory.InventoryManager pInventoryManager)
           
 void setOrderManager(atg.commerce.order.OrderManager pOrderManager)
           
 void setReconcileOrderChains(java.util.Map pReconcileOrderChains)
           
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets the Transaction Manager.
 void validateClonedOrder(atg.commerce.order.Order pOriginalOrder, atg.commerce.order.Order pCloneOrder)
          Validates the clone order against the original order.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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

CLONEEDITSTATE

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

CLONEDITMANAGER

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

CLONEORDER

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

mCloneEditHandlers

protected CloneEditHandler[] mCloneEditHandlers

mTransactionManager

protected javax.transaction.TransactionManager mTransactionManager

mInventoryManager

protected atg.commerce.inventory.InventoryManager mInventoryManager

mCatalogTools

protected atg.commerce.catalog.CatalogTools mCatalogTools

mInitializeEditChains

protected java.util.Map mInitializeEditChains

mReconcileOrderChains

protected java.util.Map mReconcileOrderChains

mOrderManager

protected atg.commerce.order.OrderManager mOrderManager
Constructor Detail

CloneEditManager

public CloneEditManager()
Method Detail

setCloneEditHandlers

public void setCloneEditHandlers(CloneEditHandler[] pCloneEditHandlers)
Sets the clone edit handlers

CloneEditHandlers are components that are called are various points in the clone edit process. They can be used to clone and reconcile data between the original and clone orders.

See Also:
CloneEditHandler

getCloneEditHandlers

public CloneEditHandler[] getCloneEditHandlers()
Returns the clone edit handlers


setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets the Transaction Manager.


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Transaction Manager


getInventoryManager

public atg.commerce.inventory.InventoryManager getInventoryManager()
Returns the InventoryManager that's passed into the reconcileOrder pipeline execution.

Returns:
InventoryManager

setInventoryManager

public void setInventoryManager(atg.commerce.inventory.InventoryManager pInventoryManager)

getCatalogTools

public atg.commerce.catalog.CatalogTools getCatalogTools()
Returns the CatalogTools that's passed into the reconcileOrder pipeline execution.

Returns:
CatalogTools

setCatalogTools

public void setCatalogTools(atg.commerce.catalog.CatalogTools pCatalogTools)

getInitializeEditChains

public java.util.Map getInitializeEditChains()
Map of init edit order chain ids.

Chains are expected to be mapped by order state.

Returns:
Map
See Also:
getInitializeOrderEditChainId(Order)

setInitializeEditChains

public void setInitializeEditChains(java.util.Map pInitializeEditChains)
Sets the map of order edit chain ids


getReconcileOrderChains

public java.util.Map getReconcileOrderChains()
Map of reconcile chain ids.

Chains are expected to be mapped by order state.

Returns:
Map
See Also:
getReconcileOrderChainId(Order)

setReconcileOrderChains

public void setReconcileOrderChains(java.util.Map pReconcileOrderChains)

getInitializeOrderEditChainId

public java.lang.String getInitializeOrderEditChainId(atg.commerce.order.Order pOrder)
Returns the init edit order chain id based on the state of the given order.

Returns:
The name of the pipeline chain used to initialize the order edit process
See Also:
getInitializeEditChains()

getReconcileOrderChainId

public java.lang.String getReconcileOrderChainId(atg.commerce.order.Order pOrder)
Returns the reconcile order chain id based on the state of the given order.

Returns:
the name of the pipeline chain use to reconcile the edit updates
See Also:
getReconcileOrderChains()

getPipelineManager

public atg.service.pipeline.PipelineManager getPipelineManager()
Returns the pipelineManager


getOrderManager

public atg.commerce.order.OrderManager getOrderManager()
Returns:
the OrderManager

setOrderManager

public void setOrderManager(atg.commerce.order.OrderManager pOrderManager)

createCloneEditStateObject

public CloneEditState createCloneEditStateObject()
Retuns a new CloneEditState. Override this method to return your own extended class.

Returns:
a new CloneEditState object

initializeOrderEdit

public CloneEditState initializeOrderEdit(atg.commerce.order.Order pOrder)
                                   throws atg.commerce.CommerceException
Executes the pipeline chain that initializes the order edit process.

The CloneEditState is created, initialized and returned. This object is used as input to several of the API for this process.

Executes the configured pipeline for initializing the edit process.

Parameters:
pOrder - the original order
Returns:
the CloneEditState
Throws:
atg.commerce.CommerceException
See Also:
getInitializeOrderEditChainId(Order)

cloneOrder

public atg.commerce.order.Order cloneOrder(atg.commerce.order.Order pOrder,
                                           java.util.Map pPropExceptions,
                                           java.util.Map pExcludedProperties)
                                    throws atg.commerce.CommerceException
Clones the order at the repository level and then calls the OrderManager to load the order and return it.

The cloneOrder method is executed on all the clone edit handlers.

Parameters:
pOrder - the order to clone
pPropExceptions -
pExcludedProperties -
Returns:
the clone Order
Throws:
atg.commerce.CommerceException
See Also:
RepositoryUtils.cloneItem(RepositoryItem, boolean, Map, Map, MutableRepository, String)

reconcileOrder

public atg.service.pipeline.PipelineResult reconcileOrder(CloneEditState pCloneEditState,
                                                          java.util.Map pExtraParameters)
                                                   throws atg.commerce.CommerceException
Runs the pipeline to reconcile the original order with the clone order.

This method registers and transaction synchronization that's used to invalidate the original and clone orders when the transaction is rolled back due to errors.

All errors during this process will set the transaction to rollback only.

Before reconciling, as a convenience, the CloneEditState is added as a local thread variable.

Parameters:
pCloneEditState - the clone edit state object
pExtraParameters - map of parameters passed to the pipeline execution
Throws:
atg.commerce.CommerceException
See Also:
CloneOrderStateContext

applyChanges

public void applyChanges(CloneEditState pCloneEditState)
                  throws atg.commerce.CommerceException
Applies all the changes in the clone to the original order.

The applyChanges method is executed on all the clone edit handlers.

Parameters:
pCloneEditState -
Throws:
atg.commerce.CommerceException

reconcileProperties

protected java.util.List reconcileProperties(java.lang.Object pClone,
                                             java.lang.Object pOrig,
                                             java.lang.String[] pProperties)
Reconciles the properties between the original and clone objects by copying the property values from the clone to the original.

Parameters:
pClone -
pOrig -
pProperties - an array of property names that are copied from the clone to the original object.

validateClonedOrder

public void validateClonedOrder(atg.commerce.order.Order pOriginalOrder,
                                atg.commerce.order.Order pCloneOrder)
                         throws atg.commerce.CommerceException
Validates the clone order against the original order.

Calls each CloneEditHandler's validateCloneOrder method.

Parameters:
pOriginalOrder -
pCloneOrder -
Throws:
atg.commerce.CommerceException - if sizes don't match

initializeCloneEditState

public void initializeCloneEditState(CloneEditState pCloneEditState,
                                     atg.commerce.order.Order pOriginalOrder,
                                     atg.commerce.order.Order pCloneOrder)
                              throws atg.commerce.CommerceException
Initializes the CloneEditState using the original and clone order

Calls each initializeCloneEditState's validateCloneOrder method.

Parameters:
pCloneEditState - state object to initialize
pOriginalOrder - the original order
pCloneOrder - the clone order
Throws:
atg.commerce.CommerceException

initializeReconciliationProcess

public void initializeReconciliationProcess(CloneEditState pCloneEditState)
                                     throws atg.commerce.CommerceException
Prepares the CloneEditState for the reconciliation process.

Calls each CloneEditHandler's initializeReconciliationProcess method.

Throws:
atg.commerce.CommerceException
See Also:
CloneEditHandler.initializeReconciliationProcess(CloneEditState)

findPropertyUpdate

public atg.userprofiling.PropertyUpdate findPropertyUpdate(java.lang.String pPropertyName,
                                                           java.util.Collection pPropertyUpdates)
Finds the PropertyUpdate object for the given property name.

Parameters:
pPropertyName - the property name to find
pPropertyUpdates - the collection of PropertyUpdates
Returns:
PropertyUpdate
See Also:
PropertyUpdate

sendFulfillmentNotifications

public void sendFulfillmentNotifications(CloneEditState pCloneEditState)
                                  throws javax.jms.JMSException,
                                         atg.commerce.CommerceException
Sends the ModifyOrderNotification for changes made to the original order. Calls each CloneEditHandler's sendFulfillmentMessages method.

Parameters:
pCloneEditState -
Throws:
javax.jms.JMSException
atg.commerce.CommerceException

detectUpdatesInFinalAmountInfo

protected java.util.List detectUpdatesInFinalAmountInfo(java.lang.Object pClonedlPricedObject,
                                                        java.lang.Object pOriginalPricedObject,
                                                        java.lang.String pPropertyName)
Creates a list of PropertyUpdates that reflect changes of amount and amountIsFinal in the price info property

Parameters:
pClonedlPricedObject - the clone object that contains a price info property
pOriginalPricedObject - the original object that contains a price info property
pPropertyName - the name of the property containing the price info object.
Returns:
List of PropertyUpdates

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
pCloneContainter - the clone object container
Returns:
UpdateItem

buildPropertyValueMap

public java.util.Map buildPropertyValueMap(java.lang.Object pObject)
Iterates over all the properties of the object and creates a map of their values.

Parameters:
pObject -
Returns:
Map of property values