atg.repository.search.indexing.config
Class SearchConfigurationXMLGenerator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.repository.search.indexing.config.SearchConfigurationXMLGenerator
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, java.util.EventListener

public class SearchConfigurationXMLGenerator
extends TimedOperationService

The SearchConfigurationXMLGenerator class (in the atg.repository.search.indexing.refinement package) is a Nucleus service that takes a searchConfig repository item and creates search-config XML. This XML uses the schema defined by ATG Search. The generator creates a W3C DOM object and uses Java's built in XML classes to create the XML stream from DOM Document. This can also be changed by setting the "transformer" property, or subclassing and extending the "transformToXML" method. This class is registered as a Nucleus component in DAF at /atg/search/repository/SearchConfigurationXMLGenerator This component has 'searchConfigurationRuleParser' property of type SearchConfigurationRuleParser and 'searchConfigurationMerger' property of type SearchConfigurationMerger. The XMLGenerator calls the parseRules method in the searchConfigurationRuleParser to get the list of rule objects for both the customer segment and the base searchConfig, and then calls the searchConfigurationMerger methods to create a merged list. After that XML is generated according to search-config XML schema using the merged rules and thesaurus and the ranking data in the searchConfig item. When base and segment ranking data exists, segment ranking data (as a block) should overwrite the base ones. This applies to ranking data only. These are wholesale, you use base or you use segment-based ranking data.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
SearchConfigurationXMLGenerator()
           
 
Method Summary
protected  void addTextElement(java.lang.String pText, java.lang.String pTagName, org.w3c.dom.Element pParent, org.w3c.dom.Document pDocument)
          Creates element with the text node inside
protected  void createConditionElement(java.util.Stack pCondition, org.w3c.dom.Element pParent, org.w3c.dom.Document pDocument)
          Creates sub-elements of <expression> element.
protected  org.w3c.dom.Document createDocument()
           
protected  void createPatternElement(atg.repository.search.config.SearchRulePattern pPattern, org.w3c.dom.Element pRule, org.w3c.dom.Document pDocument)
          Creates pattern element
protected  void createRuleElement(atg.repository.search.config.SearchRule pRule, org.w3c.dom.Element pRules, org.w3c.dom.Document pDocument)
          Creates rule element
protected  void createSynsetElement(RepositoryItem pSynset, org.w3c.dom.Element pTerms, org.w3c.dom.Document pDocument)
          Creates synset element
protected  void createTermElement(java.lang.String pReciprocal, java.lang.String pTerm, org.w3c.dom.Element pSynset, org.w3c.dom.Document pDocument)
          creates pTerm element
 void dump(org.w3c.dom.Document doc)
          Diagnostic method to write out generated xml to the file system.
 org.w3c.dom.Document generateSearchConfigDoc(RepositoryItem pCurrentSearchConfig, RepositoryItem pBaseSearchConfig, java.lang.String pRankConfigName)
          Generates search config XML into the DOM document
 void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig, RepositoryItem pBaseSearchConfig, java.io.OutputStream pOut)
          Generates search config XML into a DOM document and writes it out
 void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig, RepositoryItem pBaseSearchConfig, java.io.OutputStream pOut, java.lang.String pRankConfigName)
          Generates search config XML into a DOM document and writes it out
 void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig, RepositoryItem pBaseSearchConfig, java.io.Writer pWriter)
          Generates search config XML into a DOM document and writes it out
 java.lang.String getApplicationName()
          Get the String application name used to query the repository for the search config items to generate xml for.
 java.lang.String getDateFormat()
          Gets the String Format of dates used in date ranking properties.
 java.lang.String getDefaultLanguage()
          Gets the default language attribute to use for the search config xml
 java.lang.String getDefaultRankingMethod()
          Default ranking method name to use if the search config repository item rankingMethod property is null.
 javax.xml.parsers.DocumentBuilder getDocumentBuilder()
           
 java.lang.String getDumpPath()
          Full String path name to the directory to use if dumpFiles is true.
