public class AdminAIBatchMgr extends AdminBatchBaseMgr
Modifier and Type | Class and Description |
---|---|
protected class |
AdminAIBatchMgr.CustRetList
A return object containing a list of Customers and the last customer Id processed
|
AdminBatchBaseMgr.CustTagCounter
AdminBaseMgr.StaticData
Modifier and Type | Field and Description |
---|---|
(package private) static int |
CONNECT_TIMEOUT |
private com.google.gson.Gson |
gson |
protected static org.apache.commons.logging.Log |
log
the log
|
(package private) static int |
READ_TIMEOUT |
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, debugStackTraceExclusions, kkAdminPropsFilePath, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
Constructor and Description |
---|
AdminAIBatchMgr(KKAdminIf eng) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
attrExists(com.google.gson.JsonObject jsonObj,
java.lang.String attr) |
private int |
calcConfidence(int score,
int maxScore) |
private boolean |
exportCustomers(java.lang.String sessId,
java.io.BufferedWriter bw,
ExporterOptions exporterOptions) |
private void |
exportProducts(java.lang.String sessId,
java.io.BufferedWriter bw,
ExporterOptions exporterOptions) |
private void |
generateTag(java.lang.String sessId,
java.io.BufferedWriter bw,
ExporterOptions exporterOptions) |
protected float |
getAsFloat(com.google.gson.JsonObject jsonObj,
java.lang.String attr) |
protected int |
getAsInt(com.google.gson.JsonObject jsonObj,
java.lang.String attr) |
protected com.google.gson.JsonArray |
getAsJsonArray(com.google.gson.JsonObject jsonObj,
java.lang.String attr) |
protected com.google.gson.JsonObject |
getAsJsonObject(java.lang.String response,
boolean returnNullIfMissing) |
protected java.lang.String |
getAsString(com.google.gson.JsonObject jsonObj,
java.lang.String attr) |
protected java.lang.String |
getAsString(com.google.gson.JsonObject jsonObj,
java.lang.String attr,
boolean returnNullIfMissing) |
protected AdminAIBatchMgr.CustRetList |
getCustomers(com.konakart.db.KKCriteria c,
int custId)
The method returns a null list within the return object when all of the customers have been
read.
|
com.google.gson.Gson |
getGson() |
private java.util.List<java.lang.Integer> |
getIdsInTag(AdminCustomerTag custTag,
AdminCustomerTag tagDetail) |
protected com.konakart.db.KKCriteria |
getLiteCustomerCriteria(int size)
Get the criteria object to retrieve lite customers
|
private int |
getMaxPairCount(java.io.BufferedWriter bw,
java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> orderedProductsByProduct) |
private java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> |
getOrderedProductIds(java.io.BufferedWriter bw) |
private java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> |
getOrderedProductIdsByProduct(java.io.BufferedWriter bw,
java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> orderedProductsByCustomer) |
private java.util.Set<java.lang.Integer> |
getOrderedProductIdsForCustomer(int custId) |
void |
getProductRecommendationSuggestions(java.lang.String logName,
java.lang.String appendLogStr,
java.lang.String dataDirectory,
java.lang.String aiServiceUrl,
java.lang.String loadDBStr,
java.lang.String genTagPROPERTIES_TIME_VIEWEDStr,
java.lang.String genRandomDataStr,
java.lang.String maxAnalysisTimeMinsStr,
java.lang.String loadVersion,
java.lang.String minConfidenceStr,
java.lang.String custFieldMap,
java.lang.String sessId)
Get Product Recommendation Suggestions data from the AI Service
|
private java.util.HashMap<java.lang.Integer,AdminCustomerTag> |
populateCustTagsHash(java.io.BufferedWriter bw) |
private java.lang.String |
postFile(java.lang.String url,
java.lang.String request,
java.lang.String params,
java.lang.String filename,
java.lang.String storeId,
java.lang.String verb) |
java.lang.String |
postRequest(java.lang.String aiUrl,
java.lang.String request,
java.lang.String params,
java.lang.String filename,
int maxAttempts,
java.lang.String storeId,
java.lang.String verb) |
java.lang.String |
postRequest(java.lang.String url,
java.lang.String request,
java.lang.String params,
java.lang.String filename,
java.lang.String storeId,
java.lang.String verb) |
java.lang.String |
prettyJson(java.lang.String jsonString)
Convert a JSON string to pretty print version
|
java.lang.String |
prettyJsonArray(java.lang.String jsonString)
Convert a JSON Array string to pretty print version
|
private void |
processCustomersKonaKartService(java.io.BufferedWriter bw,
java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> orderedProductsByCustomer,
java.util.HashMap<java.lang.Integer,AdminCustomerTag> custTagHash,
boolean loadDB,
java.lang.String loadVersion,
int minConfidence) |
private void |
processInKonaKartService(java.io.BufferedWriter bw,
java.lang.String dataDir,
boolean loadDB,
java.lang.String loadVersion,
int minConfidence) |
private void |
processInZucchettiService(java.io.BufferedWriter bw,
java.lang.String aiServiceUrl,
java.lang.String uploadFile,
java.lang.String maxAnalysisTimeMinsStr,
java.lang.String dataDir,
boolean loadDB,
int chunkSize,
java.lang.String loadVersion,
int minConfidence) |
private void |
processProductsKonaKartService(java.io.BufferedWriter bw,
java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> orderedProductsByProduct,
int maxPairCount,
boolean loadDB,
java.lang.String loadVersion,
int minConfidence) |
protected int |
updateCustomerSuggestionsInDBKonaKartService(int custId,
java.util.HashMap<java.lang.Integer,java.lang.Integer> productScoresHash,
java.lang.String loadVersion,
int productScoreMax,
int minConfidence) |
ensureCustomerTagIsPresent, getAdEngConf, getAdminJsonEngine, getBatchLogName, getBoolean, getCustomerTagsHash, getInt, getIntArray, getIntArray, getLiteCustomers, getLogName, getOrders, getSkuForProduct, insertOrUpdateCustomerTag, trimMultiTag, validateTemplate
addInsertAttr, addInsertAttr, addStringRuleConstraint, addStringRuleConstraint, checkAPICallEnabled, checkIntInRange, checkIntIsSet, checkRequired, executeQuery, executeQuery, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminContentMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustPwdHistMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminEngineCacheMgr, getAdminEventMgr, getAdminExecuteMgr, getAdminFileMgr, getAdminFilterMgr, getAdminHtmlMgr, getAdminImportMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminMiscPriceMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminServletMgr, getAdminShipmentMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminSuggestionMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getDebugStackTraceExclusions, getEmailThreadGracefulShutdownTimeout, getExportMgr, getExportMgr, getExportXMLData, getIntFromString, getKkAdminPropsFilePath, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getNewCriteria, getNewCriteria, getOtherModuleByName, getPostSearchText, getPreSearchText, getProductsToCategoresCriteria, getPropertyValue, getPropertyValue, getPropertyValueAsBool, getPropertyValueAsInt, getPropertyValueAsLong, getRecordCount, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, insertKKEvent, insertKKEvent, isBusiness, isBusinessOrEnterprise, isCommunity, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareCustomersOrProducts, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, isUnix, isWindows, manageException, manageThrowable, refreshConfigs, removeCData, sendMQMessages, setAdminEng, setDebugStackTraceExclusions, setKkAdminPropsFilePath, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr, updateStaticVariablesNow
protected static org.apache.commons.logging.Log log
private com.google.gson.Gson gson
static int CONNECT_TIMEOUT
static int READ_TIMEOUT
public AdminAIBatchMgr(KKAdminIf eng) throws java.lang.Exception
eng
- the KKAdminIf enginejava.lang.Exception
- an unexpected exceptionpublic void getProductRecommendationSuggestions(java.lang.String logName, java.lang.String appendLogStr, java.lang.String dataDirectory, java.lang.String aiServiceUrl, java.lang.String loadDBStr, java.lang.String genTagPROPERTIES_TIME_VIEWEDStr, java.lang.String genRandomDataStr, java.lang.String maxAnalysisTimeMinsStr, java.lang.String loadVersion, java.lang.String minConfidenceStr, java.lang.String custFieldMap, java.lang.String sessId) throws java.lang.Exception
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.dataDirectory
- data directory for storing intermediate files. If not specified the directory
KonaKartAIData data is created under INSTALLATION_HOMEaiServiceUrl
- AI service URL (use an empty String if you don't want to use an external AI
Service)loadDBStr
- if "true" the results are loaded into the databasegenTagPROPERTIES_TIME_VIEWEDStr
- if "true" the PROPERTIES_TIME_VIEWED tag is generatedgenRandomDataStr
- if "true" generate random datamaxAnalysisTimeMinsStr
- maximum time (in minutes) that we'll wait for the analysis to complete before
giving uploadVersion
- Suggestions will be loaded wit this version numberminConfidenceStr
- Only add suggestions where the confidence level (0 to 999) is greater than this
valuecustFieldMap
- Custom field mapping (e.g. #1,#2,FAVOURITE_COLOUR,#4,#5)sessId
- sessionIdjava.lang.Exception
- an unexpected exceptionprivate void exportProducts(java.lang.String sessId, java.io.BufferedWriter bw, ExporterOptions exporterOptions) throws java.lang.Exception
java.lang.Exception
private void processInKonaKartService(java.io.BufferedWriter bw, java.lang.String dataDir, boolean loadDB, java.lang.String loadVersion, int minConfidence) throws KKAdminException, java.lang.Exception
KKAdminException
java.lang.Exception
private java.util.HashMap<java.lang.Integer,AdminCustomerTag> populateCustTagsHash(java.io.BufferedWriter bw) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException, java.lang.Exception
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException
java.lang.Exception
private void processCustomersKonaKartService(java.io.BufferedWriter bw, java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> orderedProductsByCustomer, java.util.HashMap<java.lang.Integer,AdminCustomerTag> custTagHash, boolean loadDB, java.lang.String loadVersion, int minConfidence) throws java.lang.Exception
java.lang.Exception
private void processProductsKonaKartService(java.io.BufferedWriter bw, java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> orderedProductsByProduct, int maxPairCount, boolean loadDB, java.lang.String loadVersion, int minConfidence) throws java.lang.Exception
java.lang.Exception
private int calcConfidence(int score, int maxScore)
private java.util.Set<java.lang.Integer> getOrderedProductIdsForCustomer(int custId) throws com.workingdogs.village.DataSetException, org.apache.torque.TorqueException, KKAdminException
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKAdminException
private java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> getOrderedProductIds(java.io.BufferedWriter bw) throws java.lang.Exception
java.lang.Exception
private java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> getOrderedProductIdsByProduct(java.io.BufferedWriter bw, java.util.HashMap<java.lang.Integer,java.util.Set<java.lang.Integer>> orderedProductsByCustomer) throws java.io.IOException
java.io.IOException
private int getMaxPairCount(java.io.BufferedWriter bw, java.util.HashMap<java.lang.Integer,java.util.HashMap<java.lang.Integer,java.lang.Integer>> orderedProductsByProduct) throws java.io.IOException
java.io.IOException
protected int updateCustomerSuggestionsInDBKonaKartService(int custId, java.util.HashMap<java.lang.Integer,java.lang.Integer> productScoresHash, java.lang.String loadVersion, int productScoreMax, int minConfidence) throws KKAdminException, java.lang.Exception
KKAdminException
java.lang.Exception
private java.util.List<java.lang.Integer> getIdsInTag(AdminCustomerTag custTag, AdminCustomerTag tagDetail) throws KKAdminException
KKAdminException
private void processInZucchettiService(java.io.BufferedWriter bw, java.lang.String aiServiceUrl, java.lang.String uploadFile, java.lang.String maxAnalysisTimeMinsStr, java.lang.String dataDir, boolean loadDB, int chunkSize, java.lang.String loadVersion, int minConfidence) throws java.lang.Exception
java.lang.Exception
protected AdminAIBatchMgr.CustRetList getCustomers(com.konakart.db.KKCriteria c, int custId) throws java.lang.Exception
c
- the ccustId
- the customerId (only customers with customerId greater than this will be returned)java.lang.Exception
- an unexpected exceptionprotected com.konakart.db.KKCriteria getLiteCustomerCriteria(int size) throws KKAdminException
getLiteCustomerCriteria
in class AdminBatchBaseMgr
size
- the number of records to retrieve at a timeKKAdminException
- if something unexpected happened in the KKAdmin enginepublic java.lang.String postRequest(java.lang.String url, java.lang.String request, java.lang.String params, java.lang.String filename, java.lang.String storeId, java.lang.String verb) throws java.lang.Exception
url
- URLrequest
- request stringparams
- parameters as a stringfilename
- file namestoreId
- storeIdverb
- verb (GET/PUT)java.lang.Exception
- an unexpected exceptionpublic java.lang.String postRequest(java.lang.String aiUrl, java.lang.String request, java.lang.String params, java.lang.String filename, int maxAttempts, java.lang.String storeId, java.lang.String verb) throws java.lang.Exception
aiUrl
- URLrequest
- request stringparams
- parameters as a stringfilename
- file namemaxAttempts
- maximum number of attemptsstoreId
- storeIdverb
- verb (GET/PUT)java.lang.Exception
- an unexpected exceptionprivate java.lang.String postFile(java.lang.String url, java.lang.String request, java.lang.String params, java.lang.String filename, java.lang.String storeId, java.lang.String verb) throws java.lang.Exception
java.lang.Exception
private void generateTag(java.lang.String sessId, java.io.BufferedWriter bw, ExporterOptions exporterOptions) throws java.lang.Exception
java.lang.Exception
private boolean exportCustomers(java.lang.String sessId, java.io.BufferedWriter bw, ExporterOptions exporterOptions) throws java.lang.Exception
java.lang.Exception
public com.google.gson.Gson getGson()
public java.lang.String prettyJsonArray(java.lang.String jsonString)
jsonString
- a JSON stringpublic java.lang.String prettyJson(java.lang.String jsonString)
jsonString
- a JSON stringprotected boolean attrExists(com.google.gson.JsonObject jsonObj, java.lang.String attr) throws KKAdminException
KKAdminException
protected int getAsInt(com.google.gson.JsonObject jsonObj, java.lang.String attr) throws KKAdminException
KKAdminException
protected float getAsFloat(com.google.gson.JsonObject jsonObj, java.lang.String attr) throws KKAdminException
KKAdminException
protected com.google.gson.JsonArray getAsJsonArray(com.google.gson.JsonObject jsonObj, java.lang.String attr) throws KKAdminException
KKAdminException
protected com.google.gson.JsonObject getAsJsonObject(java.lang.String response, boolean returnNullIfMissing) throws KKAdminException
KKAdminException
protected java.lang.String getAsString(com.google.gson.JsonObject jsonObj, java.lang.String attr) throws KKAdminException
KKAdminException
protected java.lang.String getAsString(com.google.gson.JsonObject jsonObj, java.lang.String attr, boolean returnNullIfMissing) throws KKAdminException
KKAdminException
Copyright © 2018 DS Data Systems UK Ltd.