atg.commerce.inventory
Class RepositoryInventoryManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.messaging.SourceSinkTemplate
              extended by atg.commerce.inventory.RepositoryInventoryManager
All Implemented Interfaces:
InventoryManager, MessageSink, MessageSource, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class RepositoryInventoryManager
extends SourceSinkTemplate
implements InventoryManager

This is a repository based implementation of InventoryManager. It implements all the methods defined by the InventoryManager API. It is a thin wrapper around a repository that contains the inventory information. This allows a maximum amount of flexibility for potential third party integrators. Integrators can simply implement a repository containing the required properties for cooperation with the RepositoryInventoryManager. The Repository InventoryManager can then be configured to extract inventory manager information from the third party repository.

This class also is a message source. It can send UpdateInventory messages if there is new inventory available for a previously unavailable item.


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
RepositoryInventoryManager()
           
 
Method Summary
 void acquireInventoryLocks(java.util.List pItemIds)
          For each item in the list, call lock The locks are acquired in sorted order.
 int backorder(java.lang.String pId, long pHowMany)
          decrement the item's backorder count, If the item is a bundle backorderBundle is called.
protected  int backorderBundle(java.lang.String pBundleId, long pHowMany)
          Backorders a bundle.
 int decreaseBackorderLevel(java.lang.String pId, long pNumber)
          decrease the item's backorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 int decreasePreorderLevel(java.lang.String pId, long pNumber)
          decrease the item's preorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 int decreaseStockLevel(java.lang.String pId, long pNumber)
          decrease the item's stock level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
protected  int decrementSKULevel(MutableRepositoryItem pItem, long pHowMany, java.lang.String pLevelName, java.lang.String pThresholdName)
          Decrement the given level by the given amount.
protected  int deriveAvailabilityStatus(java.lang.String pId)
          Derive the availabilityStatus based on the properties of the item Always derives the status, does not check the current value of availabilityStatus.
protected  int deriveBundleAvailabilityStatus(java.lang.String pBundleId)
          Derives the availability status for a bundle.
 java.lang.String getAvailabilityDatePropertyName()
          Returns property AvailabilityDatePropertyName
 int getAvailabilityStatusBackorderableValue()
          The integer value for the availabilityStatus of BACKORDERABLE
 int getAvailabilityStatusDerivedValue()
          The integer value for the availabilityStatus of DERIVED
 int getAvailabilityStatusDiscontinuedValue()
          The integer value for the availabilityStatus of DISCONTINUED
 int getAvailabilityStatusInStockValue()
          The integer value for the availabilityStatus of IN_STOCK
 int getAvailabilityStatusOutOfStockValue()
          The integer value for the availabilityStatus of OUT_OF_STOCK
 int getAvailabilityStatusPreorderableValue()
          The integer value for the availabilityStatus of PREORDERABLE
 java.lang.String getAvailabilityStatusPropertyName()
          Returns property AvailabilityStatusPropertyName
 java.lang.String getBackorderLevelPropertyName()
          Returns property BackorderLevelPropertyName
 java.lang.String getBackorderThresholdPropertyName()
          Returns property BackorderThresholdPropertyName
 java.util.List getBundledIds(java.lang.String pBundleId)
          Return the list of catalog ref ids contained in the bundle.
protected  java.util.List getBundleLinks(RepositoryItem pBundle)
          Return the List of bundle links for the given id.
protected  java.util.List getBundleLinks(java.lang.String pId)
          Return the List of bundle links for the given id.
 java.lang.String getBundleLinksPropertyName()
          The name of the property bundleLinks
 RqlStatement getCatalogRefIdMatchQuery()
          Returns property CatalogRefIdMatchQuery
 java.lang.String getCatalogRefIdPropertyName()
          Returns property CatalogRefIdPropertyName
protected  RepositoryItem getCatalogRefItem(java.lang.String pId)
          Return the RepositoryItem which represents the catalog ref (aka SKU)
 java.lang.String getCatalogRefItemType()
          Returns property CatalogRefItemType
 Repository getCatalogRefRepository()
          Returns property CatalogRefRepository
 ClientLockManager getClientLockManager()
          Deprecated. locks are no longer used
 long getDefaultBackorderLevel()
          The default value if the backorder level of an item is not defined
 long getDefaultPreorderLevel()
          The default value if the preorder level of an item is not defined
 long getDefaultStockLevel()
          The default value if the stock level of an item is not defined
 java.lang.String getInventoryEventPort()
          The port to which all inventory scenario events are sent.
protected  RepositoryItem getInventoryItem(java.lang.String pId)
          Return the RepositoryItem which represents the inventory information
protected  MutableRepositoryItem getInventoryItemForUpdate(java.lang.String pId)
          Return the MutableRepositoryItem which represents the inventory information
 java.lang.String getInventoryName()
          A displayable name for this inventory manager.
 java.lang.String getInventoryRowLockProperty()
          The name of the property of inventory that is used to grab a row lock
 java.lang.String getInventoryRowLockSQL()
          The sql command that is used to grab the row lock
 java.lang.String getItemType()
          Returns property ItemType
 int getMaximumRetriesPerRowLock()
           
 IdGenerator getMessageIdGenerator()
          The service that generates Ids for all messages.
 java.lang.String getMessageIdSpaceName()
          The name of the idspace to get our message ids from
 int getMillisecondDelayBeforeLockRetry()
           
 java.lang.String getNextMessageId()
          Returns the next unique Id for commerce messages.
 java.lang.String getPreorderLevelPropertyName()
          Returns property PreorderLevelPropertyName
 java.lang.String getPreorderThresholdPropertyName()
          Returns property PreorderThresholdPropertyName
 MutableRepository getRepository()
          Returns property Repository
 java.lang.String getSkuLinkItemPropertyName()
          the name of the item property in a sku link.
 java.lang.String getSkuLinkQuantityPropertyName()
          The name of the quantity property in a sku link
 java.lang.String getStockLevelPropertyName()
          Returns property StockLevelPropertyName
 java.lang.String getStockThresholdPropertyName()
          Returns property StockThresholdPropertyName
 java.lang.String getUpdateInventoryPort()
          The port to which all UpdateInventory messages are sent.
 int increaseBackorderLevel(java.lang.String pId, long pNumber)
          increase the item's backorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 int increasePreorderLevel(java.lang.String pId, long pNumber)
          increase the item's preorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 int increaseStockLevel(java.lang.String pId, long pNumber)
          increase the item's stock level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 int inventoryWasUpdated(java.util.List pItemIds)
          Send an UpdateInventory message out the UpdateInventoryPort.
