com.konakartadmin.bl
Class AdminSolrMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminSolrMgr
All Implemented Interfaces:
AdminSolrMgrIf

public class AdminSolrMgr
extends AdminBaseMgr
implements AdminSolrMgrIf

The AdminSolrMgr - for Managing the interface to the SOLR search server


Nested Class Summary
protected  class AdminSolrMgr.StaticData
          Used to store the static data of this manager
 
Field Summary
protected static java.lang.String END
           
protected static org.apache.commons.logging.Log log
          the log
protected static java.lang.String MIDDLE
           
protected static java.lang.String mutex
           
protected static boolean PDFReaderPresent
           
protected static java.lang.String START
           
protected static java.util.Map<java.lang.String,AdminSolrMgr.StaticData> staticDataHM
          Hash Map that contains the static data
static int TT_CAT
          static variable for term type
static int TT_CAT_MANU
          static variable for term type
static int TT_MANU
          static variable for term type
static int TT_MANU_CAT
          static variable for term type
static int TT_MODEL
          static variable for term type
static int TT_NAME
          static variable for term type
protected static java.lang.String TYPE_PDF
           
protected static java.lang.String TYPE_TEXT
           
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminSolrMgr(KKAdminIf eng)
          Constructor
 
Method Summary
 void addAllProductsToSearchEngine(boolean async)
          Loop through all of the products in the KonaKart database and add them to the Solr search engine.
 void addAllProductsToSearchEngineSync()
          Loop through all of the products in the KonaKart database and add them to the Solr search engine
 void addProductToSearchEngine(int productId)
          Add a single product referenced by productId to the Solr search engine
 void addProductToSearchEngine(int productId, java.lang.String storeId)
          Add a single product referenced by productId to the Solr search engine.
protected  void addTerm(int type, java.lang.StringBuffer sb, java.lang.String langCode, java.lang.String term, int prodId, int catId, int manuId, java.lang.String storeId)
          Common code to add a term for dynamic suggested searching
private  void checkPDFReaderPresent()
           
protected  java.lang.String getAttachmentText(AdminProduct product)
          Returns the text from the attachment so that it can be indexed in SOLR
protected  java.lang.StringBuffer getDocFromProduct(int productId, java.lang.String storeId, java.util.HashMap<java.lang.Integer,AdminLanguage> langMap)
          Create an XML string from the product object that can be passed to Solr
protected  java.lang.String getFileType(java.lang.String filePath)
          Returns the file extension
protected  java.util.HashMap<java.lang.Integer,AdminLanguage> getLangMap()
          Returns a HashMap mapping language id to language
 int getSolrCommitFrequency()
          The chunk size of records read from the database and written to SOLR after which a SOLR commit command is sent.
protected  java.net.URL getSolrUrl()
          Get the Solr Url from a configuration variable
protected  void isEnabled()
          Throws an exception if Solr isn't enabled.
protected static boolean isPDFReaderPresent()
           
 void refreshConfigs()
          Refresh the configuration of the Admin Solr Manager
 void removeAllProductsFromSearchEngine(boolean async)
          Remove all products from the Solr search engine.
 void removeAllProductsFromSearchEngineSync()
          Remove all products from the Solr search engine
 void removeProductFromSearchEngine(int productId)
          Remove a single product referenced by productId from the Solr search engine
 void removeProductFromSearchEngine(int productId, java.lang.String storeId)
          Remove a single product referenced by productId from the Solr search engine.
protected static void setPDFReaderPresent(boolean readerPresent)
           
 boolean useSolr()
          Returns true if Solr can be used, otherwise it returns false
 
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, 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
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


mutex

protected static java.lang.String mutex

staticDataHM

protected static java.util.Map<java.lang.String,AdminSolrMgr.StaticData> staticDataHM
Hash Map that contains the static data


START

protected static final java.lang.String START
See Also:
Constant Field Values

MIDDLE

protected static final java.lang.String MIDDLE
See Also:
Constant Field Values

