atg.commerce.order.abandoned
Class AbandonedOrderService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.scheduler.SchedulableService
              extended by atg.service.scheduler.SingletonSchedulableService
                  extended by atg.commerce.order.abandoned.AbandonedOrderService
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class AbandonedOrderService
extends SingletonSchedulableService

This service identifies orders that are considered abandoned and lost. The amount of time an order needs to be idle to be considered abandoned and lost is configurable. Also, a minimum amount an order has to be for to be considered abandoned or lost can also be configured. This service is an instance of the SingletonSchedulableService In scheduled mode locks must be acquired before the service is executed, to ensure that only one instance of this service is running at a given time. In non-scheduled mode locks are optional Lock names and timeouts are configurable

See Also:
SingletonSchedulableService.getLockName(), Author: Paul O'Brien

Nested Class Summary
protected  class AbandonedOrderService.AbandonedOrderBatchProcessor
          Processor for fetching and updating a given range of abandoned orders.
protected  class AbandonedOrderService.LostOrderBatchProcessor
          Processor for fetching and updating a given range of lost orders.
protected  class AbandonedOrderService.OrderBatchProcessor
          Base runner class for updating a range of orders.
 
Field Summary
protected static int ABANDONED_ORDERS
           
static java.lang.String CLASS_VERSION
          Class version string
protected static int LOST_ORDERS
           
protected static java.util.ResourceBundle sResourceBundle
          Resource Bundle
 
Fields inherited from class atg.service.scheduler.SchedulableService
mJobId
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
AbandonedOrderService()
           
 
Method Summary
protected  MutableRepositoryItem createAbandonmentInfo(RepositoryItem pOrder)
          Deprecated. Use AbandonedOrderTools to create an abandonmentInfo item instead
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
 void doScheduledTask(Scheduler pScheduler, ScheduledJob pScheduledJob)
          Callback method for the SingletonSchedulableService.
 RepositoryItem[] findAbandonedOrders()
          Deprecated. Use ranging and batching queries to process orders instead. This method is not used to process orders so overrides to this method will no longer have an effect on processing.
 RepositoryItem[] findLostOrders()
          Deprecated. Use ranging and batching queries to process orders instead. This method is not used to process orders so overrides to this method will no longer have an effect on processing.
protected  Query generateAbandonedOrdersRangeQuery()
          Generates the query for finding orders by the order date and one or more states that could mean an order is abandoned.
protected  Query generateAbandonedQuery(java.lang.String pStartingOrderId, java.lang.String pEndingOrderId, boolean pIsFirstBatch)
          This method generates the query to identify abandoned orders in batches.
protected  Query generateAbandonmentInfoIsNullQuery()
          Constructs the query for order.abandonmentInfo == null
protected  Query generateAbandonmentInfoQueryForAbandonedOrders()
          Deprecated. This has to be broken into three clauses and each clause and'd with the id/date/states constraints or the resulting query will be split in a manner that causes all orders to be returned.
protected  Query generateAbandonmentInfoQueryForLostOrders()
          Deprecated. This has to be broken into three clauses and each clause and'd with the id/date/states constraints or the resulting query will be split in a manner that causes all orders to be returned.
protected  Query generateAbandonmentInfoStateIsNullQuery()
          Constructs the query for order.abandonmentInfo.state == null
protected  Query generateAbandonmentInfoStatesQueryForAbandonedOrders()
          Constructs the query for order.abandonmentInfo.state == "REANIMATED" ...
protected  Query generateAbandonmentInfoStatesQueryForLostOrders()
          Constructs the query for order.abandonmentInfo.state != "LOST" ...
protected  Query generateDateQuery(int pIdleDays)
          This method generates the part of the abandoned/lost order query that deals with how long the order has been idle.
protected  Query generateLostOrdersRangeQuery()
          Generates the query for finding orders by the order date and one or more states that could mean an order is lost.
protected  Query generateLostQuery(java.lang.String pStartingOrderId, java.lang.String pEndingOrderId, boolean pIsFirstBatch)
          This method generates the query to identify abandoned orders in batches.
protected  Query generateMinimumAmountQuery()
          This method generates the part of the abandoned/lost order query that deals with the minimum amount an order must be for to identify the order as abandoned or lost.
protected  Query generateOrderIdBatchQuery(java.lang.String pStartingOrderId, java.lang.String pEndingOrderId, boolean pFirstBatch)
          Creates a comparison query to find all orders with order ids alphanumerically between the two given order ids.
protected  Query generateOrderStatesQuery()
          This method generates the part of the abandoned/lost order query that deals with what order states are considered possible for abandonment.
 RepositoryItem[] getAbandonedOrders()
          Deprecated. Call findAbandonedOrders() instead. The number of loaded orders is limited to getMaxAbandonedOrdersPerTransaction()