protected  boolean isBundle(java.lang.String pId)
          Checks to see if the given id refers to a bundle.
protected  void lock(java.lang.String pItemId)
          To allow multiple instance of Dynamo to simultaneously edit inventory items, we need to make sure the repository item we load is current.
 int preorder(java.lang.String pId, long pHowMany)
          decrement the item's preorder count, If the item is a bundle preorderBundle is called.
protected  int preorderBundle(java.lang.String pBundleId, long pHowMany)
          Preorders a bundle.
 int purchase(java.lang.String pId, long pHowMany)
          Check the availability status (queryAvailabilityStatus).
protected  int purchaseBundle(java.lang.String pBundleId, long pHowMany)
          Purchases a bundle by purchase each of its bundle items.
protected  int purchaseBundleOffBackorder(java.lang.String pBundleId, long pHowMany)
          Purchases the bundle then increments the backorderLevel of each item in the bundle.
protected  int purchaseBundleOffPreorder(java.lang.String pBundleId, long pHowMany)
          Purchases the bundle and increments the preorderLevel of each item in the bundle.
 int purchaseOffBackorder(java.lang.String pId, long pHowMany)
          Check the availability status (queryAvailabilityStatus).
 int purchaseOffPreorder(java.lang.String pId, long pHowMany)
          Check the availability status (queryAvailabilityStatus).
 java.util.Date queryAvailabilityDate(java.lang.String pId)
          query 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)
          query the number of items available for backorder.
 long queryBackorderThreshold(java.lang.String pId)
          Return the threshold associated with backorderLevel
 java.util.Date queryBundleAvailabilityDate(java.lang.String pBundleId)
          Cycles through each item in a bundle and calls queryAvailabilityDate on each.
protected  long queryBundleBackorderLevel(java.lang.String pId)
          Cycles through the items in a bundle and returns the greatest quantity of bundles that could be allocated given each items backorder level.
protected  long queryBundleBackorderThreshold(java.lang.String pId)
          Currently all bundles have thresholds of 0.
protected  long queryBundlePreorderLevel(java.lang.String pId)
          Cycles through the items in a bundle and returns the greatest quantity of bundles that could be preordered given each items backorder level.
protected  long queryBundlePreorderThreshold(java.lang.String pId)
          Currently all bundles have thresholds of 0.
protected  long queryBundleStockLevel(java.lang.String pId)
          Cycles through the items in a bundle and returns the greatest quantity of bundles that could be allocated given each items stock level.
protected  long queryBundleStockThreshold(java.lang.String pId)
          Currently all bundles have thresholds of 0.
 long queryPreorderLevel(java.lang.String pId)
          query the number of items in available in preorder.
 long queryPreorderThreshold(java.lang.String pId)
          Return the threshold associated with preorderLevel
 long queryStockLevel(java.lang.String pId)
          query the number of items in stock.
 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.
 void setAvailabilityDatePropertyName(java.lang.String pAvailabilityDatePropertyName)
          Sets property AvailabilityDatePropertyName
 int setAvailabilityStatus(java.lang.String pId, int pStatus)
          Set an item's availability status.
 void setAvailabilityStatusBackorderableValue(int pAvailabilityStatusBackorderableValue)
           
 void setAvailabilityStatusDerivedValue(int pAvailabilityStatusDerivedValue)
           
 void setAvailabilityStatusDiscontinuedValue(int pAvailabilityStatusDiscontinuedValue)
           
 void setAvailabilityStatusInStockValue(int pAvailabilityStatusInStockValue)
           
 void setAvailabilityStatusOutOfStockValue(int pAvailabilityStatusOutOfStockValue)
           
 void setAvailabilityStatusPreorderableValue(int pAvailabilityStatusPreorderableValue)
           
 void setAvailabilityStatusPropertyName(java.lang.String pAvailabilityStatusPropertyName)
          Sets property AvailabilityStatusPropertyName
 int setBackorderLevel(java.lang.String pId, long pNumber)
          set the item's backorder level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 void setBackorderLevelPropertyName(java.lang.String pBackorderLevelPropertyName)
          Sets property BackorderLevelPropertyName
 int setBackorderThreshold(java.lang.String pId, long pNumber)
          Set an item's backorder level threshold.
 void setBackorderThresholdPropertyName(java.lang.String pBackorderThresholdPropertyName)
          Sets property BackorderThresholdPropertyName
 void setBundleLinksPropertyName(java.lang.String pBundleLinksPropertyName)
           
 void setCatalogRefIdMatchQuery(RqlStatement pCatalogRefIdMatchQuery)
          Sets property CatalogRefIdMatchQuery
 void setCatalogRefIdPropertyName(java.lang.String pCatalogRefIdPropertyName)
          Sets property CatalogRefIdPropertyName
 void setCatalogRefItemType(java.lang.String pCatalogRefItemType)
          Sets property CatalogRefItemType
 void setCatalogRefRepository(Repository pCatalogRefRepository)
          Sets property CatalogRefRepository
 void setClientLockManager(ClientLockManager pClientLockManager)
          Deprecated. locks are no longer used
 void setDefaultBackorderLevel(long pDefaultBackorderLevel)
           
 void setDefaultPreorderLevel(long pDefaultPreorderLevel)
           
 void setDefaultStockLevel(long pDefaultStockLevel)
           
 void setInventoryEventPort(java.lang.String pInventoryEventPort)
           
 void setInventoryName(java.lang.String pInventoryName)
           
 void setInventoryRowLockProperty(java.lang.String pInventoryRowLockProperty)
           
 void setInventoryRowLockSQL(java.lang.String pInventoryRowLockSQL)
           
 void setItemType(java.lang.String pItemType)
          Sets property ItemType
 void setMaximumRetriesPerRowLock(int pMaximumRetriesPerRowLock)
           
 void setMessageIdGenerator(IdGenerator pMessageIdGenerator)
           
 void setMessageIdSpaceName(java.lang.String pMessageIdSpaceName)
           
 void setMillisecondDelayBeforeLockRetry(int pMillisecondDelayBeforeLockRetry)
           
 int setPreorderLevel(java.lang.String pId, long pNumber)
          set the item's preorder level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 void setPreorderLevelPropertyName(java.lang.String pPreorderLevelPropertyName)
          Sets property PreorderLevelPropertyName
 int setPreorderThreshold(java.lang.String pId, long pNumber)
          Set an item's preorder level threshold.
 void setPreorderThresholdPropertyName(java.lang.String pPreorderThresholdPropertyName)
          Sets property PreorderThresholdPropertyName
 void setRepository(MutableRepository pRepository)
          Sets property Repository
 void setSkuLinkItemPropertyName(java.lang.String pSkuLinkItemPropertyName)
           
 void setSkuLinkQuantityPropertyName(java.lang.String pSkuLinkQuantityPropertyName)
           
 int setStockLevel(java.lang.String pId, long pNumber)
          set the item's stock level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.
 void setStockLevelPropertyName(java.lang.String pStockLevelPropertyName)
          Sets property StockLevelPropertyName
 int setStockThreshold(java.lang.String pId, long pNumber)
          Set an item's stock level threshold.
 void setStockThresholdPropertyName(java.lang.String pStockThresholdPropertyName)
          Sets property StockThresholdPropertyName
 void setUpdateInventoryPort(java.lang.String pUpdateInventoryPort)
           
