atg.projects.store.inventory
Class StoreInventoryManager

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
                  extended by atg.projects.store.inventory.StoreInventoryManager
All Implemented Interfaces:
atg.commerce.inventory.InventoryManager, atg.dms.patchbay.MessageSink, atg.dms.patchbay.MessageSource, atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener

public class StoreInventoryManager
extends atg.commerce.inventory.RepositoryInventoryManager

This class is an extension of the RepositoryInventoryManager. It will be responsible for writing to the inventory repository. This should only happen from the fulfillment server.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
static long DEFAULT_THRESHOLD_LEVEL
          Default threshold level constant.
static java.lang.String PARAM_SITE_ID
           
static java.lang.String RQL_QUERY_DUPLICATE_BACK_IN_STOCK_ITEM
          RQL query for duplicating item.
 
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
StoreInventoryManager()
           
 
Method Summary
protected  void createBackInStockNotifyItem(atg.repository.MutableRepository pRepository, java.lang.String pCatalogRefId, java.lang.String pEmail, java.lang.String pProductId)
          Creates the required item in the repository.
protected  void createBackInStockNotifyItem(atg.repository.MutableRepository pRepository, java.lang.String pCatalogRefId, java.lang.String pEmail, java.lang.String pProductId, java.lang.String pLocale, java.lang.String pSiteId)
           
protected  int deriveAvailabilityStatus(java.lang.String skuId)
          Derive the availabilityStatus based on the properties of the item.
 java.util.Date getBackorderAvailabilityDate(java.lang.String pSkuId)
          Get the availabilityDate from the inventory data for a sku item.
 StoreCatalogProperties getCatalogProperties()
           
 long getDefaultThresholdLevel()
          The default value if the stock level of an item is not defined.
protected  long getInventoryLevel(atg.repository.RepositoryItem inventory, java.lang.String inventoryLevelPropertyName, long defaultLevel)
          Given the inventory item of note get the inventory level for the particular property.
 atg.repository.Repository getOrderRepository()
           
 java.util.Date getPreorderAvailabilityDate(atg.repository.RepositoryItem pProduct)
          Get the availabilityDate for a product.
 StorePropertyManager getPropertyManager()
           
protected  java.lang.Object getPropertyValue(atg.repository.RepositoryItem item, java.lang.String propertyName)
          Returns the object associated with the given property name.
 int increaseStockLevel(java.lang.String skuId, long quantity)
          This method will send an "UpdateInventory" message if the item changes from Out of stock to In stock with this method.
 boolean isBackInStockItemExists(atg.repository.MutableRepository pRepository, java.lang.String pCatalogRefId, java.lang.String pEmail, java.lang.String pProductId)
          Check to see if backInStoreNotifyItem already exists for this combination of CatalogRefId and email.
 int queryAvailabilityStatus(atg.repository.RepositoryItem pProduct, java.lang.String pSkuId)
          Derive the availabilityStatus based on the properties of the product and the item.
 void setCatalogProperties(StoreCatalogProperties pCatalogProperties)
           
 void setDefaultThresholdLevel(long pDefaultThresholdLevel)
          Default value if the stock level of an item is not defined.
 void setOrderRepository(atg.repository.Repository pOrderRepository)
           
 void setPropertyManager(StorePropertyManager pPropertyManager)
           
 int setStockLevel(java.lang.String skuId, long quantity)
          This method will send an "UpdateInventory" message if the item changes from Out of stock to In stock with this method.
 