protected  RepositoryItem[] getAbandonedOrdersBatch(java.lang.String pStartingOrderId, java.lang.String pEndingOrderId, boolean pIsFirstBatch)
          Gets the abandoned orders between the given starting and ending order id based on the criteria defined by the abandoned order query.
 AbandonedOrderTools getAbandonedOrderTools()
           
 Query getAbandonmentInfoQueryForAbandonedOrders()
          If the property is null, generate the query by calling generateAbandonmentInfoQueryForAbandonedOrders, otherwise return the query stored in the property.
 Query getAbandonmentInfoQueryForLostOrders()
          If the property is null, generate the query by calling generateAbandonmentInfoQueryForLostOrders, otherwise return the query stored in the property.
 Query getDateQueryForAbandonedOrders()
          Generate the query by calling generateDateQuery.
 Query getDateQueryForLostOrders()
          Generate the query by calling generateDateQuery.
 java.lang.String getDateQueryPropertyName()
           
protected  java.util.concurrent.ExecutorService getExecutorService()
          Gets the Java ExecutorService that will manage the processing threads.
 int getIdleDaysUntilAbandoned()
           
 int getIdleDaysUntilLost()
           
 RepositoryItem[] getLostOrders()
          Deprecated. call findLostOrders() instead.
protected  RepositoryItem[] getLostOrdersBatch(java.lang.String pStartingOrderId, java.lang.String pEndingOrderId, boolean pIsFirstBatch)
          Gets the lost orders between the given starting and ending order id based on the criteria defined by the lost order query.
 int getMaxAbandonedOrdersPerTransaction()
          The maximum number of abandoned orders which will be updated at once.
 int getMaxLostOrdersPerTransaction()
          The maximum number of lost orders which will be updated at once.
 double getMinimumAmount()
           
 Query getMinimumAmountQuery()
          If the property is null, generate the query by calling generateMinimumAmountQuery, otherwise return the query stored in the property.
 int getNumberOfBatchesPerTransaction()
          Returns property numberOfBatchesPerTransaction
 int getNumberOfConcurrentUpdateThreads()
          Gets the number of threads that can do updates at the same time.
 int getNumberOfHoursToTimeOutThreads()
          Gets the number of hours to timeout threads.
 java.lang.String getOrderIdPropertyName()
          Gets the name of the property that represents the order id.
 java.lang.String getOrderStatePropertyName()
           
 Query getOrderStatesQuery()
          If the property is null, generate the query by calling generateOrderStatesQuery, otherwise return the query stored in the property.
 java.lang.String getPriceInfoPropertyName()
           
 ProcSavePriceInfoObjects getSavePriceInfoObjectsProcessor()
          Gets the processor that is used to save price infos for incomplete orders.
 int getSizeOfBatch()
          Returns property SizeOfBatch
 java.lang.String getSubtotalPropertyName()
           
 javax.transaction.TransactionManager getTransactionManager()
          Returns property transactionManager
 void processAbandonedOrders()
          This method gets the orders identified as abandoned, iterates through the results, calling the methods to update each order, and send an AbandonedOrderMessage.
protected  void processAbandonedOrders(RepositoryItem[] pOrders)
          This method takes the orders identified as abandoned, iterates through them, calling the methods to update each order, and send an AbandonedOrderMessage.
 void processLostOrders()
          This method gets the orders identified as lost, then iterates through the results, calling the methods to update each order, and send an AbandonedOrderMessage.
protected  void processLostOrders(RepositoryItem[] pOrders)
          This method takes the orders identified as lost, then iterates through them, calling the methods to update each order, and send an AbandonedOrderMessage.
 void setAbandonedOrderTools(AbandonedOrderTools pAbandonedOrderTools)
          AbandonedOrderTools contains property/item names and helper methods that manipulate abandonment data.
 void setAbandonmentInfoQueryForAbandonedOrders(Query pAbandonmentInfoQueryForAbandonedOrders)
          The part of the abandoned order query that deals with what abandonment states an order can have for it to be considered newly abandoned.
 void setAbandonmentInfoQueryForLostOrders(Query pAbandonmentInfoQueryForLostOrders)
          The part of the lost order query that deals with what abandonment states an order can have for it to be considered newly lost.
 void setDateQueryForAbandonedOrders(Query pDateQueryForAbandonedOrders)
          The part of the abandoned order query that relates to how long the order has been idle.
 void setDateQueryForLostOrders(Query pDateQueryForLostOrders)
          The part of the lost order query that relates to how long the order has been idle.
 void setDateQueryPropertyName(java.lang.String pDateQueryPropertyName)
          The name of the property in the order item descriptor that is to be used as the basis for the "idle time" part of the abandoned/lost queries Note: changing this property during runtime after this service has already run will not change the query - the queries are generated on the first run of this service.
