com.raritantechnologies.searchApp.queryFilters
Class QueryMapFilter

java.lang.Object
  extended bycom.raritantechnologies.searchApp.QueryProcessorFilter
      extended bycom.raritantechnologies.searchApp.queryFilters.QueryMapFilter
All Implemented Interfaces:
IConfigurable, IQueryParser, IQueryProcessor

public class QueryMapFilter
extends QueryProcessorFilter
implements IQueryParser

QueryProcessorFilter that enables a query parameter map to be filtered prior to query execution or to modify result fields after the query is executed.

Includes operations that can change the name and/or value of a query parameter.

Can merge query fields by using the value of one input field as a name and the value of another as a value. This is useful in advanced search forms where the user selects both the field to search and its value.

Can include a IStringFilter to alter the value of a query parameter prior to query execution.

Also enables a set of fixed parameters to be added to the query map prior to execution. Useful for scoping or narrowing a query for certain SearchSource types.

Can use an IMapFilter to perform manipulations on the query parameter map prior to execution. This filter can be useful for putting query parameters into a set order - for example to produce an advanced boolean query.

XML Configuration Template:
 <SourceType name="[ name of QueryMapFilter source]"
           type="QueryProcessorFilterSource"
           sourceFactoryClass = "com.raritantechnologies.searchApp.QueryProcessorFilterFactory"
           filterClass  = "com.raritantechnologies.searchApp.queryFilters.QueryMapFilter"
           inputSource  = "[ name of SearchSource that the mapped query is passed to]"  >

   <!-- Field name Map: changes name of input field -->
   <InputNameMap>
     <Param ID="fieldID" />
     <Param ID="fieldID" mapTo="[name in output search map]" />

     <!-- Use this format to unpack a packed input parameter such as "field1=value1|field2=value2" -->
     <Param ID="fieldID" fieldDelimiter="[ delimiter for packed field ]" valueDelimiter="[ separator for field/value ]" />

     <!-- UseMapTo tags are used to switch mapping paths based on properties of the input parameter set -->
     <Param ID="[ input parameter ID ]" mapTo="[ (optional) default mapping ]">

       <!-- One or more UseMapTo Tags -->
       <UseMapTo mapTo="[ alternate output name or 'NULL' to remove the parameter from the query ]"
                    isAnd="[ true(default) | false ]" >

         <!-- One or more ValidParam Tags... -->
         <ValidParam ID="param ID" value="[ value in input map or 'NULL' or 'NOT_NULL' ]" />

         <!-- Alternatively, can use an IComparator to check the value of the input parameter before mapping -->
         <ValidParam ID="[ param ID in input map ]" >
           <Comparator class="[ class of com.raritantechnologies.utils.comparators.IComparator ]" >

           </Comparator>
         </ValidParam>
       </UseMapTo>

       <!-- Can also use an IResultMatcher to match on the entire input query at once -->
       <UseMapTo mapTo="[ alternate output name or 'NULL' to remove the parameter from the query ]" >
         <ResultMatcher class="[ class of com.raritantechnologies.searchApp.IResultMatcher ]" >

         </ResultMatcher>
       </UseMapTo>
     </Param>

     <-- uses one field value as search field name, another field value as the search value -->
     <Param nameField="[query field with name]" valueField="field with value" >
        <!-- Optional string filter that can be applied to query field's value -->
        <StringFilter class="string filter class" >
        </StringFilter>
      </Param>

   </InputNameMap>

   <!-- Adds fixed parameters to query map -->
   <FixedParams>
       <Param ID="[new query field]" value="[its value]" />
       <Param ID="[another field]"  value="[its value]" />
   </FixedParams>

   <!-- User Params enables user login information to be used create user-specific queries -->
   <!-- User parameters can be standard parameters such as NAME, PASSWORD, ALTNAME:[alternate login name ], -->
   <!-- ALTPASS:[alternate login password] or an extension attribute -->
   <UserParams>
      <Param ID="[ User info attribute e.g. Name]" mapTo="[name in output search map]" />

      <!-- Optional string filter that can be applied to the user profile value -->
      <Param ID="[ user info Attribute
   </UserParams>

   <!-- MapFilter pluggin can make arbitrary changes to the query map -->
   <MapFilter class="[ class of com.raritantechnologies.utils.filter.IMapFilter ]" >
      <!-- configuration parameters for map filter -->
   </MapFilter>

   <!-- Result Name map: changes name of output fields in results -->
   <ResultNameMap>
     <Param ID="inputID" mapTo="outputID"
   </ResultNameMap>

 </SourceType>
 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Field Summary
 
