atg.commerce.inventory
Class AbstractInventoryManagerImpl

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.inventory.AbstractInventoryManagerImpl
All Implemented Interfaces:
InventoryManager, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
NoInventoryManager

public abstract class AbstractInventoryManagerImpl
extends GenericService
implements InventoryManager

This class is designed to be a convenient way of quickly implementing an inventory manager. It reflects the idea that a minimal InventoryManager implementation must merely flesh out the purchase method. All other methods are optional.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.commerce.inventory.InventoryManager
AVAILABILITY_STATUS_BACKORDERABLE, AVAILABILITY_STATUS_DERIVED, AVAILABILITY_STATUS_DISCONTINUED, AVAILABILITY_STATUS_IN_STOCK, AVAILABILITY_STATUS_OUT_OF_STOCK, AVAILABILITY_STATUS_PREORDERABLE, INVENTORY_STATUS_FAIL, INVENTORY_STATUS_INSUFFICIENT_SUPPLY, INVENTORY_STATUS_ITEM_NOT_FOUND, INVENTORY_STATUS_SUCCEED
 
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
AbstractInventoryManagerImpl()
           
 
Method Summary
 void acquireInventoryLocks(java.util.List pItemIds)
          Acquires locks for the inventory items that apply to the given ids.
 int backorder(java.lang.String pId, long pHowMany)
          Backorder an item.
 int decreaseBackorderLevel(java.lang.String pId, long pNumber)
          Decrease an item's backorder level by the specified amount.
 int decreasePreorderLevel(java.lang.String pId, long pNumber)
          Decrease an item's preorder level by the specified amount.
 int decreaseStockLevel(java.lang.String pId, long pNumber)
          Decrease an item's stock level by the specified amount.
 java.lang.String getInventoryName()
          The displayable name of this inventory manager.
 int increaseBackorderLevel(java.lang.String pId, long pNumber)
          Increase an item's backorder level by the specified number.
 int increasePreorderLevel(java.lang.String pId, long pNumber)
          Increase an item's preorder level by the specified number.
 int increaseStockLevel(java.lang.String pId, long pNumber)
          Increase an item's stock level by the specified number.
 int inventoryWasUpdated(java.util.List pItemIds)
          Informs the inventory manager that the given ids are now available.
 int preorder(java.lang.String pId, long pHowMany)
          Preorder an item.
abstract  int purchase(java.lang.String pId, long pHowMany)
          Actually purchases a product.
 int purchaseOffBackorder(java.lang.String pId, long pHowMany)
          Actually purchases a product.
 int purchaseOffPreorder(java.lang.String pId, long pHowMany)
          Actually purchases a product.
 java.util.Date queryAvailabilityDate(java.lang.String pId)
          Return the availability date of an item.
 int queryAvailabilityStatus(java.lang.String pId)
          Return the availability status of a given item.
 long queryBackorderLevel(java.lang.String pId)
          Return how many of a given item are available for preorder.
 long queryBackorderThreshold(java.lang.String pId)
          Return the threshold associated with backorderLevel
 long queryPreorderLevel(java.lang.String pId)
          Return how many of a given item are available for backorder.
 long queryPreorderThreshold(java.lang.String pId)
          Return the threshold associated with preorderLevel
 long queryStockLevel(java.lang.String pId)
          Return how many of a given item are in the system.
 long queryStockThreshold(java.lang.String pId)
          Return the threshold associated with stockLevel.
 void releaseInventoryLocks(java.util.List pItemIds)
          Release locks for the inventory items that apply to the given ids.
 int setAvailabilityDate(java.lang.String pId, java.util.Date pDate)
          Set an item's availability date.
 int setAvailabilityStatus(java.lang.String pId, int pStatus)
          Set an item's availability status.
 int setBackorderLevel(java.lang.String pId, long pNumber)
          Set an item's backorder level to the specified number.
 int setBackorderThreshold(java.lang.String pId, long pNumber)
          Set an item's backorder level threshold.
 int setPreorderLevel(java.lang.String pId, long pNumber)
          Set an item's preorder level to the specified number.
 int setPreorderThreshold(java.lang.String pId, long pNumber)
          Set an item's preorder level threshold.
 int setStockLevel(java.lang.String pId, long pNumber)
          Set an item's stock level to the specified number.
 int setStockThreshold(java.lang.String pId, long pNumber)
          Set an item's stock level threshold.
 
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, reResolveThis, 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 java.lang.String CLASS_VERSION
Constructor Detail

AbstractInventoryManagerImpl

public AbstractInventoryManagerImpl()
Method Detail

getInventoryName

public java.lang.String getInventoryName()
The displayable name of this inventory manager.

Specified by:
getInventoryName in interface InventoryManager

purchase

public abstract int purchase(java.lang.String pId,
                             long pHowMany)
                      throws InventoryException