END

protected static final java.lang.String END
See Also:
Constant Field Values

TYPE_TEXT

protected static final java.lang.String TYPE_TEXT
See Also:
Constant Field Values

TYPE_PDF

protected static final java.lang.String TYPE_PDF
See Also:
Constant Field Values

TT_CAT

public static final int TT_CAT
static variable for term type

See Also:
Constant Field Values

TT_MANU

public static final int TT_MANU
static variable for term type

See Also:
Constant Field Values

TT_CAT_MANU

public static final int TT_CAT_MANU
static variable for term type

See Also:
Constant Field Values

TT_MANU_CAT

public static final int TT_MANU_CAT
static variable for term type

See Also:
Constant Field Values

TT_NAME

public static final int TT_NAME
static variable for term type

See Also:
Constant Field Values

TT_MODEL

public static final int TT_MODEL
static variable for term type

See Also:
Constant Field Values

PDFReaderPresent

protected static boolean PDFReaderPresent
Constructor Detail

AdminSolrMgr

public AdminSolrMgr(KKAdminIf eng)
             throws java.lang.Exception
Constructor

Parameters:
eng - the Admin Engine
Throws:
java.lang.Exception
Method Detail

addAllProductsToSearchEngine

public void addAllProductsToSearchEngine(boolean async)
                                  throws java.lang.Exception
Loop through all of the products in the KonaKart database and add them to the Solr search engine. It uses a separate thread since the operation may take a while.

Specified by:
addAllProductsToSearchEngine in interface AdminSolrMgrIf
Parameters:
async - If true we do it asynchronously
Throws:
java.lang.Exception

addAllProductsToSearchEngineSync

public void addAllProductsToSearchEngineSync()
                                      throws java.lang.Exception
Loop through all of the products in the KonaKart database and add them to the Solr search engine

Specified by:
addAllProductsToSearchEngineSync in interface AdminSolrMgrIf
Throws:
java.lang.Exception

getSolrCommitFrequency

public int getSolrCommitFrequency()
The chunk size of records read from the database and written to SOLR after which a SOLR commit command is sent. The default value is 100.

Specified by:
getSolrCommitFrequency in interface AdminSolrMgrIf
Returns:
Returns an integer

removeAllProductsFromSearchEngine

public void removeAllProductsFromSearchEngine(boolean async)
                                       throws org.apache.torque.TorqueException,
                                              com.workingdogs.village.DataSetException,
                                              java.lang.Exception
Remove all products from the Solr search engine. It uses a separate thread since the operation may take a while.

Specified by:
removeAllProductsFromSearchEngine in interface AdminSolrMgrIf
Parameters:
async - If true we do it asynchronously
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

removeAllProductsFromSearchEngineSync

public void removeAllProductsFromSearchEngineSync()
                                           throws org.apache.torque.TorqueException,
                                                  com.workingdogs.village.DataSetException,
                                                  java.lang.Exception
Remove all products from the Solr search engine

Specified by:
removeAllProductsFromSearchEngineSync in interface AdminSolrMgrIf
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

removeProductFromSearchEngine

public void removeProductFromSearchEngine(int productId)
                                   throws org.apache.torque.TorqueException,
                                          com.workingdogs.village.DataSetException,
                                          java.lang.Exception
Remove a single product referenced by productId from the Solr search engine

Specified by:
removeProductFromSearchEngine in interface AdminSolrMgrIf
Parameters:
productId -
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

removeProductFromSearchEngine

public void removeProductFromSearchEngine(int productId,
                                          java.lang.String storeId)
                                   throws org.apache.torque.TorqueException,
                                          com.workingdogs.village.DataSetException,
                                          java.lang.Exception
Remove a single product referenced by productId from the Solr search engine. The store is selected by the storeId parameter.

Specified by:
removeProductFromSearchEngine in interface AdminSolrMgrIf
Parameters:
productId -
storeId -
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

addProductToSearchEngine

