com.konakartadmin.bl
Class AdminOrderBatchMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminBatchBaseMgr
          extended by com.konakartadmin.bl.AdminOrderBatchMgr

public class AdminOrderBatchMgr
extends AdminBatchBaseMgr

The OrderBatchMgr


Nested Class Summary
protected  class AdminOrderBatchMgr.OrderProdList
          A return object containing a list of OrderProducts and the last OrderId processed
protected  class AdminOrderBatchMgr.OrderProdStatus
          Object stored in the hash maps
 
Nested classes/interfaces inherited from class com.konakartadmin.bl.AdminBaseMgr
AdminBaseMgr.StaticData
 
Field Summary
 
Fields inherited from class com.konakartadmin.bl.AdminBatchBaseMgr
log
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminOrderBatchMgr(KKAdminIf eng)
           
 
Method Summary
 java.lang.String createInvoicesBatch(java.lang.String logName, java.lang.String appendLogStr, java.lang.String recordFetchSizeStr)
          The method creates invoices for all orders that currently have a null invoice_filename.
protected  com.konakart.bl.KKCriteria getInvoiceOrderCriteria(int size)
          Create a criteria object for reading the Orders for creating invoices
protected  AdminOrder[] getOrderArrayFromList(java.util.List<AdminOrder> ordersForCustomer)
          Creates an array of Orders from a list.
protected  AdminOrderProduct[] getOrderProdArrayFromList(java.util.List<AdminOrderProduct> opForOrderList)
          Creates an array of Order Products from a list.
protected  com.konakart.bl.KKCriteria getOrderProductCriteria(int size)
          Create a criteria object for reading the OrderProducts
protected  AdminOrderBatchMgr.OrderProdList getOrderProducts(com.konakart.bl.KKCriteria c, int orderId, java.util.HashMap<java.lang.String,AdminOrderBatchMgr.OrderProdStatus> skuHM, java.util.HashMap<java.lang.Integer,AdminOrderBatchMgr.OrderProdStatus> idHM)
          The method returns null when all of the order products have been read.
protected  AdminOrder[] getOrders(com.konakart.bl.KKCriteria c, int orderId)
          The method returns an array of orders which will be empty when all of the orders have been read.
protected  com.konakart.bl.KKCriteria getUnpaidOrderCriteria(int size, int numDays, int[] validOrderStates)
          Create a criteria object for reading unpaid orders
protected  java.util.List<AdminOrder> getUnpaidOrders(com.konakart.bl.KKCriteria c)
          The method returns null when all of the orders have been read.
 java.lang.String productAvailabilityNotificationBatch(java.lang.String logName, java.lang.String appendLogStr, java.lang.String recordFetchSizeStr, java.lang.String emailTemplateName, java.lang.String numEmailThreadsStr)
          The method detects orders that haven't been fully delivered because one or more products were out of stock when the order was placed.
 java.lang.String recurringBillingBatch(java.lang.String logName, java.lang.String appendLogStr, java.lang.String recordFetchSizeStr)
          The method loops through all active subscriptions that have a next billing date set to the current date.
protected  void sendProductAvailabilityEmail(java.io.BufferedWriter bw, AdminOrderMgrIf orderMgr, AdminCustomerMgrIf custMgr, AdminOrderProduct[] opArray, com.konakart.bl.KKCriteria selectCrit, com.konakart.bl.KKCriteria updateCrit, java.lang.String templateName, java.util.concurrent.ExecutorService executor)
          protected method to send the mail and then reset the order products
protected  void sendUnpaidOrderEmail(java.io.BufferedWriter bw, AdminOrderMgrIf orderMgr, AdminCustomerMgrIf custMgr, AdminOrder[] orderArray, com.konakart.bl.KKCriteria selectCrit, com.konakart.bl.KKCriteria updateCrit, java.lang.String templateName, java.util.concurrent.ExecutorService executor, int newState)
          protected method to send the eMail and then change the order states.