protected  java.lang.String getLanguageFromLocale(java.lang.String pLocale)
          Returns Search Engine language by locale string
 atg.repository.search.config.SearchConfigurationMerger getMerger()
          Gets the SearchConfigurationMerger to merge rules from the base search config item.
 java.lang.String getOverrideRankingMethod()
          Defaults to null but if set then forces the xml generator to use this String for the ranking method and ignores any setting from the search config repository item.
 atg.repository.search.config.SearchConfigurationRuleParser getParser()
          Gets the SearchConfigurationRuleParser to parse out the rules from a search config item.
 SearchConfigurationPropertyManager getSearchConfigurationPropertyManager()
          Gets the property manager for the search config repository assets.
 java.util.TimeZone getTimeZone()
          Returns time zone for the property weighting date conversion
 javax.xml.transform.Transformer getTransformer()
          Gets the XML Transformer that will generate the XML stream from a DOM tree.
 boolean isDumpFiles()
          Returns true if this component should also write out all xml to the file system.
 void setApplicationName(java.lang.String pApplicationName)
          Set the String application name used to query the repository for the search config items to generate xml for.
 void setDateFormat(java.lang.String pDateFormat)
          Sets the String Format of dates used in date ranking properties.
 void setDefaultLanguage(java.lang.String pDefaultLanguage)
          Sets the default language attribute to use for the search config xml
 void setDefaultRankingMethod(java.lang.String pDefaultRankingMethod)
          Default ranking method name to use if the search config repository item rankingMethod property is null.
 void setDocumentBuilder(javax.xml.parsers.DocumentBuilder pDocumentBuilder)
          Sets the document builder that will be used to create DOM documents.
 void setDumpFiles(boolean pDumpFiles)
          Sets whether this component should also write out all xml to the file system.
 void setDumpPath(java.lang.String pDumpPath)
          Full String path name to the directory to use if dumpFiles is true.
 void setMerger(atg.repository.search.config.SearchConfigurationMerger pMerger)
          Sets the SearchConfigurationMerger to merge rules from the base search config item.
 void setOverrideRankingMethod(java.lang.String pOverrideRankingMethod)
          Defaults to null but if set then forces the xml generator to use this String for the ranking method and ignores any setting from the search config repository item.
 void setParser(atg.repository.search.config.SearchConfigurationRuleParser pParser)
          Sets the SearchConfigurationRuleParser to parse out the rules from a search config item.
 void setSearchConfigurationPropertyManager(SearchConfigurationPropertyManager pSearchConfigurationPropertyManager)
          Sets the property manager for the search config repository assets.
 void setTimeZone(java.util.TimeZone pTimeZone)
          Sets time zone for the property weighting date conversion
 void setTransformer(javax.xml.transform.Transformer pTransformer)
          Sets the XML Transformer that will generate the XML stream from a DOM tree.
protected  void transformToXML(org.w3c.dom.Document pDocument, java.io.OutputStream pOut)
          Transform a DOM Document object to an XML output stream.
protected  void transformToXML(org.w3c.dom.Document pDocument, javax.xml.transform.stream.StreamResult pResult)
          Transform a DOM Document object to an XML output stream.
protected  void transformToXML(org.w3c.dom.Document pDocument, java.io.Writer pWriter)
          Transform a DOM Document object to an XML output stream.
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, 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

Constructor Detail

SearchConfigurationXMLGenerator

public SearchConfigurationXMLGenerator()
Method Detail

getApplicationName

public java.lang.String getApplicationName()
Get the String application name used to query the repository for the search config items to generate xml for.

Returns:
String application name, e.g. 'merchandising'

setApplicationName

public void setApplicationName(java.lang.String pApplicationName)
Set the String application name used to query the repository for the search config items to generate xml for.

Parameters:
pApplicationName - String application name, e.g. 'merchandising'

getDefaultLanguage

public java.lang.String getDefaultLanguage()
Gets the default language attribute to use for the search config xml

Returns:
String default language, defaults to "en"

setDefaultLanguage

public void setDefaultLanguage(java.lang.String pDefaultLanguage)
Sets the default language attribute to use for the search config xml

Parameters:
pDefaultLanguage - String default language

getSearchConfigurationPropertyManager

public SearchConfigurationPropertyManager getSearchConfigurationPropertyManager()
Gets the property manager for the search config repository assets.

Returns:
SearchConfigurationPropertyManager to use

setSearchConfigurationPropertyManager

public void setSearchConfigurationPropertyManager(SearchConfigurationPropertyManager pSearchConfigurationPropertyManager)
Sets the property manager for the search config repository assets.

Parameters:
pSearchConfigurationPropertyManager - SearchConfigurationPropertyManager to use

getParser

public atg.repository.search.config.SearchConfigurationRuleParser getParser()
Gets the SearchConfigurationRuleParser to parse out the rules from a search config item.

Returns:
SearchConfigurationRuleParser to use

setParser

public void setParser(atg.repository.search.config.SearchConfigurationRuleParser pParser)
Sets the SearchConfigurationRuleParser to parse out the rules from a search config item.