protected  void setExecutorService(java.util.concurrent.ExecutorService pExecutorService)
          Sets the Java ExecutorService that will manage the processing threads.
 void setIdleDaysUntilAbandoned(int pIdleDaysUntilAbandoned)
          The number of days which an order needs to be idle before it is considered abandoned.
 void setIdleDaysUntilLost(int pIdleDaysUntilLost)
          The number of days which an order needs to be idle before it is considered lost.
 void setMaxAbandonedOrdersPerTransaction(int pMaxAbandonedOrdersPerTransaction)
           
 void setMaxLostOrdersPerTransaction(int pMaxLostOrdersPerTransaction)
           
 void setMinimumAmount(double pMinimumAmount)
          The minimum amount of an order for it to be considered abandoned or lost.
 void setMinimumAmountQuery(Query pMinimumAmountQuery)
          The part of the abandoned/lost order query that deals with the minimum total amount an order can have.
 void setNumberOfBatchesPerTransaction(int pNumberOfBatchesPerTransaction)
          Sets number of batches a single range query will process, when there is a large number of orders you could get time outs at the db level if you try and process all items at once.
 void setNumberOfConcurrentUpdateThreads(int pNumberOfConcurrentUpdateThreads)
          Sets the number of threads that can do updates at the same time.
 void setNumberOfHoursToTimeOutThreads(int pNumberOfHoursToTimeOutThreads)
          Sets the number of hours to timeout threads.
 void setOrderIdPropertyName(java.lang.String pOrderIdPropertyName)
          Sets the name of the property that represents the order id.
 void setOrderStatePropertyName(java.lang.String pOrderStatePropertyName)
          The name of the order property that indicates the state of the order.
 void setOrderStatesQuery(Query pOrderStatesQuery)
          The part of the abandoned/lost order query that deals with what order states are considered possible for abandonment.
 void setPriceInfoPropertyName(java.lang.String pPriceInfoPropertyName)
          The name of the property of the order repository item that refers to its priceInfo item.
 void setSavePriceInfoObjectsProcessor(ProcSavePriceInfoObjects pSavePriceInfoObjectsProcessor)
          Sets the processor that is used to save price infos for incomplete orders.
 void setSizeOfBatch(int pSizeOfBatch)
          Sets number of items a single thread will process
 void setSubtotalPropertyName(java.lang.String pSubtotalPropertyName)
          The name of the subtotal property of the priceInfo to compare the minimum amount against.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property transactionManager
protected  RepositoryItem updateAbandonedOrder(RepositoryItem pOrder)
          This method updates an order identified as abandoned.
protected  RepositoryItem updateLostOrder(RepositoryItem pOrder)
          This method updates an order identified as lost.
protected  void validateSavePriceInfoObjectsProcessor()
           
 
Methods inherited from class atg.service.scheduler.SingletonSchedulableService
acquireLock, getClientLockManager, getLockName, getLockTimeOut, performScheduledTask, releaseLock, setClientLockManager, setLockName, setLockTimeOut
 
Methods inherited from class atg.service.scheduler.SchedulableService
doStartService, doStopService, getJobDescription, getJobId, getJobName, getSchedule, getScheduler, getThreadMethod, getThreadMethodString, isTransactional, setJobDescription, setJobName, setSchedule, setScheduler, setThreadMethod, setThreadMethodString, setTransactional, startScheduledJob, stopScheduledJob
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle


ABANDONED_ORDERS

protected static int ABANDONED_ORDERS

LOST_ORDERS

protected static int LOST_ORDERS
Constructor Detail

AbandonedOrderService

public AbandonedOrderService()
Method Detail

setAbandonedOrderTools

public void setAbandonedOrderTools(AbandonedOrderTools pAbandonedOrderTools)
AbandonedOrderTools contains property/item names and helper methods that manipulate abandonment data.

Parameters:
pAbandonedOrderTools - the AbandonedOrderTools helper component.

getAbandonedOrderTools

public AbandonedOrderTools getAbandonedOrderTools()
Returns:
returns the AbandonedOrderTools helper component.

setIdleDaysUntilAbandoned

public void setIdleDaysUntilAbandoned(int pIdleDaysUntilAbandoned)
The number of days which an order needs to be idle before it is considered abandoned. Note: changing this property during runtime after this service has already run will not change the query - the queries are generated on the first run of this service. If you would like to change this property and have it change the query, set the dateQueryForAbandonedOrders property to null as well as changing this property.

Parameters:
pIdleDaysUntilAbandoned - the number of days which an order needs to be idle before it is considered abandoned.

getIdleDaysUntilAbandoned

public int getIdleDaysUntilAbandoned()
Returns:
Returns the number of days which an order needs to be idle before \ it is considered abandoned.

setIdleDaysUntilLost

public void setIdleDaysUntilLost(int pIdleDaysUntilLost)
The number of days which an order needs to be idle before it is considered lost. Note: changing this property during runtime after this service has already run will not change the query - the queries are generated on the first run of this service. If you would like to change this property and have it change the query, set the dateQueryForLostOrders property to null as well as changing this property.

Parameters:
pIdleDaysUntilLost - the number of days which an order needs to be idle before it is considered lost.

getIdleDaysUntilLost

public int getIdleDaysUntilLost()
Returns:
Returns the number of days which an order needs to be idle before it is considered lost.