public void addProductToSearchEngine(int productId,
                                     java.lang.String storeId)
                              throws java.lang.Exception
Add a single product referenced by productId to the Solr search engine. The store is selected by the storeId parameter.

Specified by:
addProductToSearchEngine in interface AdminSolrMgrIf
Parameters:
productId -
storeId -
Throws:
java.lang.Exception

addProductToSearchEngine

public void addProductToSearchEngine(int productId)
                              throws java.lang.Exception
Add a single product referenced by productId to the Solr search engine

Specified by:
addProductToSearchEngine in interface AdminSolrMgrIf
Parameters:
productId -
Throws:
java.lang.Exception

getLangMap

protected java.util.HashMap<java.lang.Integer,AdminLanguage> getLangMap()
                                                                 throws org.apache.torque.TorqueException,
                                                                        com.workingdogs.village.DataSetException,
                                                                        KKAdminException,
                                                                        java.lang.Exception
Returns a HashMap mapping language id to language

Returns:
Returns a HashMap mapping language id to language
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException
java.lang.Exception

getDocFromProduct

protected java.lang.StringBuffer getDocFromProduct(int productId,
                                                   java.lang.String storeId,
                                                   java.util.HashMap<java.lang.Integer,AdminLanguage> langMap)
                                            throws java.lang.Exception
Create an XML string from the product object that can be passed to Solr

Parameters:
productId -
storeId -
Returns:
Returns the XML representation of the product required by Solr
Throws:
java.lang.Exception

addTerm

protected void addTerm(int type,
                       java.lang.StringBuffer sb,
                       java.lang.String langCode,
                       java.lang.String term,
                       int prodId,
                       int catId,
                       int manuId,
                       java.lang.String storeId)
                throws KKAdminException
Common code to add a term for dynamic suggested searching

Parameters:
type - Used when specializing this method to decide whether to not include certain terms in the search.
sb -
langCode -
term -
prodId -
catId -
manuId -
storeId -
Throws:
KKAdminException

getAttachmentText

protected java.lang.String getAttachmentText(AdminProduct product)
                                      throws java.lang.Exception
Returns the text from the attachment so that it can be indexed in SOLR

Parameters:
product -
Returns:
Returns the text
Throws:
java.lang.Exception

checkPDFReaderPresent

private void checkPDFReaderPresent()
                            throws KKAdminException
Throws:
KKAdminException

getFileType

protected java.lang.String getFileType(java.lang.String filePath)
Returns the file extension

Parameters:
filePath -
Returns:
The file extension

getSolrUrl

protected java.net.URL getSolrUrl()
                           throws org.apache.torque.TorqueException,
                                  com.workingdogs.village.DataSetException,
                                  java.lang.Exception
Get the Solr Url from a configuration variable

Returns:
Returns the Solr Url
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

refreshConfigs

public void refreshConfigs()
                    throws java.lang.Exception
Refresh the configuration of the Admin Solr Manager

Specified by:
refreshConfigs in interface AdminSolrMgrIf
Overrides:
refreshConfigs in class AdminBaseMgr
Throws:
java.lang.Exception

useSolr

public boolean useSolr()
                throws java.lang.Exception
Returns true if Solr can be used, otherwise it returns false

Specified by:
useSolr in interface AdminSolrMgrIf
Returns:
Returns true if Solr can be used, otherwise it returns false
Throws:
java.lang.Exception
com.konakart.app.KKException

isEnabled

protected void isEnabled()
                  throws java.lang.Exception
Throws an exception if Solr isn't enabled.

Throws:
com.konakart.app.KKException
java.lang.Exception

isPDFReaderPresent

protected static boolean isPDFReaderPresent()
Returns:
the pDFReaderPresent

setPDFReaderPresent

protected static void setPDFReaderPresent(boolean readerPresent)
Parameters:
readerPresent - the pDFReaderPresent to set


Copyright © 2011 DS Data Systems UK Ltd.