com.raritantechnologies.verity
Interface IQueryCooker

All Known Implementing Classes:
ConcatenatingQueryCooker, OrFieldsQueryCooker, QueryCooker, RulesQueryCooker, SelectingQueryCooker, SimpleQueryCooker, SimpleThesaurusCooker, TopicHilighter

public interface IQueryCooker

Base Verity QueryCooker interface.

Each QueryCooker implementation must convert a set of form parameters contained in an com.raritantechnologies.utils.OrderedMap into a VQL string. The ConfigurationManager ensures that the QueryCooker is correctly matched to an input form.

The OrderedMap that is passed to the IQueryCooker methods can be derived from the web form ServletRequest. It contains a map of String keys to String array (String[]) values as described in the ServletRequest.getParameterMap( ) javadoc page.

The QueryCooker is owned by an IQueryProcessor, currently either a VerityQueryProcessor or a ParametricQueryProcessor. The QueryCooker is instantiated by the SearchSource's ISearchSourceFactory. For the VerityQueryProcessor, the XML Configuration looks like this:

  <SourceType name="VeritySource" type="Verity_XML"
            sourceFactoryClass="com.raritantechnologies.verity.VeritySearchSourceFactory" 
            queryProcessor="com.raritantechnologies.verity.VerityQueryProcessor" >

  <QueryCooker class="[queryCooker class]" >
     <!-- parameters needed by QueryCooker -->
  </QueryCooker>

  ... see VeritySearchSourceFactory for more details on VeritySearchSource configurations
  </SourceType>
 

For Parametric Apps, the SourceType tag has a different internal schema but has the same syntax for inserting a QueryCooker:

  <SourceType name="ParametricSource" type="ParametricQueryProcessor"
            sourceFactoryClass="com.raritantechnologies.verity.parametric.ParametricSearchSourceFactory" 
            queryProcessor="com.raritantechnologies.verity.parametric.ParametricQueryProcessor" >

    <QueryCooker class="[queryCooker class]" >
       <!-- parameters needed by QueryCooker -->
    </QueryCooker>

    <PIConfig 
      . . . PI configuration details, etc...
  </SourceType>
 

ParametricSearchSourceFactory is a subclass of the VeritySearchSourceFactory. In both cases, the Factory creation method:

   public SearchSource[] createSearchSources( Element sourceElem, XMLSearchFieldMapFactory factory );
 
contains a call to the initQueryCooker method, which looks for a "QueryCooker" tag
  protected void initQueryCooker( VeritySearchSource vss, Element searchSourceElem )
  {
      NodeList cookerLst = searchSourceElem.getElementsByTagName( "QueryCooker" );
      if (cookerLst != null && cookerLst.getLength() > 0)
      {
          Element cookerEl = (Element)cookerLst.item(0);
          vss.setQueryCookerElement( cookerEl );
      }
  }
 
When a search is executed, the VeritySearchSource or ParametricSearchSource (as all SearchSources do) provide an instance of an IQueryProcessor through the method:
    public IQueryProcessor getQueryProcessor(  );
  
It is at this point that the QueryCooker is inserted into the query processor by the SearchSource. For, example the VeritySearchSource implementation of getQueryProcessor looks like this:
  public IQueryProcessor getQueryProcessor(  )
  {
      IQueryCooker queryCooker = getQueryCooker( );

      if (queryCooker != null)
      {
          return new VerityQueryProcessor( queryCooker );
      }

      return new VerityQueryProcessor( new QueryCooker( ) );
  }
  

This means that if a <QueryCooker> tag is added to the Application Configuration XML, it will be used to translate parameterized queries into VQL by the VerityQueryProcessor and ParametricQueryProcessor code.


Developed by Raritan Technologies .

Author:
Ted Sullivan, Glenn Robitaille

Method Summary
 java.lang.String getHighlightQuery(java.lang.String[] searchSources, OrderedMap queryParams, ISearchFieldMap searchMap, ILoginInfo userInfo)
          returns a query suitable for use with Verity highlighting processes.
 java.lang.String getSourceQuery(java.lang.String[] searchSources, OrderedMap queryParams, ISearchFieldMap searchMap, ILoginInfo userInfo)
          returns a Verity Query Language (VQL) Source Query.
 java.lang.String getVerityQuery(java.lang.String[] searchSources, OrderedMap queryParams, ISearchFieldMap searchMap, ILoginInfo userInfo)
          returns a Verity Query Language (VQL) string for the form parameters submitted in queryParams.
 void initialize(org.w3c.dom.Element elem)
           
 

Method Detail

getVerityQuery

public java.lang.String getVerityQuery(java.lang.String[] searchSources,
                                       OrderedMap queryParams,
                                       ISearchFieldMap searchMap,
                                       ILoginInfo userInfo)
returns a Verity Query Language (VQL) string for the form parameters submitted in queryParams. The Search sources are needed to map the input params to the verity collection fields. This mapping can be different for different search sources.


getSourceQuery

public java.lang.String getSourceQuery(java.lang.String[] searchSources,
                                       OrderedMap queryParams,
                                       ISearchFieldMap searchMap,
                                       ILoginInfo userInfo)
returns a Verity Query Language (VQL) Source Query.


getHighlightQuery

public java.lang.String getHighlightQuery(java.lang.String[] searchSources,
                                          OrderedMap queryParams,
                                          ISearchFieldMap searchMap,
                                          ILoginInfo userInfo)
returns a query suitable for use with Verity highlighting processes.


initialize

public void initialize(org.w3c.dom.Element elem)