protected  void thresholdHasBeenReached(java.lang.String pId, java.lang.String pLevelPropertyName, java.lang.String pThresholdPropertyName, long pCurrentValue, long pThreshold)
          This gets called when some level sinks below the threshold.
protected  void unlock(java.lang.String pItemId)
          Release the lock for the given id.
protected  void updateItem(MutableRepositoryItem pItem)
          Update the item in the inventory
 
Methods inherited from class atg.commerce.messaging.SourceSinkTemplate
getDelayOnSendRetry, getMessageSourceContext, getMessageSourceName, getTransactionManager, isAllowMessageSending, receiveMessage, sendCommerceMessage, sendObjectMessage, setAllowMessageSending, setDelayOnSendRetry, setMessageSourceContext, setMessageSourceName, setTransactionManager, startMessageSource, stopMessageSource
 
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 final java.lang.String CLASS_VERSION
See Also:
Constant Field Values
Constructor Detail

RepositoryInventoryManager

public RepositoryInventoryManager()
Method Detail

setStockLevelPropertyName

public void setStockLevelPropertyName(java.lang.String pStockLevelPropertyName)
Sets property StockLevelPropertyName


getStockLevelPropertyName

public java.lang.String getStockLevelPropertyName()
Returns property StockLevelPropertyName


setBackorderLevelPropertyName

public void setBackorderLevelPropertyName(java.lang.String pBackorderLevelPropertyName)
Sets property BackorderLevelPropertyName


getBackorderLevelPropertyName

public java.lang.String getBackorderLevelPropertyName()
Returns property BackorderLevelPropertyName


setPreorderLevelPropertyName

public void setPreorderLevelPropertyName(java.lang.String pPreorderLevelPropertyName)
Sets property PreorderLevelPropertyName


getPreorderLevelPropertyName

public java.lang.String getPreorderLevelPropertyName()
Returns property PreorderLevelPropertyName


setStockThresholdPropertyName

public void setStockThresholdPropertyName(java.lang.String pStockThresholdPropertyName)
Sets property StockThresholdPropertyName


getStockThresholdPropertyName

public java.lang.String getStockThresholdPropertyName()
Returns property StockThresholdPropertyName


setBackorderThresholdPropertyName

public void setBackorderThresholdPropertyName(java.lang.String pBackorderThresholdPropertyName)
Sets property BackorderThresholdPropertyName


getBackorderThresholdPropertyName

public java.lang.String getBackorderThresholdPropertyName()
Returns property BackorderThresholdPropertyName


setPreorderThresholdPropertyName

public void setPreorderThresholdPropertyName(java.lang.String pPreorderThresholdPropertyName)
Sets property PreorderThresholdPropertyName


getPreorderThresholdPropertyName

public java.lang.String getPreorderThresholdPropertyName()
Returns property PreorderThresholdPropertyName


setAvailabilityStatusPropertyName

public void setAvailabilityStatusPropertyName(java.lang.String pAvailabilityStatusPropertyName)
Sets property AvailabilityStatusPropertyName


getAvailabilityStatusPropertyName

public java.lang.String getAvailabilityStatusPropertyName()
Returns property AvailabilityStatusPropertyName


setAvailabilityDatePropertyName

public void setAvailabilityDatePropertyName(java.lang.String pAvailabilityDatePropertyName)
Sets property AvailabilityDatePropertyName


getAvailabilityDatePropertyName

public java.lang.String getAvailabilityDatePropertyName()
Returns property AvailabilityDatePropertyName


setCatalogRefIdPropertyName

public void setCatalogRefIdPropertyName(java.lang.String pCatalogRefIdPropertyName)
Sets property CatalogRefIdPropertyName


getCatalogRefIdPropertyName

public java.lang.String getCatalogRefIdPropertyName()
Returns property CatalogRefIdPropertyName


setBundleLinksPropertyName

public void setBundleLinksPropertyName(java.lang.String pBundleLinksPropertyName)

getBundleLinksPropertyName

