Changeset 9266


Ignore:
Timestamp:
2005-03-03T16:25:02+13:00 (19 years ago)
Author:
kjdon
Message:

added a does chunking flag - whether or not the service provides maxdocs to return. put default implementations for some of the abstract methods, so new classes don't need to implement them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java

    r9002 r9266  
    4646    // compulsory params
    4747    protected static final String INDEX_PARAM = "index";
     48    protected static final String QUERY_PARAM = "query";
     49
     50    // optional standard params - some of these have to be implemented
    4851    protected static final String MAXDOCS_PARAM = "maxDocs";
    49     protected static final String QUERY_PARAM = "query";
    50 
    51     // optional standard params
    5252    protected static final String HITS_PER_PAGE_PARAM = "hitsPerPage";
    5353    protected static final String START_PAGE_PARAM = "startPage";
     
    6464
    6565    protected boolean does_paging = false;
     66    protected boolean does_chunking = true;
    6667    protected String default_document_type = null;
    6768
     
    7071    }
    7172
     73    /** sets up the short service info for TextQuery. If other services
     74     * will be provided, should be added in the subclass configure
     75     * also looks for search format info, and document format info
     76     */
    7277    public boolean configure(Element info, Element extra_info)
    7378    {
     
    122127    }
    123128   
     129    /** returns the description of the TextQuery service. If a subclass
     130     * provides other services they need to provides their own descriptions */
    124131    protected Element getServiceDescription(String service, String lang, String subset)
    125132    {
     
    146153    }
    147154   
    148     abstract protected Element processTextQuery(Element request);
    149    
    150    
     155    /** adds the standard query params into the service description */
    151156    protected void addStandardQueryParams(Element param_list, String lang)
    152157    {
    153158    createParameter(INDEX_PARAM, param_list, lang);
    154     createParameter(MAXDOCS_PARAM, param_list, lang);
     159    if (does_chunking) {
     160        createParameter(MAXDOCS_PARAM, param_list, lang);
     161    }
    155162    if (does_paging) {
    156163        createParameter(HITS_PER_PAGE_PARAM, param_list, lang);
     
    160167    }
    161168
    162    
     169    /** adds any service specific query params into the service
     170     *  default implementation: add nothing. subclasses may need to
     171     * override this to add in their specific parameters
     172     */
    163173    protected void addCustomQueryParams(Element param_list, String lang)
    164174    {
     
    253263    }
    254264
    255     abstract protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang);
    256265
    257266    /** returns the document type of the doc that the specified node
     
    260269    GSXML.DOC_TYPE_PAGED,
    261270    GSXML.DOC_TYPE_HIERARCHY
     271    default implementation returns GSXML.DOC_TYPE_SIMPLE, over ride
     272    if documents can be hierarchical
    262273    */
    263     abstract protected String getDocType(String node_id);
     274    protected String getDocType(String node_id) {
     275    return GSXML.DOC_TYPE_SIMPLE;
     276    }
    264277   
    265     /** returns true if the node has child nodes */
    266     abstract protected boolean hasChildren(String node_id);
    267     /** returns true if the node has a parent */
    268     abstract protected boolean hasParent(String node_id);
    269 
    270  }
    271 
     278    /** returns true if the node has child nodes
     279     * default implementation returns false, over ride if documents can be
     280     * hierarchical
     281     */
     282    protected boolean hasChildren(String node_id) {
     283    return false;
     284    }
     285    /** returns true if the node has a parent
     286     * default implementation returns false, over ride if documents can be
     287     * hierarchical*/
     288    protected boolean hasParent(String node_id) {
     289    return false;
     290    }
     291
     292    /** do the actual query
     293     * must be implemented by subclass */
     294    abstract protected Element processTextQuery(Element request);
     295   
     296    /** get the details about the indexes available
     297     * must be implemented by subclass
     298     * there must be at least one index */
     299    abstract protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang);
     300
     301}
     302
Note: See TracChangeset for help on using the changeset viewer.