getMaxLostOrdersPerTransaction

public int getMaxLostOrdersPerTransaction()
The maximum number of lost orders which will be updated at once. This value is used in processLostOrders() as a number of orders to be updated per transaction.

Returns:
the maxLostOrdersPerTransaction

setMaxLostOrdersPerTransaction

public void setMaxLostOrdersPerTransaction(int pMaxLostOrdersPerTransaction)
Parameters:
pMaxLostOrdersPerTransaction - the maximum number of orders

getMaxAbandonedOrdersPerTransaction

public int getMaxAbandonedOrdersPerTransaction()
The maximum number of abandoned orders which will be updated at once. This value is used in processAbandonedOrders() as a number of orders to be updated per transaction.

Returns:
the maxAbandonedOrdersPerTransaction

setMaxAbandonedOrdersPerTransaction

public void setMaxAbandonedOrdersPerTransaction(int pMaxAbandonedOrdersPerTransaction)
Parameters:
pMaxAbandonedOrdersPerTransaction - the maximum number of orders

setMinimumAmount

public void setMinimumAmount(double pMinimumAmount)
The minimum amount of an order for it to be considered abandoned or lost. Note: changing this property during runtime after this service has already run will not change the query - the queries are generated on the first run of this service. If you would like to change this property and have it change the query, set the minimumAmountQuery property to null as well as changing this property.

Parameters:
pMinimumAmount - the minimum amount of an order for it to be be considered abandoned or lost.

getMinimumAmount

public double getMinimumAmount()
Returns:
Returns the minimum amount of an order for it to be considered abandoned or lost.

setDateQueryPropertyName

public void setDateQueryPropertyName(java.lang.String pDateQueryPropertyName)
The name of the property in the order item descriptor that is to be used as the basis for the "idle time" part of the abandoned/lost queries Note: changing this property during runtime after this service has already run will not change the query - the queries are generated on the first run of this service. If you would like to change this property and have it change the query, set the dateQueryForAbandonedOrder and dateQueryForLostOrders properties to null as well as changing this property

Parameters:
pDateQueryPropertyName - the name of the property in the order item descriptor that is to be used as the basis for the "idle time" part of the abandoned/lost queries

getDateQueryPropertyName

public java.lang.String getDateQueryPropertyName()
Returns:
Returns the name of property in the order item descriptor that is to be used as thebasis for the "idle time" part of the abandoned/lost queries

setOrderStatePropertyName

public void setOrderStatePropertyName(java.lang.String pOrderStatePropertyName)
The name of the order property that indicates the state of the order.

Parameters:
pOrderStatePropertyName - the name of the order property that indicates the state of the order

getOrderStatePropertyName

public java.lang.String getOrderStatePropertyName()
Returns:
Returns the name of the order property that indicates the state of the order.

setPriceInfoPropertyName

public void setPriceInfoPropertyName(java.lang.String pPriceInfoPropertyName)
The name of the property of the order repository item that refers to its priceInfo item.

Parameters:
pPriceInfoPropertyName - the name of the property of the order repository item that refers to its priceInfo item.

getPriceInfoPropertyName

public java.lang.String getPriceInfoPropertyName()
Returns:
Returns the name of the property of the order repository item that refers to its priceInfo item.

setSubtotalPropertyName

public void setSubtotalPropertyName(java.lang.String pSubtotalPropertyName)
The name of the subtotal property of the priceInfo to compare the minimum amount against.

Parameters:
pSubtotalPropertyName - the name of the subtotal property of the priceInfo to compare the minimum amount against.

getSubtotalPropertyName

public java.lang.String getSubtotalPropertyName()
Returns:
returns the name of the subtotal property of the priceInfo to compare the minimum amount against.

setDateQueryForAbandonedOrders

public void setDateQueryForAbandonedOrders(Query pDateQueryForAbandonedOrders)
The part of the abandoned order query that relates to how long the order has been idle. This query will be of the form: "abandonmentInfo.orderLastUpdated < "Mon Nov 17 13:35:03 EDT 2003"

Parameters:
pDateQueryForAbandonedOrders - the part of the abandoned order query that relates to how long the order has been idle

getDateQueryForAbandonedOrders

public Query getDateQueryForAbandonedOrders()
                                     throws RepositoryException
Generate the query by calling generateDateQuery.

Returns:
returns the part of the abandoned order query that relates to how long the order has been idle.
Throws:
RepositoryException

setDateQueryForLostOrders

public void setDateQueryForLostOrders(Query pDateQueryForLostOrders)
The part of the lost order query that relates to how long the order has been idle. This query will be of the form: "abandonmentInfo.orderLastUpdated < "Mon Nov 17 13:35:03 EDT 2003"

Parameters:
pDateQueryForLostOrders - the part of the lost order query that relates to how long the order has been idle

getDateQueryForLostOrders

public Query getDateQueryForLostOrders()
                                throws RepositoryException
Generate the query by calling generateDateQuery.

Returns:
returns the part of the lost order query that relates to how long the order has been idle.
Throws:
RepositoryException