public java.lang.String getBundleLinksPropertyName()
The name of the property bundleLinks


setSkuLinkItemPropertyName

public void setSkuLinkItemPropertyName(java.lang.String pSkuLinkItemPropertyName)

getSkuLinkItemPropertyName

public java.lang.String getSkuLinkItemPropertyName()
the name of the item property in a sku link.


setSkuLinkQuantityPropertyName

public void setSkuLinkQuantityPropertyName(java.lang.String pSkuLinkQuantityPropertyName)

getSkuLinkQuantityPropertyName

public java.lang.String getSkuLinkQuantityPropertyName()
The name of the quantity property in a sku link


setAvailabilityStatusDerivedValue

public void setAvailabilityStatusDerivedValue(int pAvailabilityStatusDerivedValue)

getAvailabilityStatusDerivedValue

public int getAvailabilityStatusDerivedValue()
The integer value for the availabilityStatus of DERIVED


setAvailabilityStatusInStockValue

public void setAvailabilityStatusInStockValue(int pAvailabilityStatusInStockValue)

getAvailabilityStatusInStockValue

public int getAvailabilityStatusInStockValue()
The integer value for the availabilityStatus of IN_STOCK


setAvailabilityStatusBackorderableValue

public void setAvailabilityStatusBackorderableValue(int pAvailabilityStatusBackorderableValue)

getAvailabilityStatusBackorderableValue

public int getAvailabilityStatusBackorderableValue()
The integer value for the availabilityStatus of BACKORDERABLE


setAvailabilityStatusPreorderableValue

public void setAvailabilityStatusPreorderableValue(int pAvailabilityStatusPreorderableValue)

getAvailabilityStatusPreorderableValue

public int getAvailabilityStatusPreorderableValue()
The integer value for the availabilityStatus of PREORDERABLE


setAvailabilityStatusOutOfStockValue

public void setAvailabilityStatusOutOfStockValue(int pAvailabilityStatusOutOfStockValue)

getAvailabilityStatusOutOfStockValue

public int getAvailabilityStatusOutOfStockValue()
The integer value for the availabilityStatus of OUT_OF_STOCK


setAvailabilityStatusDiscontinuedValue

public void setAvailabilityStatusDiscontinuedValue(int pAvailabilityStatusDiscontinuedValue)

getAvailabilityStatusDiscontinuedValue

public int getAvailabilityStatusDiscontinuedValue()
The integer value for the availabilityStatus of DISCONTINUED


setDefaultStockLevel

public void setDefaultStockLevel(long pDefaultStockLevel)

getDefaultStockLevel

public long getDefaultStockLevel()
The default value if the stock level of an item is not defined


setDefaultBackorderLevel

public void setDefaultBackorderLevel(long pDefaultBackorderLevel)

getDefaultBackorderLevel

public long getDefaultBackorderLevel()
The default value if the backorder level of an item is not defined


setDefaultPreorderLevel

public void setDefaultPreorderLevel(long pDefaultPreorderLevel)

getDefaultPreorderLevel

public long getDefaultPreorderLevel()
The default value if the preorder level of an item is not defined


setMessageIdGenerator

public void setMessageIdGenerator(IdGenerator pMessageIdGenerator)

getMessageIdGenerator

public IdGenerator getMessageIdGenerator()
The service that generates Ids for all messages.


setMessageIdSpaceName

public void setMessageIdSpaceName(java.lang.String pMessageIdSpaceName)

getMessageIdSpaceName

public java.lang.String getMessageIdSpaceName()
The name of the idspace to get our message ids from


setRepository

public void setRepository(MutableRepository pRepository)
Sets property Repository


getRepository

public MutableRepository getRepository()
Returns property Repository


setItemType

public void setItemType(java.lang.String pItemType)
Sets property ItemType


getItemType

public java.lang.String getItemType()
Returns property ItemType


setCatalogRefIdMatchQuery

public void setCatalogRefIdMatchQuery(RqlStatement pCatalogRefIdMatchQuery)
Sets property CatalogRefIdMatchQuery


getCatalogRefIdMatchQuery

public RqlStatement getCatalogRefIdMatchQuery()
Returns property CatalogRefIdMatchQuery


setCatalogRefRepository

public void setCatalogRefRepository(Repository pCatalogRefRepository)
Sets property CatalogRefRepository


getCatalogRefRepository

public Repository getCatalogRefRepository()
Returns property CatalogRefRepository


setCatalogRefItemType

public void setCatalogRefItemType(java.lang.String pCatalogRefItemType)
Sets property CatalogRefItemType


getCatalogRefItemType

public java.lang.String getCatalogRefItemType()
Returns property CatalogRefItemType


setClientLockManager

public void setClientLockManager(ClientLockManager pClientLockManager)
Deprecated. locks are no longer used


getClientLockManager

public ClientLockManager getClientLockManager()
Deprecated. locks are no longer used


setUpdateInventoryPort

public void setUpdateInventoryPort(java.lang.String pUpdateInventoryPort)

getUpdateInventoryPort

public java.lang.String getUpdateInventoryPort()
The port to which all UpdateInventory messages are sent.


setInventoryEventPort

public void setInventoryEventPort(java.lang.String pInventoryEventPort)

getInventoryEventPort

public java.lang.String getInventoryEventPort()
The port to which all inventory scenario events are sent.


getCatalogRefItem

protected RepositoryItem getCatalogRefItem(java.lang.String pId)
                                    throws RepositoryException
Return the RepositoryItem which represents the catalog ref (aka SKU)

Throws:
RepositoryException - if there was a problem accessing the item

setMaximumRetriesPerRowLock

public void setMaximumRetriesPerRowLock(int pMaximumRetriesPerRowLock)

getMaximumRetriesPerRowLock

public int getMaximumRetriesPerRowLock()

setMillisecondDelayBeforeLockRetry

public void setMillisecondDelayBeforeLockRetry(int pMillisecondDelayBeforeLockRetry)

