atg.commerce.order.edit
Class HandlingInstructionEditHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.edit.CloneEditHandler
              extended by atg.commerce.order.edit.CollectionEditHandler
                  extended by atg.commerce.order.edit.ListEditHandler
                      extended by atg.commerce.order.edit.HandlingInstructionEditHandler
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

public class HandlingInstructionEditHandler
extends ListEditHandler

This handler updates handling instructions between the clone and original order and reconciles the gift repository based on the changes.

See Also:
ListEditHandler

Field Summary
static java.lang.String CLASS_VERSION
           
protected  CommerceItemEditHandler mCommerceItemEditHandler
           
protected  GiftlistManager mGiftlistManager
           
protected  HandlingInstructionManager mHandlingInstructionManager
           
protected  ShippingGroupEditHandler mShippingGroupEditHandler
           
 
Fields inherited from class atg.commerce.order.edit.CollectionEditHandler
mCollectionPropertyName, mSortPropertyName, mSubPropertyHandlers, mThrowExceptionsForCollectionChanges, STATE_CLONETOORIGINAL_MAP, STATE_ORIGINALTOCLONE_MAP
 
Fields inherited from class atg.commerce.order.edit.CloneEditHandler
mFulfillmentMessageSender, mKeyPropertyName, mOrderFulfillmentTools, mPropertiesToCopyOnUpdate, STATE_ADD_ITEMS, STATE_DELETE_ITEMS, STATE_UPDATE_ITEMS
 
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
HandlingInstructionEditHandler()
           
 
Method Summary
protected  void addItem(CloneEditState pCloneEditState, AddItem pAddItem)
          Overrides add item to use the handling group container interfaces to add the new handling instruction.
 void adjustCloneCommerceIdReferences(CloneEditState pCloneEditState)
          Adjusts the commerceItemId and shippingGroupId in eac hclone handling instruction to reference the clone commerce item and shipping group id.
protected  void adjustCloneHandlingInstructionReferences(CloneEditState pCloneEditState, HandlingInstruction pHandlingInstruction)
          Adjusts the handling instruction's commerce item and shipping group id properties so they reference the ids of the clone objects.
protected  void adjustHandlingInstructionReferences(CloneEditState pCloneEditState, HandlingInstruction pHandlingInstruction)
          Changes the commerceItemId and shippingGroupId of the handling instruction to their original order counter parts.
 void adjustOriginalCommerceIdReferences(CloneEditState pCloneEditState)
          Adjusts the commerceItemId and shippingGroupId in each original order handling instruction to reference the original commerce item and shipping group id.
 void applyChanges(CloneEditState pCloneEditState)
          Extends the base behavior to update the commerce item and shipping group handling instruction references to match the original counterparts.
protected  void deleteItem(CloneEditState pCloneEditState, DeleteItem pDeleteItem)
          Overrides delete item to use the handling instruction container interfaces to remove the item
protected  void detectChangesToCollection(CloneEditState pCloneEditState, java.lang.Object pOriginalCollectionContainer, java.lang.Object pCloneCollectionContainer)
          Extends the base behavior by first getting the shipping group lists from the containers and calling super with the shipping group lists.
protected  void detectRemovedHandlingInstructions(CloneEditState pCloneEditState)
          Iterates over all the handling instructions that were originally mapped and determines if any of the clone shipping groups contain the counterpart clone handling instruction .