setOrderStatesQuery

public void setOrderStatesQuery(Query pOrderStatesQuery)
The part of the abandoned/lost order query that deals with what order states are considered possible for abandonment. This query will be of the form 'state = "INCOMPLETE"'.

Parameters:
pOrderStatesQuery - the part of the abandoned/lost order query that deals with what order states are considered possible for abandonment.

getOrderStatesQuery

public Query getOrderStatesQuery()
                          throws RepositoryException
If the property is null, generate the query by calling generateOrderStatesQuery, otherwise return the query stored in the property.

Returns:
returns the part of the abandoned/lost order query that deals with what order states are considered possible for abandonment.
Throws:
RepositoryException

setAbandonmentInfoQueryForAbandonedOrders

public void setAbandonmentInfoQueryForAbandonedOrders(Query pAbandonmentInfoQueryForAbandonedOrders)
The part of the abandoned order query that deals with what abandonment states an order can have for it to be considered newly abandoned. This query will be of the form 'abandonmentInfo is "null" OR abandonmentInfo.state = "REANIMATED" OR abandonmentInfo.state = "null"'

Parameters:
pAbandonmentInfoQueryForAbandonedOrders - the part of the abandoned order query that deals with what abandonment states an order can have for it to be considered newly abandoned

getAbandonmentInfoQueryForAbandonedOrders

public Query getAbandonmentInfoQueryForAbandonedOrders()
                                                throws RepositoryException
If the property is null, generate the query by calling generateAbandonmentInfoQueryForAbandonedOrders, otherwise return the query stored in the property.

Returns:
returns the part of the abandoned order query that deals with what abandonment states an order can have for it to be considered newly abandoned.
Throws:
RepositoryException

setAbandonmentInfoQueryForLostOrders

public void setAbandonmentInfoQueryForLostOrders(Query pAbandonmentInfoQueryForLostOrders)
The part of the lost order query that deals with what abandonment states an order can have for it to be considered newly lost. This query will be of the form 'abandonmentInfo = "null" OR abandonmentInfo.state != "LOST" OR abandonmentInfo.state = "null"'

Parameters:
pAbandonmentInfoQueryForLostOrders - the part of the lost order query that deals with what abandonment states an order can have for it to be considered newly lost

getAbandonmentInfoQueryForLostOrders

public Query getAbandonmentInfoQueryForLostOrders()
                                           throws RepositoryException
If the property is null, generate the query by calling generateAbandonmentInfoQueryForLostOrders, otherwise return the query stored in the property.

Returns:
returns the part of the lost order query that deals with what abandonment states an order can have for it to be considered newly lost.
Throws:
RepositoryException

setMinimumAmountQuery

public void setMinimumAmountQuery(Query pMinimumAmountQuery)
The part of the abandoned/lost order query that deals with the minimum total amount an order can have. This query will be of the form "priceInfo.rawSubtotal >= 100.00"

Parameters:
pMinimumAmountQuery - the part of the abandoned/lost order query that deals with the minimum total amount an order can have.

getMinimumAmountQuery

public Query getMinimumAmountQuery()
                            throws RepositoryException
If the property is null, generate the query by calling generateMinimumAmountQuery, otherwise return the query stored in the property.

Returns:
returns the part of the abandoned/lost order query that deals with the minimum total amount an order can have.
Throws:
RepositoryException

getSavePriceInfoObjectsProcessor

public ProcSavePriceInfoObjects getSavePriceInfoObjectsProcessor()
Gets the processor that is used to save price infos for incomplete orders.

Returns:

setSavePriceInfoObjectsProcessor

public void setSavePriceInfoObjectsProcessor(ProcSavePriceInfoObjects pSavePriceInfoObjectsProcessor)
Sets the processor that is used to save price infos for incomplete orders.

Parameters:
pSavePriceInfoObjectsProcessor -

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property transactionManager


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property transactionManager


setNumberOfBatchesPerTransaction

public void setNumberOfBatchesPerTransaction(int pNumberOfBatchesPerTransaction)
Sets number of batches a single range query will process, when there is a large number of orders you could get time outs at the db level if you try and process all items at once.


getNumberOfBatchesPerTransaction

public int getNumberOfBatchesPerTransaction()
Returns property numberOfBatchesPerTransaction


setSizeOfBatch

public void setSizeOfBatch(int pSizeOfBatch)
Sets number of items a single thread will process


getSizeOfBatch

public int getSizeOfBatch()
Returns property SizeOfBatch


getNumberOfConcurrentUpdateThreads

public int getNumberOfConcurrentUpdateThreads()
Gets the number of threads that can do updates at the same time.

Returns:
The number of threads.

setNumberOfConcurrentUpdateThreads

public void setNumberOfConcurrentUpdateThreads(int pNumberOfConcurrentUpdateThreads)
Sets the number of threads that can do updates at the same time.

Parameters:
pNumberOfConcurrentUpdateThreads - The number of threads.