getMillisecondDelayBeforeLockRetry

public int getMillisecondDelayBeforeLockRetry()

setInventoryRowLockProperty

public void setInventoryRowLockProperty(java.lang.String pInventoryRowLockProperty)

getInventoryRowLockProperty

public java.lang.String getInventoryRowLockProperty()
The name of the property of inventory that is used to grab a row lock


setInventoryRowLockSQL

public void setInventoryRowLockSQL(java.lang.String pInventoryRowLockSQL)

getInventoryRowLockSQL

public java.lang.String getInventoryRowLockSQL()
The sql command that is used to grab the row lock


getInventoryItemForUpdate

protected MutableRepositoryItem getInventoryItemForUpdate(java.lang.String pId)
                                                   throws RepositoryException
Return the MutableRepositoryItem which represents the inventory information

Throws:
RepositoryException - if there was a problem accessing the item

getInventoryItem

protected RepositoryItem getInventoryItem(java.lang.String pId)
                                   throws RepositoryException
Return the RepositoryItem which represents the inventory information

Returns:
The RepositoryItem
Throws:
RepositoryException - if there was a problem accessing the item

setInventoryName

public void setInventoryName(java.lang.String pInventoryName)

getInventoryName

public java.lang.String getInventoryName()
A displayable name for this inventory manager.

Specified by:
getInventoryName in interface InventoryManager

purchase

public int purchase(java.lang.String pId,
                    long pHowMany)
             throws InventoryException
Check the availability status (queryAvailabilityStatus). If it is not IN_STOCK, return INVENTORY_STATUS_FAIL. If it is in stock, but there is less than pHowMany, return INVENTORY_STATUS_INSUFFICIENT_SUPPLY. Decrement the stockLevel by the amount allocated. If the item passed in is a bundle purchaseBundle is called.

Specified by:
purchase in interface InventoryManager
Parameters:
pId - The id of the SKU being purchased.
pHowMany - The amount of the SKU being purchased.
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU isn't found.
Throws:
InventoryException
See Also:
queryAvailabilityStatus(java.lang.String), purchaseBundle(java.lang.String, long)

purchaseOffBackorder

public int purchaseOffBackorder(java.lang.String pId,
                                long pHowMany)
                         throws InventoryException
Check the availability status (queryAvailabilityStatus). If it is not IN_STOCK, return INVENTORY_STATUS_FAIL. If it is in stock, but there is less than pHowMany, return INVENTORY_STATUS_INSUFFICIENT_SUPPLY. Decrement the stockLevel by the amount allocated and increment the backorderLevel by the same. If the item is a bundle purchaseBundleOffBackorder is called.

Specified by:
purchaseOffBackorder in interface InventoryManager
Parameters:
pId - The id of the SKU being purchased.
pHowMany - The amount of the SKU being purchased.
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU isn't found.
Throws:
InventoryException
See Also:
queryAvailabilityStatus(java.lang.String), purchaseBundleOffBackorder(java.lang.String, long)

purchaseOffPreorder

public int purchaseOffPreorder(java.lang.String pId,
                               long pHowMany)
                        throws InventoryException
Check the availability status (queryAvailabilityStatus). If it is not IN_STOCK, return INVENTORY_STATUS_FAIL. If it is in stock, but there is less than pHowMany, return INVENTORY_STATUS_INSUFFICIENT_SUPPLY. Decrement the stockLevel by the amount allocated and increment the preorderLevel by the same. If the item is a bundle purchaseBundleOffPreorder is called.

Specified by:
purchaseOffPreorder in interface InventoryManager
Parameters:
pId - The id of the SKU being purchased.
pHowMany - The amount of the SKU being purchased.
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU isn't found.
Throws:
InventoryException
See Also:
queryAvailabilityStatus(java.lang.String), purchaseBundleOffPreorder(java.lang.String, long)

preorder

public int preorder(java.lang.String pId,
                    long pHowMany)
             throws InventoryException
decrement the item's preorder count, If the item is a bundle preorderBundle is called.

Specified by:
preorder in interface InventoryManager
Parameters:
pId - The id of the SKU being preordered.
pHowMany - The amount of the SKU being preordered.
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU doesn't correspond to any item
Throws:
InventoryException
See Also:
preorderBundle(java.lang.String, long)

backorder

public int backorder(java.lang.String pId,
                     long pHowMany)
              throws InventoryException
decrement the item's backorder count, If the item is a bundle backorderBundle is called.

Specified by:
backorder in interface InventoryManager
Parameters:
pId - The id of the SKU being backordered.
pHowMany - The amount of the SKU being backordered..
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU doesn't correspond to any item
Throws:
InventoryException
See Also:
backorderBundle(java.lang.String, long)

decrementSKULevel

protected int decrementSKULevel(MutableRepositoryItem pItem,
                                long pHowMany,
                                java.lang.String pLevelName,
                                java.lang.String pThresholdName)
                         throws InventoryException
Decrement the given level by the given amount. Does no checks on the availabilityStatus of the item in the repository. If the given threshold is reached, then thresholdHasBeenReached will be called. This method assumes the item is not a bundle.

Parameters:
pItem - The id of the SKU being changed.
pHowMany - The amount the level should be decreased by.
pLevelName - The name of the level that should be decreased. (one of stockLevel, backorderLevel, preorderLevel)
pThresholdName - The name of the threshold associated with pLevelName
Returns:
INVENTORY_STATUS_ITEM_NOT_FOUND if the SKU doesn't correspond to any item
Throws:
InventoryException
See Also:
thresholdHasBeenReached(java.lang.String, java.lang.String, java.lang.String, long, long)

setStockLevel

public int setStockLevel(java.lang.String pId,
                         long pNumber)
                  throws InventoryException
set the item's stock level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.

Specified by:
setStockLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose stockLevel is being set
pNumber - The amount to set the stockLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock level was set successfully.
Throws:
InventoryException

setBackorderLevel

public int setBackorderLevel(java.lang.String pId,
                             long pNumber)
                      throws InventoryException