Methods inherited from class atg.commerce.inventory.RepositoryInventoryManager
acquireInventoryLocks, backorder, backorderBundle, decreaseBackorderLevel, decreasePreorderLevel, decreaseStockLevel, decrementSKULevel, deriveBundleAvailabilityStatus, getAvailabilityDatePropertyName, getAvailabilityStatusBackorderableValue, getAvailabilityStatusDerivedValue, getAvailabilityStatusDiscontinuedValue, getAvailabilityStatusInStockValue, getAvailabilityStatusOutOfStockValue, getAvailabilityStatusPreorderableValue, getAvailabilityStatusPropertyName, getBackorderLevelPropertyName, getBackorderThresholdPropertyName, getBundledIds, getBundleLinks, getBundleLinks, getBundleLinksPropertyName, getCatalogRefIdMatchQuery, getCatalogRefIdPropertyName, getCatalogRefItem, getCatalogRefItemType, getCatalogRefRepository, getClientLockManager, getDefaultBackorderLevel, getDefaultPreorderLevel, getDefaultStockLevel, getInventoryEventPort, getInventoryItem, getInventoryItemForUpdate, getInventoryName, getInventoryRowLockProperty, getInventoryRowLockSQL, getItemType, getMaximumRetriesPerRowLock, getMessageIdGenerator, getMessageIdSpaceName, getMillisecondDelayBeforeLockRetry, getNextMessageId, getPreorderLevelPropertyName, getPreorderThresholdPropertyName, getRepository, getSkuLinkItemPropertyName, getSkuLinkQuantityPropertyName, getStockLevelPropertyName, getStockThresholdPropertyName, getUpdateInventoryPort, increaseBackorderLevel, increasePreorderLevel, inventoryWasUpdated, isBundle, lock, preorder, preorderBundle, purchase, purchaseBundle, purchaseBundleOffBackorder, purchaseBundleOffPreorder, purchaseOffBackorder, purchaseOffPreorder, queryAvailabilityDate, queryAvailabilityStatus, queryBackorderLevel, queryBackorderThreshold, queryBundleAvailabilityDate, queryBundleBackorderLevel, queryBundleBackorderThreshold, queryBundlePreorderLevel, queryBundlePreorderThreshold, queryBundleStockLevel, queryBundleStockThreshold, queryPreorderLevel, queryPreorderThreshold, queryStockLevel, queryStockThreshold, releaseInventoryLocks, setAvailabilityDate, setAvailabilityDatePropertyName, setAvailabilityStatus, setAvailabilityStatusBackorderableValue, setAvailabilityStatusDerivedValue, setAvailabilityStatusDiscontinuedValue, setAvailabilityStatusInStockValue, setAvailabilityStatusOutOfStockValue, setAvailabilityStatusPreorderableValue, setAvailabilityStatusPropertyName, setBackorderLevel, setBackorderLevelPropertyName, setBackorderThreshold, setBackorderThresholdPropertyName, setBundleLinksPropertyName, setCatalogRefIdMatchQuery, setCatalogRefIdPropertyName, setCatalogRefItemType, setCatalogRefRepository, setClientLockManager, setDefaultBackorderLevel, setDefaultPreorderLevel, setDefaultStockLevel, setInventoryEventPort, setInventoryName, setInventoryRowLockProperty, setInventoryRowLockSQL, setItemType, setMaximumRetriesPerRowLock, setMessageIdGenerator, setMessageIdSpaceName, setMillisecondDelayBeforeLockRetry, setPreorderLevel, setPreorderLevelPropertyName, setPreorderThreshold, setPreorderThresholdPropertyName, setRepository, setSkuLinkItemPropertyName, setSkuLinkQuantityPropertyName, setStockLevelPropertyName, setStockThreshold, setStockThresholdPropertyName, setUpdateInventoryPort, thresholdHasBeenReached, unlock, updateItem
 
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

PARAM_SITE_ID

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

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string.


RQL_QUERY_DUPLICATE_BACK_IN_STOCK_ITEM

public static java.lang.String RQL_QUERY_DUPLICATE_BACK_IN_STOCK_ITEM
RQL query for duplicating item.


DEFAULT_THRESHOLD_LEVEL

public static final long DEFAULT_THRESHOLD_LEVEL
Default threshold level constant.

See Also:
Constant Field Values
Constructor Detail

StoreInventoryManager

public StoreInventoryManager()
Method Detail

getPropertyManager

public StorePropertyManager getPropertyManager()
Returns:
the StorePropertyManager

setPropertyManager

public void setPropertyManager(StorePropertyManager pPropertyManager)
Parameters:
PropertyManager - the StorePropertyManager to set

setDefaultThresholdLevel

public void setDefaultThresholdLevel(long pDefaultThresholdLevel)
Default value if the stock level of an item is not defined.

Parameters:
pDefaultThresholdLevel - default threshold level

getDefaultThresholdLevel

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

Returns:
default threshold level

getOrderRepository

public atg.repository.Repository getOrderRepository()
Returns:
order repository.

setOrderRepository

public void setOrderRepository(atg.repository.Repository pOrderRepository)
Parameters:
pOrderRepository - - order repository.

getCatalogProperties

public StoreCatalogProperties getCatalogProperties()
Returns:
catalog properties.

setCatalogProperties

public void setCatalogProperties(StoreCatalogProperties pCatalogProperties)
Parameters:
pCatalogProperties - - catalog properties to set.

setStockLevel

public int setStockLevel(java.lang.String skuId,
                         long quantity)
                  throws atg.commerce.inventory.InventoryException
This method will send an "UpdateInventory" message if the item changes from Out of stock to In stock with this method.

Specified by:
setStockLevel in interface atg.commerce.inventory.InventoryManager
Overrides:
setStockLevel in class atg.commerce.inventory.RepositoryInventoryManager
Parameters:
skuId - The id of the SKU whose stockLevel is being set
quantity - The amount to set the stockLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock level was set successfully. INVENTORY_STATUS_ITEM_NOT_FOUND if no item could be found for the SKU.
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

increaseStockLevel

public int increaseStockLevel(java.lang.String skuId,
                              long quantity)
                       throws atg.commerce.inventory.InventoryException
This method will send an "UpdateInventory" message if the item changes from Out of stock to In stock with this method.