getNumberOfHoursToTimeOutThreads

public int getNumberOfHoursToTimeOutThreads()
Gets the number of hours to timeout threads.

Returns:
The number of hours.

setNumberOfHoursToTimeOutThreads

public void setNumberOfHoursToTimeOutThreads(int pNumberOfHoursToTimeOutThreads)
Sets the number of hours to timeout threads.

Parameters:
pNumberOfHoursToTimeOutThreads - The number of hours.

getOrderIdPropertyName

public java.lang.String getOrderIdPropertyName()
                                        throws RepositoryException
Gets the name of the property that represents the order id.

Returns:
The order id property name.
Throws:
RepositoryException

setOrderIdPropertyName

public void setOrderIdPropertyName(java.lang.String pOrderIdPropertyName)
Sets the name of the property that represents the order id.

Parameters:
pOrderIdPropertyName - The order id property name.

setExecutorService

protected void setExecutorService(java.util.concurrent.ExecutorService pExecutorService)
Sets the Java ExecutorService that will manage the processing threads.

Parameters:
pExecutorService - The Java Executor service.

getExecutorService

protected java.util.concurrent.ExecutorService getExecutorService()
Gets the Java ExecutorService that will manage the processing threads.

Returns:
The Java Executor service.

generateDateQuery

protected Query generateDateQuery(int pIdleDays)
                           throws RepositoryException
This method generates the part of the abandoned/lost order query that deals with how long the order has been idle.

Parameters:
pIdleDays - the number of days orders need to be idle to be returned by this query.
Returns:
Returns query that will return orders idle for the given number of days.
Throws:
RepositoryException

generateOrderStatesQuery

protected Query generateOrderStatesQuery()
                                  throws RepositoryException
This method generates the part of the abandoned/lost order query that deals with what order states are considered possible for abandonment.

Returns:
Returns query that will return orders with the proper states.
Throws:
RepositoryException

generateAbandonmentInfoIsNullQuery

protected Query generateAbandonmentInfoIsNullQuery()
                                            throws RepositoryException
Constructs the query for order.abandonmentInfo == null

Returns:
The abandonmentInfo is null clause.
Throws:
RepositoryException

generateAbandonmentInfoStatesQueryForAbandonedOrders

protected Query generateAbandonmentInfoStatesQueryForAbandonedOrders()
                                                              throws RepositoryException
Constructs the query for order.abandonmentInfo.state == "REANIMATED" ...

Returns:
The abandonmentInfo state query comparison clause.
Throws:
RepositoryException

generateAbandonmentInfoStatesQueryForLostOrders

protected Query generateAbandonmentInfoStatesQueryForLostOrders()
                                                         throws RepositoryException
Constructs the query for order.abandonmentInfo.state != "LOST" ...

Returns:
The abandonmentInfo state query comparison clause.
Throws:
RepositoryException

generateAbandonmentInfoStateIsNullQuery

protected Query generateAbandonmentInfoStateIsNullQuery()
                                                 throws RepositoryException
Constructs the query for order.abandonmentInfo.state == null

Returns:
The abandonmentInfo state query is null clause.
Throws:
RepositoryException

generateAbandonmentInfoQueryForAbandonedOrders

protected Query generateAbandonmentInfoQueryForAbandonedOrders()
                                                        throws RepositoryException
Deprecated. This has to be broken into three clauses and each clause and'd with the id/date/states constraints or the resulting query will be split in a manner that causes all orders to be returned.

This method generates the part of the abandoned order query that deals with whether or not the order has abandonmentInfo already, and if it does what abandonment states are considered valid to identify an order as abandoned or lost. We want only orders that either have no abandonmentInfo, or those whose abandonment state is RECLAIMED or no state yet.

Returns:
Returns query that will return orders with the proper abandonment information.
Throws:
RepositoryException

generateAbandonmentInfoQueryForLostOrders

protected Query generateAbandonmentInfoQueryForLostOrders()
                                                   throws RepositoryException
Deprecated. This has to be broken into three clauses and each clause and'd with the id/date/states constraints or the resulting query will be split in a manner that causes all orders to be returned.

This method generates the part of the lost order query that deals with whether or not the order has abandonmentInfo already, and if it does what abandonment states are considered valid to identify an order as abandoned or lost. For lost queries, we want only orders that either have no abandonmentInfo, or those whose abandonment state is NOT already LOST or no state yet.

Returns:
Returns query that will return orders with the proper abandonment information.
Throws:
RepositoryException

generateMinimumAmountQuery

protected Query generateMinimumAmountQuery()
                                    throws RepositoryException
This method generates the part of the abandoned/lost order query that deals with the minimum amount an order must be for to identify the order as abandoned or lost. This will generate a query of the form "WHERE priceInfo.rawSubtotal >= {minimumAmount}"

Returns:
Returns query that will return orders worth more than the configured minimum amount or null if minimum amount property is 0
Throws:
RepositoryException

generateAbandonedQuery