protected  void setOrderProductState(AdminOrderProduct[] orderProds, int newState, com.konakart.bl.KKCriteria selectCrit, com.konakart.bl.KKCriteria updateCrit)
          Set the state of the list of order products passed in.
protected  void setOrderState(AdminOrder[] orders, int newState, com.konakart.bl.KKCriteria selectCrit, com.konakart.bl.KKCriteria updateCrit)
          Set the state of the list of orders passed in.
 java.lang.String unpaidOrderNotificationBatch(java.lang.String logName, java.lang.String appendLogStr, java.lang.String recordFetchSizeStr, java.lang.String emailTemplateName, java.lang.String numEmailThreadsStr, java.lang.String numDaysStr, java.lang.String validOrderStatesStr, java.lang.String newStateStr)
          An email is sent to all customers when a number of days has passed since they submitted their order and the order is not in one of the valid order states.
 
Methods inherited from class com.konakartadmin.bl.AdminBatchBaseMgr
executeQuery, getBoolean, getInt, getIntArray, getLogName, validateTemplate
 
Methods inherited from class com.konakartadmin.bl.AdminBaseMgr
addInsertAttr, addInsertAttr, checkIntIsSet, checkRequired, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminHtmlMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminPublishProdMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getExportXMLData, getIntFromString, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getPostSearchText, getPreSearchText, getPropertyValue, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, manageException, refreshConfigs, removeCData, setAdminEng, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminOrderBatchMgr

public AdminOrderBatchMgr(KKAdminIf eng)
                   throws java.lang.Exception
Parameters:
eng -
Throws:
java.lang.Exception
Method Detail

unpaidOrderNotificationBatch

public java.lang.String unpaidOrderNotificationBatch(java.lang.String logName,
                                                     java.lang.String appendLogStr,
                                                     java.lang.String recordFetchSizeStr,
                                                     java.lang.String emailTemplateName,
                                                     java.lang.String numEmailThreadsStr,
                                                     java.lang.String numDaysStr,
                                                     java.lang.String validOrderStatesStr,
                                                     java.lang.String newStateStr)
                                              throws java.lang.Exception
An email is sent to all customers when a number of days has passed since they submitted their order and the order is not in one of the valid order states. When the eMail has been sent, the order is set to a new state. If a customer has more than one unpaid order, only one mail is sent for all orders.

Parameters:
logName - The name of the log which shouldn't include the path or extension. i.e. It should be myLog rather than /logs/myLog.txt.
appendLogStr - If set to false, a new log will be created every time the batch job is run. Otherwise new data will be appended to the existing log. It defaults to false.
recordFetchSizeStr - It the batch involves reading many records in a loop, this determines the maximum number read in any one loop. It defaults to 100.
emailTemplateName - The name of the eMail template if the batch involves sending eMails to customers. The name should not include the extension or the underscore+country code. i.e. It should be myTemplate rather than myTemplate_en.vm. The country code and file extension will be added automatically.
numEmailThreadsStr - If the batch involves sending eMails to customers, this determines how many eMail sender threads are used. It defaults to 5.
numDaysStr - The number of days that needs to have passed before a mail is sent
validOrderStatesStr - An array of integers that determine valid order states. If the order is in a valid state then a mail is not sent. They are in a format "1-4-7" where "-" is the delimiter.
newStateStr - The state that the order should be set to once a mail has been sent.
Returns:
Returns the number of mails sent
Throws:
java.lang.Exception

productAvailabilityNotificationBatch

public java.lang.String productAvailabilityNotificationBatch(java.lang.String logName,
                                                             java.lang.String appendLogStr,
                                                             java.lang.String recordFetchSizeStr,
                                                             java.lang.String emailTemplateName,
                                                             java.lang.String numEmailThreadsStr)
                                                      throws java.lang.Exception
The method detects orders that haven't been fully delivered because one or more products were out of stock when the order was placed. It detects the products that were out of stock and that didn't have an Available Date set when they were ordered. If the available date is now available, an eMail is sent to the customer (one eMail even for multiple products) and the state of the OrderProduct object is changed so that the eMail is not sent again next time the method is run.