set the item's backorder level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.

Specified by:
setBackorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose backorderLevel is being set
pNumber - The amount to set the backorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's backorder level was set successfully.
Throws:
InventoryException

setPreorderLevel

public int setPreorderLevel(java.lang.String pId,
                            long pNumber)
                     throws InventoryException
set the item's preorder level to pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.

Specified by:
setPreorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose preorderLevel is being set
pNumber - The amount to set the preorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's preorder level was set successfully.
Throws:
InventoryException

increaseStockLevel

public int increaseStockLevel(java.lang.String pId,
                              long pNumber)
                       throws InventoryException
increase the item's stock level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED. If the stock level is not set, there is no effect.

Specified by:
increaseStockLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose stockLevel is being increased.
pNumber - The amount to increase the stockLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock level was set successfully.
Throws:
InventoryException

decreaseStockLevel

public int decreaseStockLevel(java.lang.String pId,
                              long pNumber)
                       throws InventoryException
decrease the item's stock level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED. 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 SKU whose stockLevel is being decreased.
pNumber - The amount to decrease the stockLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock level was set successfully.
Throws:
InventoryException

increaseBackorderLevel

public int increaseBackorderLevel(java.lang.String pId,
                                  long pNumber)
                           throws InventoryException
increase the item's backorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED. If the backorder level is not set, there is no effect.

Specified by:
increaseBackorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose backorderLevel is being increased.
pNumber - The amount to increase the backorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's backorder level was set successfully.
Throws:
InventoryException

decreaseBackorderLevel

public int decreaseBackorderLevel(java.lang.String pId,
                                  long pNumber)
                           throws InventoryException
decrease the item's backorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.

Specified by:
decreaseBackorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose backorderLevel is being decreased.
pNumber - The amount to decrease the backorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's backorder level was set successfully.
Throws:
InventoryException

increasePreorderLevel

public int increasePreorderLevel(java.lang.String pId,
                                 long pNumber)
                          throws InventoryException
increase the item's preorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED. If the preorder level is not set, there is no effect.

Specified by:
increasePreorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose preorderLevel is being increased.
pNumber - The amount to increase the preorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's preorder level was set successfully.
Throws:
InventoryException

decreasePreorderLevel

public int decreasePreorderLevel(java.lang.String pId,
                                 long pNumber)
                          throws InventoryException
decrease the item's preorder level by pNumber, If the item is a bundle, this method does nothing and returns INVENTORY_STATUS_SUCCEED.

Specified by:
decreasePreorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose preorderLevel is being decreased.
pNumber - The amount to decrease the preorderLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's preorder level was set successfully.
Throws:
InventoryException

setAvailabilityStatus

public int setAvailabilityStatus(java.lang.String pId,
                                 int pStatus)
                          throws InventoryException
Set an item's availability status. Does not check if the item is a bundle.

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. Does nothing if the item is a bundle.

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
Description copied from interface: InventoryManager
Return the availability status of a given item. If an item has a status of DERIVED, then the return value is calculated. Otherwise the existing status is returned. An item can be in one of four states:

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
query the number of items in stock. If the item is a bundle, then queryBundleStockLevel

Specified by:
queryStockLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose stockLevel is returned
Returns:
The stockLevel of the SKU
Throws:
InventoryException
See Also:
queryBundleStockLevel(java.lang.String)

queryBackorderLevel

public long queryBackorderLevel(java.lang.String pId)
                         throws InventoryException
query the number of items available for backorder. If the item is a bundle, then queryBundleBackorderLevel

Specified by:
queryBackorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose backorderLevel is returned
Returns:
The backorderLevel of the SKU
Throws:
InventoryException
See Also:
queryBundleBackorderLevel(java.lang.String)

queryPreorderLevel

public long queryPreorderLevel(java.lang.String pId)
                        throws InventoryException
query the number of items in available in preorder. If the item is a bundle, then queryBundlePreorderLevel

Specified by:
queryPreorderLevel in interface InventoryManager
Parameters:
pId - The id of the SKU whose preorderLevel is returned
Returns:
The preorderLevel of the SKU
Throws:
InventoryException
See Also:
queryBundlePreorderLevel(java.lang.String)

queryAvailabilityDate

public java.util.Date queryAvailabilityDate(java.lang.String pId)
                                     throws InventoryException
query the availability date of an item. If the item is a bundle then queryBundleAvailabilityDate

Specified by:
queryAvailabilityDate in interface InventoryManager
Parameters:
pId - The id of the SKU whose availabilityDate is returned
Returns:
The availabilityDate of the SKU
Throws:
InventoryException
See Also:
queryBundleAvailabilityDate(java.lang.String)

inventoryWasUpdated

public int inventoryWasUpdated(java.util.List pItemIds)
                        throws InventoryException
Send an UpdateInventory message out the UpdateInventoryPort. No changes are made to the inventory.

Specified by:
inventoryWasUpdated in interface InventoryManager
Parameters:
pItemIds - The items with recently added inventory
Returns:
INVENTORY_STATUS_SUCCESS
Throws:
MissingInventoryItemException - if a given id does not exist.
InventoryException
See Also:
JMSException

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 SKU involved
pNumber - the number to set the threshold to
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock threshold was set successfully.
Throws:
InventoryException

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 SKU involved
pNumber - the number to set the threshold to
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock threshold was set successfully.
Throws:
InventoryException

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 SKU involved
pNumber - the number to set the threshold to
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock threshold was set successfully.
Throws:
InventoryException

queryStockThreshold

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

Specified by:
queryStockThreshold in interface InventoryManager
Parameters:
pId - the id of the SKU involved
Returns:
The value of the threshold
Throws:
InventoryException

queryBackorderThreshold

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

Specified by:
queryBackorderThreshold in interface InventoryManager
Parameters:
pId - the id of the SKU involved
Returns:
The value of the threshold
Throws:
InventoryException

queryPreorderThreshold

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