Actually purchases a product. The backend inventory system should register that a purchase has been made.

Specified by:
purchase in interface InventoryManager
Parameters:
pId - the id of the item involved
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem during the purchase process.

purchaseOffBackorder

public int purchaseOffBackorder(java.lang.String pId,
                                long pHowMany)
                         throws InventoryException
Actually purchases a product. The backend inventory system should register that a purchase has been made. If the purchase succeeds, the item's backorderLevel is increased appropriately.

Specified by:
purchaseOffBackorder in interface InventoryManager
Parameters:
pId - the id of the item involved
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem during the purchase process.

purchaseOffPreorder

public int purchaseOffPreorder(java.lang.String pId,
                               long pHowMany)
                        throws InventoryException
Actually purchases a product. The backend inventory system should register that a purchase has been made. If the purchase succeeds, the item's preorderLevel is increased appropriately.

Specified by:
purchaseOffPreorder in interface InventoryManager
Parameters:
pId - the id of the item involved
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem during the purchase process.

preorder

public int preorder(java.lang.String pId,
                    long pHowMany)
             throws InventoryException
Preorder an item. The usual implication of preordering is that the retailer has never had the item in stock, but promises to have the item soon.

Specified by:
preorder in interface InventoryManager
Parameters:
pId - the id of the item involved
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem in trying to preorder the item

backorder

public int backorder(java.lang.String pId,
                     long pHowMany)
              throws InventoryException
Backorder an item. The usual implication of this is very similar to preorder, except that the store did at one time have this item, it's just out of it now.

Specified by:
backorder in interface InventoryManager
Parameters:
pId - the id of the item involved
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem with the backordering process.

setStockLevel

public int setStockLevel(java.lang.String pId,
                         long pNumber)
                  throws InventoryException
Set an item's stock level to the specified number.

Specified by:
setStockLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setBackorderLevel

public int setBackorderLevel(java.lang.String pId,
                             long pNumber)
                      throws InventoryException
Set an item's backorder level to the specified number.

Specified by:
setBackorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setPreorderLevel

public int setPreorderLevel(java.lang.String pId,
                            long pNumber)
                     throws InventoryException
Set an item's preorder level to the specified number.

Specified by:
setPreorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

increaseStockLevel

public int increaseStockLevel(java.lang.String pId,
                              long pNumber)
                       throws InventoryException
Increase an item's stock level by the specified number.

Specified by:
increaseStockLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to add to the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

decreaseStockLevel

public int decreaseStockLevel(java.lang.String pId,
                              long pNumber)
                       throws InventoryException
Decrease an item's stock level by the specified amount. This method is to be used for inventory adjustments, not for purchases. For purchases, use the purchase(String pId, long pHowMany) method.

Specified by:
decreaseStockLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to decrease from the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

increaseBackorderLevel

public int increaseBackorderLevel(java.lang.String pId,
                                  long pNumber)
                           throws InventoryException
Increase an item's backorder level by the specified number.

Specified by:
increaseBackorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to add to the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

decreaseBackorderLevel

public int decreaseBackorderLevel(java.lang.String pId,
                                  long pNumber)
                           throws InventoryException
Decrease an item's backorder level by the specified amount.

Specified by:
decreaseBackorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to decrease from the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

increasePreorderLevel

public int increasePreorderLevel(java.lang.String pId,
                                 long pNumber)
                          throws InventoryException
Increase an item's preorder level by the specified number.

Specified by:
increasePreorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to add to the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

decreasePreorderLevel

public int decreasePreorderLevel(java.lang.String pId,
                                 long pNumber)
                          throws InventoryException
Decrease an item's preorder level by the specified amount.

Specified by:
decreasePreorderLevel in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of items to decrease from the current stock level
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setStockThreshold

public int setStockThreshold(java.lang.String pId,
                             long pNumber)
                      throws InventoryException
Set an item's stock level threshold.

Specified by:
setStockThreshold in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setBackorderThreshold

public int setBackorderThreshold(java.lang.String pId,
                                 long pNumber)
                          throws InventoryException
Set an item's backorder level threshold.

Specified by:
setBackorderThreshold in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setPreorderThreshold

public int setPreorderThreshold(java.lang.String pId,
                                long pNumber)
                         throws InventoryException
Set an item's preorder level threshold.

Specified by:
setPreorderThreshold in interface InventoryManager
Parameters:
pId - the id of the item involved
pNumber - the number of the given item to restock
Returns:
INVENTORY_STATUS_SUCCEED or INVENTORY_STATUS_FAIL
Throws:
InventoryException - if there was a problem trying to restock

setAvailabilityStatus

public int setAvailabilityStatus(java.lang.String pId,
                                 int pStatus)
                          throws InventoryException
Set an item's availability status.