protected Query generateAbandonedQuery(java.lang.String pStartingOrderId,
                                       java.lang.String pEndingOrderId,
                                       boolean pIsFirstBatch)
                                throws RepositoryException
This method generates the query to identify abandoned orders in batches.

Parameters:
pStartingOrderId - The id of the first order in the batch. Passing null defeats the batching and returns all abandoned orders at once. This is not recommended.
pEndingOrderId - The id of the last order in the batch. Passing null defeats the batching and returns all abandoned orders at once. This is not recommended.
pIsFirstBatch - True if this is the first batch. If it's the first batch then the first order will be processed otherwise it will be assumed it was processed in the last batch.
Returns:
The query to find the abandoned orders in the given batch.
Throws:
RepositoryException

generateLostQuery

protected Query generateLostQuery(java.lang.String pStartingOrderId,
                                  java.lang.String pEndingOrderId,
                                  boolean pIsFirstBatch)
                           throws RepositoryException
This method generates the query to identify abandoned orders in batches.

Parameters:
pStartingOrderId - The id of the first order in the batch. Passing null defeats the batching and returns all abandoned orders at once. This is not recommended.
pEndingOrderId - The id of the last order in the batch. Passing null defeats the batching and returns all abandoned orders at once. This is not recommended.
pIsFirstBatch - True if this is the first batch. If it's the first batch then the first order will be processed otherwise it will be assumed it was processed in the last batch.
Returns:
The query to find the abandoned orders in the given batch.
Throws:
RepositoryException

generateAbandonedOrdersRangeQuery

protected Query generateAbandonedOrdersRangeQuery()
                                           throws RepositoryException
Generates the query for finding orders by the order date and one or more states that could mean an order is abandoned. This query is used for finding ranges of orders that will be fed to the process for further constraining the order to process by abandonment info and/or minimum amount. When this query is executed it will be ordered by id and then by customer id.

Returns:
The query for finding abandonded orders by date and state(s).
Throws:
RepositoryException

generateLostOrdersRangeQuery

protected Query generateLostOrdersRangeQuery()
                                      throws RepositoryException
Generates the query for finding orders by the order date and one or more states that could mean an order is lost. This query is used for finding ranges of orders that will be fed to the process for further constraining the order to process by abandonment info and/or minimum amount. When this query is executed it will be ordered by id and then by customer id.

Returns:
The query for finding lost orders by date and state(s).
Throws:
RepositoryException

generateOrderIdBatchQuery

protected Query generateOrderIdBatchQuery(java.lang.String pStartingOrderId,
                                          java.lang.String pEndingOrderId,
                                          boolean pFirstBatch)
                                   throws RepositoryException
Creates a comparison query to find all orders with order ids alphanumerically between the two given order ids. If the firstBatch parameter is set, the batch will include the starting order id, otherwise it will not. The batch always includes the ending id.

Parameters:
pStartingOrderId - The starting order id.
pEndingOrderId - The ending order id.
Returns:
The comparison query ( order.id >= {starting id} AND order.id <= {ending id} ) for the first batch and ( order.id > {starting id} AND order.id <= {ending id} ) for all non-starting batches. If either the starting or ending index is empty then null is returned.
Throws:
RepositoryException

getAbandonedOrdersBatch

protected RepositoryItem[] getAbandonedOrdersBatch(java.lang.String pStartingOrderId,
                                                   java.lang.String pEndingOrderId,
                                                   boolean pIsFirstBatch)
                                            throws RepositoryException,
                                                   TransactionDemarcationException
Gets the abandoned orders between the given starting and ending order id based on the criteria defined by the abandoned order query.

Parameters:
pStartingOrderId - The starting order id.
pEndingOrderId - The ending order id.
pIsFirstBatch - If this is the first batch. The first batch includes the starting order id in processing.
Returns:
The batch of orders found between the given ids and matching the abandoned order criteria defined in the abandoned order query.
Throws:
RepositoryException
TransactionDemarcationException

getLostOrdersBatch

protected RepositoryItem[] getLostOrdersBatch(java.lang.String pStartingOrderId,
                                              java.lang.String pEndingOrderId,
                                              boolean pIsFirstBatch)
                                       throws RepositoryException,
                                              TransactionDemarcationException
Gets the lost orders between the given starting and ending order id based on the criteria defined by the lost order query.

Parameters:
pStartingOrderId - The starting order id.
pEndingOrderId - The ending order id.
pIsFirstBatch - If this is the first batch. The first batch includes the starting order id in processing.
Returns:
The batch of orders found between the given ids and matching the lost order criteria defined in the generateLostQuery method.
Throws:
RepositoryException
TransactionDemarcationException

getAbandonedOrders

public RepositoryItem[] getAbandonedOrders()
                                    throws RepositoryException
Deprecated. Call findAbandonedOrders() instead. The number of loaded orders is limited to getMaxAbandonedOrdersPerTransaction()

This method generates and executes the query for abandoned orders, and returns an array of order repository items representing the orders identified as abandoned. This method can be overridden if you would like to change the way abandoned orders are identified.