protected  void detectUpdatesForNewShippingGroup(CloneEditState pCloneEditState, ShippingGroup pNewShippingGroup)
          Iterates over all the new shipping groups in the clone order (e.g.
protected  ShippingGroup findCloneShippingGroupForHI(CloneEditState pCloneEditState, java.lang.String pCloneHIId)
          Finds the clone shipping group that contains the given clone handling instruction
protected  ShippingGroup findOriginalShippingGroupForHI(CloneEditState pCloneEditState, java.lang.String pOriginalHIId)
          Finds the original shipping group that contains the given original handling instruction
 CommerceItemEditHandler getCommerceItemEditHandler()
          Reference to the CommerceItemEditHandler used to access commerce item meta-deta generated from the cloning process.
 GiftlistManager getGiftlistManager()
          All Giftlist manipulations are done with this.
 HandlingInstructionManager getHandlingInstructionManager()
          The HandlingInstruction manager
 ShippingGroupEditHandler getShippingGroupEditHandler()
          Reference to the ShippingGroupEditHandler used to access shipping group meta-deta generated from the cloning process.
protected  boolean handleMissingOriginalObject(CloneEditState pCloneEditState, java.lang.Object pCloneContainer, java.lang.Object pCloneObject, java.lang.Object pOriginalContainer, java.lang.Object pOriginalCounterPartKey)
          If an original handling instruction cannot be found in original shipping group associated with the clone shipping group, it could mean the handling instruction was moved during updates to a difference clone shipping group.
protected  void mapOriginalToClone(CloneEditState pCloneEditState, Order pOriginalOrder, Order pCloneOrder)
          Overrides base behavior to process all the CommerceItemContainers starting with the order.
protected  void moveItem(CloneEditState pCloneEditState, UpdateItem pUpdateItem)
          This API is called by updateItem the original container specified in the UpdateItem isn't the container that maps to the clone container and handles the move operation.
 void reconcileGiftlistRepository(CloneEditState pCloneEditState)
          Reconciles the gift list quantity purchased for updated, added and removed giftlist handling instructions.
protected  void reconcileGiftRepositoryForAddedHIs(CloneEditState pCloneEditState)
          Reconciles the gift repository based on the AddItems generated during reconcilication.
protected  void reconcileGiftRepositoryForDeletedHIs(CloneEditState pCloneEditState)
          Reconciles the gift repository based on the DeleteItems generated during reconcilication.
protected  void reconcileGiftRepositoryForNewShippingGroups(CloneEditState pCloneEditState)
          Reconciles the gift repository for any new gift handling instructions that may have been added to new shipping groups in the clone order.
protected  void reconcileGiftRepositoryForUpdatedHIs(CloneEditState pCloneEditState)
          Reconciles the gift repository based on the UpdateItems generated during reconcilication.
 void setCommerceItemEditHandler(CommerceItemEditHandler pCommerceItemEditHandler)
           
 void setGiftlistManager(GiftlistManager pGiftlistManager)
           
 void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
          Specifies the HandlingInstructionManager.
 void setShippingGroupEditHandler(ShippingGroupEditHandler pShippingGroupEditHandler)
           
protected  void updateItem(CloneEditState pCloneEditState, UpdateItem pUpdateItem)
          Extends the base behavior to handle the condition where the handling instruction moved from one shipping group to another.
protected  void validateCollection(Order pOriginalOrder, Order pCloneOrder)
          Validates the handling instruction collections for each shipping group in the order.
 
Methods inherited from class atg.commerce.order.edit.CollectionEditHandler
detectChanges, detectDeletes, executeSubPropertyHandlerInitialization, executeSubPropertyHandlerUpdates, executeSubPropertyHandlerValidation, findCounterpartObject, getCloneToOriginalMap, getCollection, getCollectionPropertyName, getMatchingCloneKey, getMatchingOriginalKey, getOriginalToCloneMap, getSortedCollection, getSortPropertyName, getSubPropertyHandlers, initializeCloneEditState, isSubPropertyHandlers, isThrowExceptionsForCollectionChanges, mapOriginalToCloneCollection, saveOriginalToCloneObjectMappings, setCollectionPropertyName, setSortPropertyName, setSubPropertyHandlers, setThrowExceptionsForCollectionChanges, sortCollection, validateCloneOrder, validateCollection, validateCollectionSize
 
Methods inherited from class atg.commerce.order.edit.CloneEditHandler
addAddItem, addDeleteItem, addStateData, addUpdateItem, cloneOrder, copyPricingModels, createAddItem, createDeleteItem, createUpdateItem, generateModifications, getAddItems, getCloneEditManager, getDeleteItems, getFulfillmentMessageSender, getKeyForObject, getKeyPropertyName, getObjectType, getOrderFulfillmentTools, getPropertiesToCopy, getPropertiesToCopyOnUpdate, getStateData, getStateMap, getUpdateItems, initializeReconciliationProcess, isAddedItem, parseConfigString, processAddItems, processDeleteItems, processUpdateItems, reconcileObjectProperties, sendFulfillmentNotifications, sendMessage, setCloneEditManager, setFulfillmentMessageSender, setKeyPropertyName, setOrderFulfillmentTools, setPropertiesToCopyOnUpdate
 
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

mGiftlistManager

protected GiftlistManager mGiftlistManager

mCommerceItemEditHandler

protected CommerceItemEditHandler mCommerceItemEditHandler

mShippingGroupEditHandler

protected ShippingGroupEditHandler mShippingGroupEditHandler

mHandlingInstructionManager

protected HandlingInstructionManager mHandlingInstructionManager
Constructor Detail

HandlingInstructionEditHandler

public HandlingInstructionEditHandler()
Method Detail

setGiftlistManager

public void setGiftlistManager(GiftlistManager pGiftlistManager)

getGiftlistManager

public GiftlistManager getGiftlistManager()
All Giftlist manipulations are done with this.


getCommerceItemEditHandler

public CommerceItemEditHandler getCommerceItemEditHandler()
Reference to the CommerceItemEditHandler used to access commerce item meta-deta generated from the cloning process.


setCommerceItemEditHandler

public void setCommerceItemEditHandler(CommerceItemEditHandler pCommerceItemEditHandler)

getShippingGroupEditHandler

public ShippingGroupEditHandler getShippingGroupEditHandler()
Reference to the ShippingGroupEditHandler used to access shipping group meta-deta generated from the cloning process.


setShippingGroupEditHandler

public void setShippingGroupEditHandler(ShippingGroupEditHandler pShippingGroupEditHandler)

setHandlingInstructionManager

public void setHandlingInstructionManager(HandlingInstructionManager pHandlingInstructionManager)
Specifies the HandlingInstructionManager.

Parameters:
pHandlingInstructionManager - a HandlingInstructionManager value

getHandlingInstructionManager

public HandlingInstructionManager getHandlingInstructionManager()
The HandlingInstruction manager

Returns:
a HandlingInstructionManager value

mapOriginalToClone

protected void mapOriginalToClone(CloneEditState pCloneEditState,
                                  Order pOriginalOrder,
                                  Order pCloneOrder)
                           throws CommerceException
Overrides base behavior to process all the CommerceItemContainers starting with the order.

Overrides:
mapOriginalToClone in class CollectionEditHandler
Throws:
CommerceException
See Also:
CollectionEditHandler.mapOriginalToCloneCollection(CloneEditState, Collection, Collection)

detectChangesToCollection

protected void detectChangesToCollection(CloneEditState pCloneEditState,
                                         java.lang.Object pOriginalCollectionContainer,
                                         java.lang.Object pCloneCollectionContainer)
                                  throws CommerceException
Extends the base behavior by first getting the shipping group lists from the containers and calling super with the shipping group lists.

Overrides:
detectChangesToCollection in class CollectionEditHandler
Parameters:
pCloneEditState - the CloneEditState that was created at the beginning of the clone process.
pOriginalCollectionContainer - the object that has the original collection in the property defined by collectionPropertyName
pCloneCollectionContainer - the object that has the clone collection in the property defined by collectionPropertyName
Throws:
CommerceException

detectRemovedHandlingInstructions

protected void detectRemovedHandlingInstructions(CloneEditState pCloneEditState)
Iterates over all the handling instructions that were originally mapped and determines if any of the clone shipping groups contain the counterpart clone handling instruction .

If the clone counterpart cannot be found anywhere in the clone order, a DeleteItem is created for the original handling instruction.

Parameters:
pCloneEditState -

detectUpdatesForNewShippingGroup

protected void detectUpdatesForNewShippingGroup(CloneEditState pCloneEditState,
                                                ShippingGroup pNewShippingGroup)
Iterates over all the new shipping groups in the clone order (e.g. groups that were added after the clone order was created) and determines if they have any handling instructions that may have been moved from their originating clone shipping group. These would be any clone handling instruction that maps to an original handling instruction. This can happen if handling instructions move during the order modification process.

An UpdateItem is generated for each one found to be moved to a new shipping group.

Parameters:
pCloneEditState -
pNewShippingGroup -

applyChanges

public void applyChanges(CloneEditState pCloneEditState)
                  throws CommerceException
Extends the base behavior to update the commerce item and shipping group handling instruction references to match the original counterparts.

Also reconciles the gift repository based on updates made to gift handling instructions

Overrides:
applyChanges in class CollectionEditHandler
Throws:
CommerceException
See Also:
reconcileGiftlistRepository(CloneEditState)

addItem

protected void addItem(CloneEditState pCloneEditState,
                       AddItem pAddItem)
                throws CommerceException
Overrides add item to use the handling group container interfaces to add the new handling instruction.

Overrides:
addItem in class ListEditHandler
Parameters:
pCloneEditState -
pAddItem -
Throws:
CommerceException

deleteItem

protected void deleteItem(CloneEditState pCloneEditState,
                          DeleteItem pDeleteItem)
                   throws CommerceException
Overrides delete item to use the handling instruction container interfaces to remove the item

Overrides:
deleteItem in class CollectionEditHandler
Parameters:
pCloneEditState -
pDeleteItem - the DeleteItem object
Throws:
CommerceException

adjustHandlingInstructionReferences

protected void adjustHandlingInstructionReferences(CloneEditState pCloneEditState,
                                                   HandlingInstruction pHandlingInstruction)
Changes the commerceItemId and shippingGroupId of the handling instruction to their original order counter parts.

Parameters:
pCloneEditState -
pHandlingInstruction -

adjustCloneHandlingInstructionReferences

protected void adjustCloneHandlingInstructionReferences(CloneEditState pCloneEditState,
                                                        HandlingInstruction pHandlingInstruction)
Adjusts the handling instruction's commerce item and shipping group id properties so they reference the ids of the clone objects.

The clones are the counterparts to the current original commerce item and shipping group ids being referenced.

Parameters:
pCloneEditState -
pHandlingInstruction -

reconcileGiftlistRepository

public void reconcileGiftlistRepository(CloneEditState pCloneEditState)
                                 throws CommerceException
Reconciles the gift list quantity purchased for updated, added and removed giftlist handling instructions. This is done based on the DeleteItems, UpdateItems and AddItems generated during the update detected process.

Also reconciles new handling instructions added to new shipping groups.

Parameters:
pCloneEditState -
Throws:
CommerceException
See Also:
CloneEditHandler.getDeleteItems(CloneEditState), CloneEditHandler.getAddItems(CloneEditState), CloneEditHandler.getUpdateItems(CloneEditState), reconcileGiftRepositoryForNewShippingGroups(CloneEditState)

reconcileGiftRepositoryForAddedHIs

protected void reconcileGiftRepositoryForAddedHIs(CloneEditState pCloneEditState)
                                           throws CommerceException
Reconciles the gift repository based on the AddItems generated during reconcilication.

Parameters:
pCloneEditState -
Throws:
CommerceException

reconcileGiftRepositoryForUpdatedHIs

protected void reconcileGiftRepositoryForUpdatedHIs(CloneEditState pCloneEditState)
                                             throws CommerceException
Reconciles the gift repository based on the UpdateItems generated during reconcilication.

Parameters:
pCloneEditState -
Throws:
CommerceException

reconcileGiftRepositoryForDeletedHIs

protected void reconcileGiftRepositoryForDeletedHIs(CloneEditState pCloneEditState)
                                             throws CommerceException
Reconciles the gift repository based on the DeleteItems generated during reconcilication.

Parameters:
pCloneEditState -
Throws:
CommerceException

reconcileGiftRepositoryForNewShippingGroups

protected void reconcileGiftRepositoryForNewShippingGroups(CloneEditState pCloneEditState)
                                                    throws CommerceException
Reconciles the gift repository for any new gift handling instructions that may have been added to new shipping groups in the clone order.

Parameters:
pCloneEditState -
Throws:
CommerceException

validateCollection

protected void validateCollection(Order pOriginalOrder,
                                  Order pCloneOrder)
                           throws CommerceException
Validates the handling instruction collections for each shipping group in the order.

Overrides:
validateCollection in class CollectionEditHandler
Throws:
CommerceException
See Also:
CollectionEditHandler.validateCollectionSize(Object, Object)

adjustCloneCommerceIdReferences

public void adjustCloneCommerceIdReferences(CloneEditState pCloneEditState)
                                     throws CommerceException
Adjusts the commerceItemId and shippingGroupId in eac hclone handling instruction to reference the clone commerce item and shipping group id.

Overrides:
adjustCloneCommerceIdReferences in class CloneEditHandler
Throws:
CommerceException

adjustOriginalCommerceIdReferences

public void adjustOriginalCommerceIdReferences(CloneEditState pCloneEditState)
                                        throws CommerceException
Adjusts the commerceItemId and shippingGroupId in each original order handling instruction to reference the original commerce item and shipping group id. The originals are the counterparts to the current clone commerce item and shipping group ids being referenced.

Overrides:
adjustOriginalCommerceIdReferences in class CloneEditHandler
Throws:
CommerceException

handleMissingOriginalObject

protected boolean handleMissingOriginalObject(CloneEditState pCloneEditState,
                                              java.lang.Object pCloneContainer,
                                              java.lang.Object pCloneObject,
                                              java.lang.Object pOriginalContainer,
                                              java.lang.Object pOriginalCounterPartKey)
                                       throws CommerceException
If an original handling instruction cannot be found in original shipping group associated with the clone shipping group, it could mean the handling instruction was moved during updates to a difference clone shipping group.

This implementation will search for the missing original object in the other original shipping groups. If found, a new UpdateItem is generated.

updateItem is implemented to recognize that the original container specified in the UpdateItem isn't the container that maps to the clone container and handles the move operation.

Overrides:
handleMissingOriginalObject in class CollectionEditHandler
pCloneContainer - the container where the clone object is located
pCloneObject - the clone object for which the original object is missing
pOriginalContainer - the original container from which the original object is missing
pOriginalCounterPartKey - the key of the missing original object.
Returns:
true if the condition was successfully handled.
Throws:
CommerceException
See Also:
updateItem(CloneEditState, UpdateItem)

findOriginalShippingGroupForHI

protected ShippingGroup findOriginalShippingGroupForHI(CloneEditState pCloneEditState,
                                                       java.lang.String pOriginalHIId)
Finds the original shipping group that contains the given original handling instruction

Parameters:
pCloneEditState -
pOriginalHIId - the handling instruction id to find
Returns:
the original shipping group, if found

findCloneShippingGroupForHI

protected ShippingGroup findCloneShippingGroupForHI(CloneEditState pCloneEditState,
                                                    java.lang.String pCloneHIId)
Finds the clone shipping group that contains the given clone handling instruction

Parameters:
pCloneEditState -
pCloneHIId - the handling instruction id to find
Returns:
the clone shipping group, if found

updateItem

protected void updateItem(CloneEditState pCloneEditState,
                          UpdateItem pUpdateItem)
                   throws CommerceException
Extends the base behavior to handle the condition where the handling instruction moved from one shipping group to another.

A move occurs when the original container specified in the UpdateItem isn't the container that maps to the clone container.

Overrides:
updateItem in class CloneEditHandler
Throws:
CommerceException
See Also:
moveItem(CloneEditState, UpdateItem)

moveItem

protected void moveItem(CloneEditState pCloneEditState,
                        UpdateItem pUpdateItem)
                 throws CommerceException
This API is called by updateItem the original container specified in the UpdateItem isn't the container that maps to the clone container and handles the move operation.

Parameters:
pCloneEditState -
pUpdateItem -
Throws:
CommerceException