Specified by:
queryPreorderThreshold in interface InventoryManager
Parameters:
pId - the id of the SKU involved
Returns:
The value of the threshold
Throws:
InventoryException

thresholdHasBeenReached

protected void thresholdHasBeenReached(java.lang.String pId,
                                       java.lang.String pLevelPropertyName,
                                       java.lang.String pThresholdPropertyName,
                                       long pCurrentValue,
                                       long pThreshold)
                                throws InventoryException
This gets called when some level sinks below the threshold. It creates an InventoryThresholdReached object and sends it over the inventory event port

Parameters:
pId - The id of the SKU at a critical inventory level.
pLevelPropertyName - The name of the property that is at a critical level
pThresholdPropertyName - The name of the threshold that has been reached.
pCurrentValue - The current value of pLevelPropertyName
pThreshold - The vale of pThresholdPropertyName
Throws:
InventoryException
See Also:
InventoryThresholdReached, getInventoryEventPort()

deriveAvailabilityStatus

protected int deriveAvailabilityStatus(java.lang.String pId)
                                throws InventoryException
Derive the availabilityStatus based on the properties of the item Always derives the status, does not check the current value of availabilityStatus. Uses these rules: (a negative level indicates infinite supply) if(stockLevel != 0) return IN_STOCK; else if(backorderLevel != 0) return BACKORDERABLE; else if(preorderLevel != 0) return PREORDERABLE; else return OUT_OF_STOCK;

Parameters:
pId - The sku we are deriving the status for
Returns:
The derived status
Throws:
InventoryException

getNextMessageId

public java.lang.String getNextMessageId()
                                  throws InventoryException
Returns the next unique Id for commerce messages.

Throws:
InventoryException

updateItem

protected void updateItem(MutableRepositoryItem pItem)
                   throws RepositoryException
Update the item in the inventory

Parameters:
pItem - The inventory's RepositoryItem
Throws:
RepositoryException

lock

protected void lock(java.lang.String pItemId)
             throws java.sql.SQLException
To allow multiple instance of Dynamo to simultaneously edit inventory items, we need to make sure the repository item we load is current. To help ensure this, write to the row in the database. The database will give the thread the row lock for the table. Other changes from other machines or Dynamos need to wait until we commit our changes. This method effectively locks the row. If the id does not exist, the lock call automatically works.

Parameters:
pItemId - The catalog ref id whose inventory we want to change
Throws:
java.sql.SQLException
See Also:
getMillisecondDelayBeforeLockRetry(), getMaximumRetriesPerRowLock(), getInventoryRowLockProperty(), getInventoryRowLockSQL()

unlock

protected void unlock(java.lang.String pItemId)
               throws java.sql.SQLException
Release the lock for the given id. In this implementation, unlock does nothing since we are relying on the database row locks. They will be released when the transaction ends.

Throws:
java.sql.SQLException

acquireInventoryLocks

public void acquireInventoryLocks(java.util.List pItemIds)
                           throws InventoryException
For each item in the list, call lock The locks are acquired in sorted order. Any locks for ids contained within a bundle are also acquired in the correct order. If one of the ids does not exist, it is ignored.

Specified by:
acquireInventoryLocks in interface InventoryManager
Parameters:
pItemIds - The list of catalog ref ids
Throws:
InventoryException

releaseInventoryLocks

public void releaseInventoryLocks(java.util.List pItemIds)
                           throws InventoryException
Release locks for the inventory items that apply to the given ids. This implementation does nothing since we are relying on the database row locks, which are released when the transaction ends.

Specified by:
releaseInventoryLocks in interface InventoryManager
Throws:
InventoryException

getBundledIds

public java.util.List getBundledIds(java.lang.String pBundleId)
                             throws InventoryException
Return the list of catalog ref ids contained in the bundle.

Throws:
InventoryException

getBundleLinks

protected java.util.List getBundleLinks(java.lang.String pId)
                                 throws InventoryException
Return the List of bundle links for the given id.

Parameters:
pId - The id of the sku in question
Returns:
A list of bundle links.
Throws:
InventoryException

getBundleLinks

protected java.util.List getBundleLinks(RepositoryItem pBundle)
                                 throws InventoryException
Return the List of bundle links for the given id.

Parameters:
pBundle - The sku.
Returns:
A list of bundle links.
Throws:
InventoryException

isBundle

protected boolean isBundle(java.lang.String pId)
                    throws InventoryException
Checks to see if the given id refers to a bundle. If bundles should be treated just like all other items This method should be overwritten to return false. The criteria for determining if a sku is a bundle, is if the sku has a nonempty bundleLinks list.

Parameters:
pId - The id of the sku in question
Returns:
true if the item is a bundle, false otherwise
Throws:
InventoryException

deriveBundleAvailabilityStatus

protected int deriveBundleAvailabilityStatus(java.lang.String pBundleId)
                                      throws InventoryException
Derives the availability status for a bundle. Assumes the given sku represents a bundle. for each item queryAvailabilityStatus(item) if any items are AVAILABILITY_STATUS_OUT_OF_STOCK return AVAILABILITY_STATUS_OUT_OF_STOCK else if any are AVAILABILITY_STATUS_PREORDERABLE return AVAILABILITY_STATUS_PREORDERABLE else if any are AVAILABILITY_STATUS_BACKORDERABLE return AVAILABILITY_STATUS_BACKORDERABLE else return AVAILABILITY_STATUS_IN_STOCK

Parameters:
pId - the id of the bundle
Returns:
the availability status according to the above rules.
Throws:
InventoryException

purchaseBundle

protected int purchaseBundle(java.lang.String pBundleId,
                             long pHowMany)
                      throws InventoryException
