com.raritantechnologies.rql.map
Class RQLMapQueryParser

java.lang.Object
  extended bycom.raritantechnologies.rql.map.RQLMapQueryParser
All Implemented Interfaces:
IConfigurable, IQueryParser

public class RQLMapQueryParser
extends java.lang.Object
implements IQueryParser

Converts an RTI RQLMap format to a format that can be executed by a Search Source. The RQLMapQueryParser uses an RQLMapTopicBuilder to convert the RQLMap into a TopicSet which is then translated to a query string by an ITopicRenderer.

An RQLMap is an ordered set of name=value pairs that expresses an advanced query using prefix notation:

  Example:      (Title contains 'Java' OR Author contains 'Eckel) 
            AND ( Publish_Date > 9/1/1990 AND Publish_Date < 12/31/1999)
    _NAME_1     = 'Optional topic name'
    _BOOL_OP_1  = AND         // BOOL_OP operate across fields
    _BOOL_OP_2  = OR          // Possible values are AND, OR, NOT, NEAR/n/Ordered, PHRASE, RANGE
    _FIELD_1    = Title
    _VALUE_1    = Java
    _FIELD_2    = Author
    _VALUE_2    = Eckel
    _END_OP_2   = BOOL_OP_2
    _BOOL_OP_3  = RANGE
    _FIELD_OP_1 = GT     	// possible values are LT, LTE, GT, GTE, EQ, ANY, ALL, NOT
    _FIELD_3    = Publish_Date
    _VALUE_3    = 9/1/1990
    _FIELD_OP_2 = LT
    _FIELD_4    = Publish_Date
    _VALUE_4    = 12/31/1999
    _END_OP_3   = BOOL_OP_3
    _END_OP_1   = BOOL_OP_1

 

Default behavior: find all "_FIELD_[x] and matching _VALUE_[x] and collapse to single fields.

XML Configuration Template:
  <QueryParser class="com.raritantechnologies.rql.map.RQLMapQueryParser"
                  outputField="[ field that gets parsed RQL map ]" >

    <TopicRenderer class="[ class of com.raritantechnologies.rql.topic.ITopicRenderer ]" >

    </TopicRenderer>

  </QueryParser>
 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Constructor Summary
RQLMapQueryParser()
           
RQLMapQueryParser(java.lang.String topicField, ITopicRenderer topicRenderer)
           
 
Method Summary
 java.lang.String createQuery(OrderedMap params, java.lang.String language, ILoginInfo userInfo)
           
 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 params, ILoginInfo userInfo)
           
 OrderedMap parse(OrderedMap params, 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.
 void setTopicRenderer(ITopicRenderer topicRenderer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RQLMapQueryParser

public RQLMapQueryParser()

RQLMapQueryParser

public RQLMapQueryParser(java.lang.String topicField,
                         ITopicRenderer topicRenderer)
Method Detail

parse

public OrderedMap parse(OrderedMap params,
                        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:
params - An ordered map containing the query parameters
language - String representing the target language (e.g. VQL)
Throws:
QueryParseException
UnsupportedLanguageException

parse

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

setLanguage

public void setLanguage(java.lang.String language)
Specified by:
setLanguage 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

getErrors

public java.util.List getErrors()
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)
Allows QueryParser object to access the sessionData.

Specified by:
setSessionID in interface IQueryParser

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

setTopicRenderer

public void setTopicRenderer(ITopicRenderer topicRenderer)