Specified by:
setAvailabilityStatus in interface InventoryManager
Parameters:
pId - the id of the item involved
pStatus - the new status (one of AVAILABILITY_STATUS_IN_STOCK, AVAILABILITY_STATUS_BACKORDERABLE, AVAILABILITY_STATUS_PREORDERABLE, AVAILABILITY_STATUS_OUT_OF_STOCK, AVAILABILITY_STATUS_DISCONTINUED, or AVAILABILITY_STATUS_DERIVED)
Returns:
INVENTORY_STATUS_SUCCEED, INVENTORY_STATUS_ITEM_NOT_FOUND, or INVENTORY_STATUS_FAIL
Throws:
InventoryException

setAvailabilityDate

public int setAvailabilityDate(java.lang.String pId,
                               java.util.Date pDate)
                        throws InventoryException
Set an item's availability date.

Specified by:
setAvailabilityDate in interface InventoryManager
Parameters:
pId - the id of the item involved
pDate - The new availability date for the item.
Returns:
INVENTORY_STATUS_SUCCEED, INVENTORY_STATUS_ITEM_NOT_FOUND, or INVENTORY_STATUS_FAIL
Throws:
InventoryException

queryAvailabilityStatus

public int queryAvailabilityStatus(java.lang.String pId)
                            throws InventoryException
Return the availability status of a given item.

Specified by:
queryAvailabilityStatus in interface InventoryManager
Returns:
AVAILABILITY_STATUS_IN_STOCK
Throws:
InventoryException - if there was a problem determining the status of the item

queryStockLevel

public long queryStockLevel(java.lang.String pId)
                     throws InventoryException
Return how many of a given item are in the system.

Specified by:
queryStockLevel in interface InventoryManager
Returns:
how many items, with the given id, are available for purchase
Throws:
InventoryException - if there was a problem determining the number

queryPreorderLevel

public long queryPreorderLevel(java.lang.String pId)
                        throws InventoryException
Return how many of a given item are available for backorder.

Specified by:
queryPreorderLevel in interface InventoryManager
Returns:
how many items, with the given id, are available for backorder
Throws:
InventoryException - if there was a problem determining the number

queryBackorderLevel

public long queryBackorderLevel(java.lang.String pId)
                         throws InventoryException
Return how many of a given item are available for preorder.

Specified by:
queryBackorderLevel in interface InventoryManager
Returns:
how many items, with the given id, are available for preorder
Throws:
InventoryException - if there was a problem determining the number

queryStockThreshold

public long queryStockThreshold(java.lang.String pId)
                         throws InventoryException
Return the threshold associated with stockLevel.

Specified by:
queryStockThreshold in interface InventoryManager
Returns:
how many items, with the given id, are available for purchase
Throws:
InventoryException - if there was a problem determining the number

queryBackorderThreshold

public long queryBackorderThreshold(java.lang.String pId)
                             throws InventoryException
Return the threshold associated with backorderLevel

Specified by:
queryBackorderThreshold in interface InventoryManager
Returns:
how many items, with the given id, are available for purchase
Throws:
InventoryException - if there was a problem determining the number

queryPreorderThreshold

public long queryPreorderThreshold(java.lang.String pId)
                            throws InventoryException
Return the threshold associated with preorderLevel

Specified by:
queryPreorderThreshold in interface InventoryManager
Returns:
how many items, with the given id, are available for purchase
Throws:
InventoryException - if there was a problem determining the number

queryAvailabilityDate

public java.util.Date queryAvailabilityDate(java.lang.String pId)
                                     throws InventoryException
Return the availability date of an item.

Specified by:
queryAvailabilityDate in interface InventoryManager
Returns:
the date that the item will be available for puchase if the item's availability status is not AVAILABILITY_STATUS_IN_STOCK. If the item's availability status is AVAILABILITY_STATUS_IN_STOCK, then we return null.
Throws:
InventoryException - if there was a problem determining the date

inventoryWasUpdated

public int inventoryWasUpdated(java.util.List pItemIds)
                        throws InventoryException
Informs the inventory manager that the given ids are now available. Some implementations of the InventoryManager may send a message informing other systems that some items that were previously unavailable are now available. No changes are made to the inventory.

Specified by:
inventoryWasUpdated in interface InventoryManager
Parameters:
pItemIds - The items with recently added inventory
Throws:
InventoryException

acquireInventoryLocks

public void acquireInventoryLocks(java.util.List pItemIds)
                           throws InventoryException
Acquires locks for the inventory items that apply to the given ids.

Specified by:
acquireInventoryLocks in interface InventoryManager
Throws:
InventoryException

releaseInventoryLocks

public void releaseInventoryLocks(java.util.List pItemIds)
                           throws InventoryException
Release locks for the inventory items that apply to the given ids.

Specified by:
releaseInventoryLocks in interface InventoryManager
Throws:
InventoryException