Returns:
Returns an array of order repository items representing the orders identified as abandoned.
Throws:
RepositoryException

findAbandonedOrders

public RepositoryItem[] findAbandonedOrders()
                                     throws RepositoryException
Deprecated. Use ranging and batching queries to process orders instead. This method is not used to process orders so overrides to this method will no longer have an effect on processing.

This method generates and executes the query for abandoned orders, and returns an array of order repository items representing the orders identified as abandoned. This method can be overridden if you would like to change the way abandoned orders are identified. The number of loaded orders is limited to getMaxAbandonedOrdersPerTransaction()

Returns:
Returns an array of order repository items representing the orders identified as abandoned.
Throws:
RepositoryException

getLostOrders

public RepositoryItem[] getLostOrders()
                               throws RepositoryException
Deprecated. call findLostOrders() instead.

This method generates and executes the query for lost orders, and returns an array of order repository items representing the orders identified as lost. This method can be overridden if you would like to change the way lost orders are identified. The number of loaded orders is limited to getMaxLostOrdersPerTransaction()

Returns:
Returns an array of order repository items representing the orders identified as lost.
Throws:
RepositoryException

findLostOrders

public RepositoryItem[] findLostOrders()
                                throws RepositoryException
Deprecated. Use ranging and batching queries to process orders instead. This method is not used to process orders so overrides to this method will no longer have an effect on processing.

This method generates and executes the query for lost orders, and returns an array of order repository items representing the orders identified as lost. This method can be overridden if you would like to change the way lost orders are identified. The number of loaded orders is limited to getMaxLostOrdersPerTransaction()

Returns:
Returns an array of order repository items representing the orders identified as lost.
Throws:
RepositoryException

createAbandonmentInfo

protected MutableRepositoryItem createAbandonmentInfo(RepositoryItem pOrder)
                                               throws RepositoryException
Deprecated. Use AbandonedOrderTools to create an abandonmentInfo item instead

This method generates a new abandonmentInfo object for the given order.

Parameters:
pOrder - the order repository item that needs an abandonmentInfo item created and associated with it
Throws:
RepositoryException

updateAbandonedOrder

protected RepositoryItem updateAbandonedOrder(RepositoryItem pOrder)
                                       throws RepositoryException
This method updates an order identified as abandoned. If no abandonmentInfo exists for the order, it is created. Otherwise, the abandonmentInfo item is updated. Also, the abandonedOrderCount of the profile that owns the order is incremented.

Parameters:
pOrder - the order that has been identified as abandoned
Returns:
Returns the new or updated abandonmentInfo repository item.
Throws:
RepositoryException

updateLostOrder

protected RepositoryItem updateLostOrder(RepositoryItem pOrder)
                                  throws RepositoryException,
                                         CommerceException
This method updates an order identified as lost. If no abandonmentInfo exists for the order, it is created. Otherwise, the abandonmentInfo item is updated. Also, the abandonedOrderCount of the profile that owns the order is decremented if the order was previously identified as abandoned.

Parameters:
pOrder - the order that has been identified as lost
Returns:
Returns the new or updated abandonmentInfo repository item.
Throws:
RepositoryException
CommerceException

processAbandonedOrders

public void processAbandonedOrders()
                            throws CommerceException
This method gets the orders identified as abandoned, iterates through the results, calling the methods to update each order, and send an AbandonedOrderMessage.

Throws:
CommerceException - If an underlying method throws an exception

processLostOrders

public void processLostOrders()
                       throws CommerceException
This method gets the orders identified as lost, then iterates through the results, calling the methods to update each order, and send an AbandonedOrderMessage.

Throws:
CommerceException - If an underlying method throws an exception

processAbandonedOrders

protected void processAbandonedOrders(RepositoryItem[] pOrders)
                               throws CommerceException
This method takes the orders identified as abandoned, iterates through them, calling the methods to update each order, and send an AbandonedOrderMessage.

Throws:
CommerceException
See Also:
getMaxAbandonedOrdersPerTransaction()

processLostOrders

protected void processLostOrders(RepositoryItem[] pOrders)
                          throws CommerceException
This method takes the orders identified as lost, then iterates through them, calling the methods to update each order, and send an AbandonedOrderMessage.

Parameters:
pOrders - The lost orders to process.
Throws:
CommerceException
See Also:
getMaxLostOrdersPerTransaction()

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
Creates and returns a new Servlet that will administer this service. The AbandonedOrderService implements its own admin servlet to hide getAbandonedOrders() and getLostOrders() from showing up as properties.

Overrides:
createAdminServlet in class GenericService
Returns:
admin servlet

doScheduledTask

public void doScheduledTask(Scheduler pScheduler,
                            ScheduledJob pScheduledJob)
Callback method for the SingletonSchedulableService.

Specified by:
doScheduledTask in class SingletonSchedulableService

validateSavePriceInfoObjectsProcessor

protected void validateSavePriceInfoObjectsProcessor()