Specified by:
increaseStockLevel in interface atg.commerce.inventory.InventoryManager
Overrides:
increaseStockLevel in class atg.commerce.inventory.RepositoryInventoryManager
Parameters:
skuId - The id of the SKU whose stockLevel is being increased.
quantity - The amount to increase the stockLevel to.
Returns:
INVENTORY_STATUS_SUCCEED if the item's stock level was set successfully. INVENTORY_STATUS_ITEM_NOT_FOUND if no item could be found for the SKU.
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

deriveAvailabilityStatus

protected int deriveAvailabilityStatus(java.lang.String skuId)
                                throws atg.commerce.inventory.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 > stockThreshold) return IN_STOCK; else if (backorderLevel > backorderThreshold) return BACKORDERABLE; else if (preorderLevel > preorderThreshold) return PREORDERABLE; else return OUT_OF_STOCK;

Overrides:
deriveAvailabilityStatus in class atg.commerce.inventory.RepositoryInventoryManager
Parameters:
skuId - The sku we are deriving the status for
Returns:
The derived status
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

queryAvailabilityStatus

public int queryAvailabilityStatus(atg.repository.RepositoryItem pProduct,
                                   java.lang.String pSkuId)
                            throws atg.commerce.inventory.InventoryException
Derive the availabilityStatus based on the properties of the product and the item. Always derives the status, does not check the current value of availabilityStatus. Preorderability is checked first. Preorderability can be set based just on product properties or on a combination of product properties and inventory levels. The end date for preorderability can be set to a fixed date or use stockLevel to determine when it ends. If an item is not preorderable, then the inventory levels are checked to see if it is available, backorderable or unavailable.

Parameters:
pProduct - The product we are deriving the status for
pSkuId - The sku we are deriving the status for
Returns:
The derived status
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

getPreorderAvailabilityDate

public java.util.Date getPreorderAvailabilityDate(atg.repository.RepositoryItem pProduct)
Get the availabilityDate for a product.

Parameters:
pProduct - The product we are getting the availability date for
Returns:
The availabilityDate which may be null

getBackorderAvailabilityDate

public java.util.Date getBackorderAvailabilityDate(java.lang.String pSkuId)
                                            throws atg.commerce.inventory.InventoryException
Get the availabilityDate from the inventory data for a sku item.

Parameters:
pSkuId - The sku we are getting the availability date for
Returns:
The availabilityDate which may be null
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

getInventoryLevel

protected long getInventoryLevel(atg.repository.RepositoryItem inventory,
                                 java.lang.String inventoryLevelPropertyName,
                                 long defaultLevel)
                          throws atg.commerce.inventory.InventoryException
Given the inventory item of note get the inventory level for the particular property.

Parameters:
inventory - - The inventory repository Item to work with
inventoryLevelPropertyName - - the property name of the inventory property that denotes the level
defaultLevel - a default level if the property is unset
Returns:
Returns the inventory level stored for the property or the default if not found.
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information

getPropertyValue

protected java.lang.Object getPropertyValue(atg.repository.RepositoryItem item,
                                            java.lang.String propertyName)
                                     throws atg.commerce.inventory.InventoryException
Returns the object associated with the given property name.

Parameters:
item - the repository item to fetch the value from
propertyName - the property value to return
Returns:
The object, null if pItem is null or pPropertyName is null.
Throws:
atg.commerce.inventory.InventoryException - if there was an error while attempting to return the inventory information. An error can occur if no item can be found with the given id; if the value from the named property is null, or a general RepositoryException occurs.

isBackInStockItemExists

public boolean isBackInStockItemExists(atg.repository.MutableRepository pRepository,
                                       java.lang.String pCatalogRefId,
                                       java.lang.String pEmail,
                                       java.lang.String pProductId)
                                throws atg.repository.RepositoryException
Check to see if backInStoreNotifyItem already exists for this combination of CatalogRefId and email.

Parameters:
pRepository - Repository where to check if item exists
pCatalogRefId - repository id
pEmail - string that represents email
pProductId - product id
pItemDescriptor - item descriptor
Returns:
true if item exists
Throws:
atg.repository.RepositoryException - if there was an error while creating repository item

createBackInStockNotifyItem

protected void createBackInStockNotifyItem(atg.repository.MutableRepository pRepository,
                                           java.lang.String pCatalogRefId,
                                           java.lang.String pEmail,
                                           java.lang.String pProductId)
                                    throws atg.repository.RepositoryException
Creates the required item in the repository.

Parameters:
pRepository - Repository where to create item
pCatalogRefId - repository id
pEmail - string that represents email
pProductId - product id
Throws:
atg.repository.RepositoryException - if there was an error while creating repository item

createBackInStockNotifyItem

protected void createBackInStockNotifyItem(atg.repository.MutableRepository pRepository,
                                           java.lang.String pCatalogRefId,
                                           java.lang.String pEmail,
                                           java.lang.String pProductId,
                                           java.lang.String pLocale,
                                           java.lang.String pSiteId)
                                    throws atg.repository.RepositoryException
Throws:
atg.repository.RepositoryException