Parameters:
pParser - SearchConfigurationRuleParser to use

getMerger

public atg.repository.search.config.SearchConfigurationMerger getMerger()
Gets the SearchConfigurationMerger to merge rules from the base search config item.

Returns:
SearchConfigurationMerger to use.

setMerger

public void setMerger(atg.repository.search.config.SearchConfigurationMerger pMerger)
Sets the SearchConfigurationMerger to merge rules from the base search config item.

Parameters:
pMerger - SearchConfigurationMerger to use.

isDumpFiles

public boolean isDumpFiles()
Returns true if this component should also write out all xml to the file system. Defaults to false.

Returns:
true if this component should also write out all xml to the file system.

setDumpFiles

public void setDumpFiles(boolean pDumpFiles)
Sets whether this component should also write out all xml to the file system.

Parameters:
pDumpFiles - boolean, if true this component will also write out all xml to the file system.

getDumpPath

public java.lang.String getDumpPath()
Full String path name to the directory to use if dumpFiles is true. You must include the final slash directory separator, e.g. "C:\work\logs\"

Returns:
pDumpPath String path name to the directory to use if dumpFiles is true

setDumpPath

public void setDumpPath(java.lang.String pDumpPath)
Full String path name to the directory to use if dumpFiles is true. You must include the final slash directory separator, e.g. "C:\work\logs\"

Parameters:
pDumpPath - String path name to the directory to use if dumpFiles is true

getDateFormat

public java.lang.String getDateFormat()
Gets the String Format of dates used in date ranking properties. Defaults to "MM/dd/yyyy".

Returns:
String Format of dates used in date ranking properties.

setDateFormat

public void setDateFormat(java.lang.String pDateFormat)
Sets the String Format of dates used in date ranking properties.

Parameters:
pDateFormat - String Format of dates used in date ranking properties.

getTimeZone

public java.util.TimeZone getTimeZone()
Returns time zone for the property weighting date conversion

Returns:
time zone for the property weighting date conversion

setTimeZone

public void setTimeZone(java.util.TimeZone pTimeZone)
Sets time zone for the property weighting date conversion

Parameters:
pTimeZone - time zone for the property weighting date conversion

setOverrideRankingMethod

public void setOverrideRankingMethod(java.lang.String pOverrideRankingMethod)
Defaults to null but if set then forces the xml generator to use this String for the ranking method and ignores any setting from the search config repository item.

Parameters:
pOverrideRankingMethod - String to set rankingMethod to

getOverrideRankingMethod

public java.lang.String getOverrideRankingMethod()
Defaults to null but if set then forces the xml generator to use this String for the ranking method and ignores any setting from the search config repository item.

Returns:
String to set rankingMethod to

setDefaultRankingMethod

public void setDefaultRankingMethod(java.lang.String pDefaultRankingMethod)
Default ranking method name to use if the search config repository item rankingMethod property is null. Defaults to 'compute' However it can be overriden by the overrideRankingMethod property of this component.

Parameters:
pDefaultRankingMethod - String default ranking method to use, defaults to 'compute'

getDefaultRankingMethod

public java.lang.String getDefaultRankingMethod()
Default ranking method name to use if the search config repository item rankingMethod property is null. Defaults to 'compute' However it can be overriden by the overrideRankingMethod property of this component.

Returns:
pDefaultRankingMethod String default ranking method to use, defaults to 'compute'

getTransformer

public javax.xml.transform.Transformer getTransformer()
Gets the XML Transformer that will generate the XML stream from a DOM tree. If no transformer is set, this method will provide a default.

Returns:
XML transformer

setTransformer

public void setTransformer(javax.xml.transform.Transformer pTransformer)
Sets the XML Transformer that will generate the XML stream from a DOM tree.

Parameters:
pTransformer - XML Transformer

setDocumentBuilder

public void setDocumentBuilder(javax.xml.parsers.DocumentBuilder pDocumentBuilder)
Sets the document builder that will be used to create DOM documents.

Parameters:
pDocumentBuilder - DOM document builder

getDocumentBuilder

public javax.xml.parsers.DocumentBuilder getDocumentBuilder()
Returns:
document builder. If needed, one is created.

createDocument

protected org.w3c.dom.Document createDocument()
Returns:
Created new DOM document, using the document builder.

addTextElement

protected void addTextElement(java.lang.String pText,
                              java.lang.String pTagName,
                              org.w3c.dom.Element pParent,
                              org.w3c.dom.Document pDocument)
Creates element with the text node inside