Purchases a bundle by purchase each of its bundle items. foreach item queryAvailabilityStatus(bundle) if AVAILABILITY_STATUS_IN_STOCK for each item purchase(item, itemQuantity) if purchase returns INVENTORY_STATUS_INSUFFICIENT_SUPPLY for each item already purchased increaseStockLevel return INVENTORY_STATUS_INSUFFICIENT_SUPPLY if purchase returns INVENTORY_STATUS_FAILED for each item already purchased increaseStockLevel return INVENTORY_STATUS_FAILED return INVENTORY_STATUS_SUCCEED else return INVENTORY_STATUS_FAILED

Parameters:
pBundleId - The id of the bundle
pHowMany - the quantity of the bundle to purchase
Returns:
The success flag of this operation.
Throws:
InventoryException

backorderBundle

protected int backorderBundle(java.lang.String pBundleId,
                              long pHowMany)
                       throws InventoryException
Backorders a bundle. Does the following for the bundle: foreach item backorder(item, itemQuantity) if backorder returns INVENTORY_STATUS_INSUFFICIENT_SUPPLY for each item already backordered increaseBackorderLevel return INVENTORY_STATUS_INSUFFICIENT_SUPPLY if backorder returns INVENTORY_STATUS_FAILED for each item already backordered increaseBackorderLevel return INVENTORY_STATUS_FAILED return INVENTORY_STATUS_SUCCEED else return INVENTORY_STATUS_FAILED

Parameters:
pBundleId - The id of the bundle we are backordering
pHowMany - the quantity of the bundle to backorder
Returns:
a success flag
Throws:
InventoryException

preorderBundle

protected int preorderBundle(java.lang.String pBundleId,
                             long pHowMany)
                      throws InventoryException
Preorders a bundle. Does the following for the bundle: foreach item preorder(item, itemQuantity) if preorder returns INVENTORY_STATUS_INSUFFICIENT_SUPPLY for each item already preordered increasePreorderLevel return INVENTORY_STATUS_INSUFFICIENT_SUPPLY if preorder returns INVENTORY_STATUS_FAILED for each item already preordered increasePreorderLevel return INVENTORY_STATUS_FAILED return INVENTORY_STATUS_SUCCEED else return INVENTORY_STATUS_FAILED

Parameters:
pBundleId - The id of the bundle we are backordering
pHowMany - the quantity of the bundle to backorder
Returns:
a success flag
Throws:
InventoryException

purchaseBundleOffPreorder

protected int purchaseBundleOffPreorder(java.lang.String pBundleId,
                                        long pHowMany)
                                 throws InventoryException
Purchases the bundle and increments the preorderLevel of each item in the bundle.

Parameters:
pBundleId - The id of the bundle
pHowMany - the quantity of the bundle to purchase
Returns:
The success flag of this operation.
Throws:
InventoryException

purchaseBundleOffBackorder

protected int purchaseBundleOffBackorder(java.lang.String pBundleId,
                                         long pHowMany)
                                  throws InventoryException
Purchases the bundle then increments the backorderLevel of each item in the bundle.

Parameters:
pBundleId - The id of the bundle
pHowMany - the quantity of the bundle to purchase
Returns:
The success flag of this operation.
Throws:
InventoryException

queryBundleStockLevel

protected long queryBundleStockLevel(java.lang.String pId)
                              throws InventoryException
Cycles through the items in a bundle and returns the greatest quantity of bundles that could be allocated given each items stock level. Takes into account the quantity of each item in the bundle. If the bundle calls for 5 of item A and 1 of item B and item A has a stock level of 10 and item B has a stock level of 10. This method will return 2 since that is the number of bundles that those stock levels can support.

Parameters:
pId - The id of the bundle
Returns:
the largest quantity of the bundle that can be allocated
Throws:
InventoryException

queryBundleBackorderLevel

protected long queryBundleBackorderLevel(java.lang.String pId)
                                  throws InventoryException
Cycles through the items in a bundle and returns the greatest quantity of bundles that could be allocated given each items backorder level. Takes into account the quantity of each item in the bundle. If the bundle calls for 5 of item A and 1 of item B and item A has a backorder level of 10 and item B has a backorder level of 10. This method will return 2 since that is the number of bundles that those backorder levels can support.

Parameters:
pId - The id of the bundle
Returns:
the largest quantity of the bundle that can be backordered
Throws:
InventoryException

queryBundlePreorderLevel

protected long queryBundlePreorderLevel(java.lang.String pId)
                                 throws InventoryException
Cycles through the items in a bundle and returns the greatest quantity of bundles that could be preordered given each items backorder level. Takes into account the quantity of each item in the bundle. If the bundle calls for 5 of item A and 1 of item B and item A has a preorder level of 10 and item B has a preorder level of 10. This method will return 2 since that is the number of bundles that those preorder levels can support.

Parameters:
pId - The id of the bundle
Returns:
the largest quantity of the bundle that can be preordered
Throws:
InventoryException

queryBundleStockThreshold

protected long queryBundleStockThreshold(java.lang.String pId)
                                  throws InventoryException
Currently all bundles have thresholds of 0. If this behavior should change, override this method.

Parameters:
pId - The id of the bundle
Returns:
0
Throws:
InventoryException

queryBundleBackorderThreshold

protected long queryBundleBackorderThreshold(java.lang.String pId)
                                      throws InventoryException
Currently all bundles have thresholds of 0. If this behavior should change, override this method.

Parameters:
pId - The id of the bundle
Returns:
0
Throws:
InventoryException

queryBundlePreorderThreshold

protected long queryBundlePreorderThreshold(java.lang.String pId)
                                     throws InventoryException
Currently all bundles have thresholds of 0. If this behavior should change, override this method.

Parameters:
pId - The id of the bundle
Returns:
0
Throws:
InventoryException

queryBundleAvailabilityDate

public java.util.Date queryBundleAvailabilityDate(java.lang.String pBundleId)
                                           throws InventoryException
Cycles through each item in a bundle and calls queryAvailabilityDate on each. This method returns the latest of those dates.

Parameters:
pBundleId - The id of the bundle
Returns:
The availabilityDate of the bundle
Throws:
InventoryException
MissingInventoryItemException
See Also:
queryAvailabilityDate(java.lang.String)