Fields inherited from class com.raritantechnologies.searchApp.QueryProcessorFilter
theQueryProcessor
 
Constructor Summary
QueryMapFilter()
           
 
Method Summary
 java.lang.String createQuery(OrderedMap params, java.lang.String language, ILoginInfo userInfo)
           
 IResultSet executeQuery(java.lang.Integer queryID, ISearchFieldMap searchMap, SourceLoginInfo[] sources, OrderedMap inputParameters, java.lang.Integer pageSize, java.lang.Integer startRec)
          Base implementation executes the query then starts filter chain.
 void filterResultSet(ILoginInfo loginInfo, IResultSet resultSet)
          Subclasses should override this to do meaningful work.
 java.util.List getErrors()
          Returns the errors that occurred during the translate() step.
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
 OrderedMap parse(OrderedMap inputParameters, ILoginInfo userInfo)
           
 OrderedMap parse(OrderedMap inputParameters, java.lang.String language, ILoginInfo userInfo)
          Translate using the input parameters if this is how the query is passed.
 void setLanguage(java.lang.String language)
           
 void setSessionID(java.lang.String id)
          Allows QueryParser object to access the sessionData.
 
Methods inherited from class com.raritantechnologies.searchApp.QueryProcessorFilter
doExecuteQuery, getQueryProcessor, getQueryProcessor, getRealSources, setNextFilter, setQueryProcessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryMapFilter

public QueryMapFilter()
Method Detail

executeQuery

public IResultSet executeQuery(java.lang.Integer queryID,
                               ISearchFieldMap searchMap,
                               SourceLoginInfo[] sources,
                               OrderedMap inputParameters,
                               java.lang.Integer pageSize,
                               java.lang.Integer startRec)
                        throws QueryProcessorException
Description copied from class: QueryProcessorFilter
Base implementation executes the query then starts filter chain.

Specified by:
executeQuery in interface IQueryProcessor
Overrides:
executeQuery in class QueryProcessorFilter
Throws:
QueryProcessorException

parse

public OrderedMap parse(OrderedMap inputParameters,
                        ILoginInfo userInfo)
Specified by:
parse in interface IQueryParser

parse

public OrderedMap parse(OrderedMap inputParameters,
                        java.lang.String language,
                        ILoginInfo userInfo)
                 throws QueryParseException,
                        UnsupportedLanguageException
Description copied from interface: IQueryParser
Translate using the input parameters if this is how the query is passed.

Specified by:
parse in interface IQueryParser
Parameters:
inputParameters - An ordered map containing the query parameters
language - String representing the target language (e.g. VQL)
Throws:
QueryParseException
UnsupportedLanguageException

setLanguage

public void setLanguage(java.lang.String language)
Specified by:
setLanguage in interface IQueryParser

getErrors

public java.util.List getErrors()
Description copied from interface: IQueryParser
Returns the errors that occurred during the translate() step.

Specified by:
getErrors in interface IQueryParser
Returns:
the list of error(s) (if any) that occurred.

setSessionID

public void setSessionID(java.lang.String id)
Description copied from interface: IQueryParser
Allows QueryParser object to access the sessionData.

Specified by:
setSessionID in interface IQueryParser

createQuery

public java.lang.String createQuery(OrderedMap params,
                                    java.lang.String language,
                                    ILoginInfo userInfo)
                             throws QueryParseException,
                                    UnsupportedLanguageException
Specified by:
createQuery in interface IQueryParser
Throws:
QueryParseException
UnsupportedLanguageException

filterResultSet

public void filterResultSet(ILoginInfo loginInfo,
                            IResultSet resultSet)
Description copied from class: QueryProcessorFilter
Subclasses should override this to do meaningful work. call super.filterResultSet( ) to do chaining.

Overrides:
filterResultSet in class QueryProcessorFilter

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IQueryParser
Overrides:
initialize in class QueryProcessorFilter