Parameters:
pText - text for the node
pTagName - tag's name
pParent - parent DOM element
pDocument - DOM document

createPatternElement

protected void createPatternElement(atg.repository.search.config.SearchRulePattern pPattern,
                                    org.w3c.dom.Element pRule,
                                    org.w3c.dom.Document pDocument)
Creates pattern element

Parameters:
pPattern - SearchRulePattern
pRule - parent element
pDocument - DOM document

createConditionElement

protected void createConditionElement(java.util.Stack pCondition,
                                      org.w3c.dom.Element pParent,
                                      org.w3c.dom.Document pDocument)
Creates sub-elements of <expression> element. Recursively calls itself for operators

Parameters:
pCondition - condition stack, one element popped each call
pParent - parent element
pDocument - DOM document

createRuleElement

protected void createRuleElement(atg.repository.search.config.SearchRule pRule,
                                 org.w3c.dom.Element pRules,
                                 org.w3c.dom.Document pDocument)
Creates rule element

Parameters:
pRule - SearchRule
pRules - parent element
pDocument - DOM document

createSynsetElement

protected void createSynsetElement(RepositoryItem pSynset,
                                   org.w3c.dom.Element pTerms,
                                   org.w3c.dom.Document pDocument)
Creates synset element

Parameters:
pSynset - synset repository item
pTerms - parent element
pDocument - DOM document

createTermElement

protected void createTermElement(java.lang.String pReciprocal,
                                 java.lang.String pTerm,
                                 org.w3c.dom.Element pSynset,
                                 org.w3c.dom.Document pDocument)
creates pTerm element

Parameters:
pReciprocal - "true" for reciprocal synset
pTerm - term
pSynset - parent element
pDocument - DOM document

transformToXML

protected void transformToXML(org.w3c.dom.Document pDocument,
                              javax.xml.transform.stream.StreamResult pResult)
Transform a DOM Document object to an XML output stream.

Parameters:
pDocument - DOM document to transform
pResult - stream result

transformToXML

protected void transformToXML(org.w3c.dom.Document pDocument,
                              java.io.OutputStream pOut)
Transform a DOM Document object to an XML output stream.

Parameters:
pDocument - DOM document to transform
pOut - output stream

transformToXML

protected void transformToXML(org.w3c.dom.Document pDocument,
                              java.io.Writer pWriter)
Transform a DOM Document object to an XML output stream.

Parameters:
pDocument - DOM document to transform
pWriter - output writer

getLanguageFromLocale

protected java.lang.String getLanguageFromLocale(java.lang.String pLocale)
Returns Search Engine language by locale string

Parameters:
pLocale - locale string
Returns:
Search Engine language string

generateSearchConfigDoc

public org.w3c.dom.Document generateSearchConfigDoc(RepositoryItem pCurrentSearchConfig,
                                                    RepositoryItem pBaseSearchConfig,
                                                    java.lang.String pRankConfigName)
Generates search config XML into the DOM document

Parameters:
pCurrentSearchConfig - search config for the current visitor
pBaseSearchConfig - base search config for the visitor's locale
pRankConfigName - Name to use for this generated rank config xml or null to use the id of the search config
Returns:
DOM document

generateSearchConfigXML

public void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig,
                                    RepositoryItem pBaseSearchConfig,
                                    java.io.OutputStream pOut)
Generates search config XML into a DOM document and writes it out

Parameters:
pCurrentSearchConfig - search config for the current visitor
pBaseSearchConfig - base search config for the visitor's locale
pOut - OutputStream to write to

generateSearchConfigXML

public void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig,
                                    RepositoryItem pBaseSearchConfig,
                                    java.io.OutputStream pOut,
                                    java.lang.String pRankConfigName)
Generates search config XML into a DOM document and writes it out

Parameters:
pCurrentSearchConfig - search config for the current visitor
pBaseSearchConfig - base search config for the visitor's locale
pOut - OutputStream to write to
pRankConfigName - Name to use for this generated rank config xml or null to use the id of the search config

generateSearchConfigXML

public void generateSearchConfigXML(RepositoryItem pCurrentSearchConfig,
                                    RepositoryItem pBaseSearchConfig,
                                    java.io.Writer pWriter)
Generates search config XML into a DOM document and writes it out

Parameters:
pCurrentSearchConfig - search config for the current visitor
pBaseSearchConfig - base search config for the visitor's locale
pWriter - Writer to write to

dump

public void dump(org.w3c.dom.Document doc)
Diagnostic method to write out generated xml to the file system.

Parameters:
doc - XML Document to write out.