Parameters:
logName - The name of the log which shouldn't include the path or extension. i.e. It should be myLog rather than /logs/myLog.txt.
appendLogStr - If set to false, a new log will be created every time the batch job is run. Otherwise new data will be appended to the existing log. It defaults to false.
recordFetchSizeStr - It the batch involves reading many records in a loop, this determines the maximum number read in any one loop. It defaults to 100.
emailTemplateName - The name of the eMail template if the batch involves sending eMails to customers. The name should not include the extension or the underscore+country code. i.e. It should be myTemplate rather than myTemplate_en.vm. The country code and file extension will be added automatically.
numEmailThreadsStr - If the batch involves sending eMails to customers, this determines how many eMail sender threads are used. It defaults to 5.
Returns:
Returns the number of eMails sent
Throws:
java.lang.Exception

createInvoicesBatch

public java.lang.String createInvoicesBatch(java.lang.String logName,
                                            java.lang.String appendLogStr,
                                            java.lang.String recordFetchSizeStr)
                                     throws java.lang.Exception
The method creates invoices for all orders that currently have a null invoice_filename.

Once the invoice has been created the order is updated with the name of the filename of the invoice.

Parameters:
logName - The name of the log which shouldn't include the path or extension. i.e. It should be myLog rather than /logs/myLog.txt.
appendLogStr - If set to false, a new log will be created every time the batch job is run. Otherwise new data will be appended to the existing log. It defaults to false.
recordFetchSizeStr - It the batch involves reading many records in a loop, this determines the maximum number read in any one loop. It defaults to 100.
Returns:
Returns the number of invoices created
Throws:
java.lang.Exception

recurringBillingBatch

public java.lang.String recurringBillingBatch(java.lang.String logName,
                                              java.lang.String appendLogStr,
                                              java.lang.String recordFetchSizeStr)
                                       throws java.lang.Exception
The method loops through all active subscriptions that have a next billing date set to the current date. The payment is made by interfacing to the payment gateway and the subscription object is updated with a new next billing date. The subscription object is also updated if the transaction with the payment gateway fails.

Parameters:
logName - The name of the log which shouldn't include the path or extension. i.e. It should be myLog rather than /logs/myLog.txt.
appendLogStr - If set to false, a new log will be created every time the batch job is run. Otherwise new data will be appended to the existing log. It defaults to false.
recordFetchSizeStr - It the batch involves reading many records in a loop, this determines the maximum number read in any one loop. It defaults to 100.
Returns:
Returns the number of payment transactions performed
Throws:
java.lang.Exception

getOrderProdArrayFromList

protected AdminOrderProduct[] getOrderProdArrayFromList(java.util.List<AdminOrderProduct> opForOrderList)
Creates an array of Order Products from a list. We need to get a unique instance since it is passed to a thread to send the eMail. It can't just be a pointer to the list.

Parameters:
opForOrderList -
Returns:
An array of Order Products

getOrderArrayFromList

protected AdminOrder[] getOrderArrayFromList(java.util.List<AdminOrder> ordersForCustomer)
Creates an array of Orders from a list. We need to get a unique instance since it is passed to a thread to send the eMail. It can't just be a pointer to the list.

Parameters:
ordersForCustomer -
Returns:
An array of Orders

sendUnpaidOrderEmail

protected void sendUnpaidOrderEmail(java.io.BufferedWriter bw,
                                    AdminOrderMgrIf orderMgr,
                                    AdminCustomerMgrIf custMgr,
                                    AdminOrder[] orderArray,
                                    com.konakart.bl.KKCriteria selectCrit,
                                    com.konakart.bl.KKCriteria updateCrit,
                                    java.lang.String templateName,
                                    java.util.concurrent.ExecutorService executor,
                                    int newState)
                             throws java.lang.Exception
protected method to send the eMail and then change the order states.

Parameters:
bw -
orderMgr -
custMgr -
orderArray -
selectCrit -
updateCrit -
templateName -
executor -
newState -
Throws:
java.lang.Exception

sendProductAvailabilityEmail

protected void sendProductAvailabilityEmail(java.io.BufferedWriter bw,
                                            AdminOrderMgrIf orderMgr,
                                            AdminCustomerMgrIf custMgr,
                                            AdminOrderProduct[] opArray,
                                            com.konakart.bl.KKCriteria selectCrit,
                                            com.konakart.bl.KKCriteria updateCrit,
                                            java.lang.String templateName,
                                            java.util.concurrent.ExecutorService executor)
                                     throws java.lang.Exception
protected method to send the mail and then reset the order products

Parameters:
bw -
orderMgr -
custMgr -
opArray -
selectCrit -
updateCrit -
templateName -
executor -
Throws:
java.lang.Exception

getUnpaidOrders

protected java.util.List<AdminOrder> getUnpaidOrders(com.konakart.bl.KKCriteria c)
                                              throws java.lang.Exception
The method returns null when all of the orders have been read. The caller can stop looping when he receives null.

Parameters:
c -
Returns:
Returns a list of AdminOrders
Throws:
java.lang.Exception

getOrderProducts

protected AdminOrderBatchMgr.OrderProdList getOrderProducts(com.konakart.bl.KKCriteria c,
                                                            int orderId,
                                                            java.util.HashMap<java.lang.String,AdminOrderBatchMgr.OrderProdStatus> skuHM,
                                                            java.util.HashMap<java.lang.Integer,AdminOrderBatchMgr.OrderProdStatus> idHM)
                                                     throws java.lang.Exception
The method returns null when all of the order products have been read. If we don't need to send any emails for any of the read order products then it returns an empty list. The can stop looping when he receives null. We loop through the list of order products and create a return list that just contains the ones that have a delivery date and weren't in stock.

Parameters:
c -
orderId - We only fetch order products for orders with an id >= to this
skuHM -
idHM -
Returns:
Returns a list of AdminOrderProducts and last order processed
Throws:
java.lang.Exception

getOrders

protected AdminOrder[] getOrders(com.konakart.bl.KKCriteria c,
                                 int orderId)
                          throws java.lang.Exception
The method returns an array of orders which will be empty when all of the orders have been read.

Parameters:
c -
Returns:
Returns a list of AdminOrderProducts and last order processed
Throws:
java.lang.Exception

setOrderProductState

protected void setOrderProductState(AdminOrderProduct[] orderProds,
                                    int newState,
                                    com.konakart.bl.KKCriteria selectCrit,
                                    com.konakart.bl.KKCriteria updateCrit)
                             throws org.apache.torque.TorqueException
Set the state of the list of order products passed in.

Parameters:
orderProds -
newState -
selectCrit -
updateCrit -
Throws:
org.apache.torque.TorqueException

setOrderState

protected void setOrderState(AdminOrder[] orders,
                             int newState,
                             com.konakart.bl.KKCriteria selectCrit,
                             com.konakart.bl.KKCriteria updateCrit)
                      throws org.apache.torque.TorqueException
Set the state of the list of orders passed in.

Parameters:
orders -
newState -
selectCrit -
updateCrit -
Throws:
org.apache.torque.TorqueException

getUnpaidOrderCriteria

protected com.konakart.bl.KKCriteria getUnpaidOrderCriteria(int size,
                                                            int numDays,
                                                            int[] validOrderStates)
Create a criteria object for reading unpaid orders

Parameters:
size -
validOrderStates -
Returns:
KKCriteria object

getOrderProductCriteria

protected com.konakart.bl.KKCriteria getOrderProductCriteria(int size)
Create a criteria object for reading the OrderProducts

Parameters:
size -
Returns:
KKCriteria object

getInvoiceOrderCriteria

protected com.konakart.bl.KKCriteria getInvoiceOrderCriteria(int size)
Create a criteria object for reading the Orders for creating invoices

Parameters:
size -
Returns:
KKCriteria object


Copyright © 2011 DS Data Systems UK Ltd.