Changeset 24858


Ignore:
Timestamp:
2011-12-06T11:48:16+13:00 (12 years ago)
Author:
sjm84
Message:

Reformatting this file ahead of some changes

File:
1 edited

Legend:

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

    r24394 r24858  
    2727// XML classes
    2828import org.w3c.dom.Document;
    29 import org.w3c.dom.Element; 
     29import org.w3c.dom.Element;
    3030import org.w3c.dom.NodeList;
    3131
     
    3636import org.apache.log4j.*;
    3737
    38 /** Partially implements a generic search service
    39  *
     38/**
     39 * Partially implements a generic search service
     40 *
    4041 * @author <a href="mailto:[email protected]">Katherine Don</a>
    4142 */
    4243
    43 public abstract class AbstractSearch
    44     extends ServiceRack
     44public abstract class AbstractSearch extends ServiceRack
    4545{
    4646
    47     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.AbstractSearch.class.getName());
    48 
    49     // the search service
    50     protected String QUERY_SERVICE = null; // set by subclass
    51    
    52     // compulsory params
    53     protected static final String INDEX_PARAM = "index";
    54     protected static final String QUERY_PARAM = "query";
    55 
    56     // optional standard params - some of these have to be implemented
    57     protected static final String MAXDOCS_PARAM = "maxDocs";
    58     protected static final String HITS_PER_PAGE_PARAM = "hitsPerPage";
    59     protected static final String START_PAGE_PARAM = "startPage";
    60 
    61     protected AbstractSimpleDocument gs_doc = null;
    62 
    63     /** can more than one index be searched at the same time? */
    64     protected boolean does_multi_index_search = false;
    65     /** does this service support paging of results? */
    66     protected boolean does_paging = false;
    67     /** does this service support asking for a subset of results? */
    68     protected boolean does_chunking = false;
    69     /** the default document type - use if all documents are the same type
    70      */
    71     protected String default_document_type = null;
    72     /** the default index, or comma separated list if more than one is
    73      * the default (with start and end commas, eg ,TI,SU,).
    74      * Should be set by configure()
    75      */
    76     protected String default_index = "";
    77 
    78     protected String default_max_docs = "100";
    79    
    80     protected String default_hits_per_page = "10";
    81  
    82     public AbstractSearch()
    83     {
    84     }
    85 
    86     /** Sets up the short service info for service by QUERY_SERVICE
    87      *    (e.g. TextQuery or AudioQuery)
    88      *  If other services will be provided, should be added in the
    89      *  subclass configure also looks for search format info, and
    90      *  document format info
    91      */
    92     public boolean configure(Element info, Element extra_info)
    93     {
    94     if (!super.configure(info, extra_info)){
    95         return false;
    96     }
    97 
    98     logger.info("Configuring AbstractSearch...");
    99    
    100     this.config_info = info;
    101 
    102     // set up short_service_info_
    103     // => for now just has id and type. the name (lang dependent)
    104     //    will be added in if the list is requested.
    105 
    106     Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM);
    107     tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
    108     tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
    109     this.short_service_info.appendChild(tq_service);
    110 
    111     // add some format info to service map if there is any
    112     // => lookin extra info first look in buildConfig
    113 
    114     Element format = (Element)GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM);
    115 
    116     if (format==null) {
    117         String path = GSPath.appendLink(GSXML.SEARCH_ELEM, GSXML.FORMAT_ELEM);
    118 
    119         // Note by xiao: instead of retrieving the first 'format'
    120         //   element inside the 'search' element, we are trying to
    121         //   find the real format element which has at least one
    122         //   'gsf:template' child element. (extra_info is
    123         //   collectionConfig.xml)
    124 
    125         //format = (Element) GSXML.getNodeByPath(extra_info, path);
    126      
    127         Element search_elem = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
    128         NodeList format_elems = null;
    129         if (search_elem != null) {
    130         format_elems = search_elem.getElementsByTagName(GSXML.FORMAT_ELEM);
    131         }
    132         for(int i=0; i<format_elems.getLength(); i++) {
    133         format = (Element)format_elems.item(i);
    134         if (format.getElementsByTagName("gsf:template").getLength() != 0) {
    135             break;
    136         }
    137         }
    138     }//end of if(format==null)
    139     //
    140     if (format != null) {
    141         this.format_info_map.put(QUERY_SERVICE, this.doc.importNode(format, true));
    142     }
    143    
    144     // look for document display format - for documentType
    145     String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM);
    146     Element display_format = (Element)GSXML.getNodeByPath(extra_info, path);
    147     if (display_format != null) {
    148         // check for docType option.
    149         Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType");
    150         if (doc_type_opt != null) {
    151         String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT);
    152         if (!value.equals("")) {
    153             this.default_document_type = value;
    154         }
    155         }
    156     }
    157 
    158     // Base line for document (might be overriden by sub-classes)
    159     gs_doc = new SimpleDocument(this.doc,this.default_document_type);
    160 
    161     return true;
    162     }
    163    
    164     /** returns a basic description for QUERY_SERVICE. If a subclass
    165      * provides other services they need to provide their own descriptions */
    166     protected Element getServiceDescription(String service, String lang, String subset)
    167     {
    168     if (!service.equals(QUERY_SERVICE)) {
    169         return null;
    170     }
    171 
    172     Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM);
    173     tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
    174     tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
    175     if (subset==null || subset.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) {
    176         tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(QUERY_SERVICE, lang) ));
    177         tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getServiceSubmit(QUERY_SERVICE, lang) ));
    178         tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(QUERY_SERVICE, lang)));
    179     }
    180     if (subset==null || subset.equals(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER)) {
    181         Element param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    182         addCustomQueryParams(param_list, lang);
    183         addStandardQueryParams(param_list, lang);
    184         tq_service.appendChild(param_list);
    185     }
    186     return tq_service;
    187    
    188     }
    189 
    190     // perhaps these should be changed to search down the class hierarchy for
    191     // values - do can just put the info in the resource bundle to use it
    192     /** returns the default name for the TextQuery service */
    193     protected String getServiceName(String service_id, String lang) {
    194     return getTextString(service_id+".name", lang);
    195     }
    196    
    197     /** returns the default description for the TextQuery service */
    198     protected String getServiceDescription(String service_id, String lang) {
    199     return getTextString(service_id+".description", lang);
    200     }
    201 
    202     /** returns the default submit button text for the TextQuery service */
    203     protected String getServiceSubmit(String service_id, String lang) {
    204     return getTextString(service_id+".submit", lang);
    205 
    206     }
    207     /** adds the standard query params into the service description */
    208     protected void addStandardQueryParams(Element param_list, String lang)
    209     {
    210       // this test is not so good. here we are using absence of default index
    211       // to determine whether we have indexes or not. But in other places,
    212       // absence of default index just means to use the first one as default.
    213     if (!default_index.equals("")){
    214         createParameter(INDEX_PARAM, param_list, lang);
    215     }
    216     if (does_chunking) {
    217         createParameter(MAXDOCS_PARAM, param_list, lang);
    218     }
    219     if (does_paging) {
    220         createParameter(HITS_PER_PAGE_PARAM, param_list, lang);
    221         createParameter(START_PAGE_PARAM, param_list, lang);
    222     }
    223     createParameter(QUERY_PARAM, param_list, lang);
    224     }
    225 
    226     /** adds any service specific query params into the service
    227      *  default implementation: add nothing. subclasses may need to
    228      * override this to add in their specific parameters
    229      */
    230     protected void addCustomQueryParams(Element param_list, String lang)
    231     {
    232     // default behaviour, do nothing
    233     }
    234    
    235     protected void createParameter(String name, Element param_list, String lang)
    236     {
    237     createParameter(name, param_list, lang, null);
    238     }
    239 
    240      protected void createParameter(String name, Element param_list, String lang, String default_value)
    241     {
    242     // at this level, not interested in boolean return type
    243     createParameterChain(name,param_list,lang,default_value);
    244     }
    245 
    246 
    247     /** default implementations for the standard parameters plus some
    248      * other common ones index, maxDocs, hitsPerPage, startPage
    249     */
    250 
    251      protected boolean createParameterChain(String name, Element param_list, String lang, String default_value)
    252     {
    253     Element param = null;
    254     String param_default = default_value;
    255 
    256     if (name.equals(QUERY_PARAM)) {
    257         param = GSXML.createParameterDescription(this.doc, QUERY_PARAM, getTextString("param."+QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, param_default, null, null);
    258         param_list.appendChild(param);
    259         return true;
    260     } else if (name.equals(INDEX_PARAM)) {
    261 
    262         // should we make these class fields?
    263         ArrayList index_ids = new ArrayList();
    264         ArrayList index_names = new ArrayList();
    265         getIndexData(index_ids, index_names, lang);
    266         String param_type = GSXML.PARAM_TYPE_ENUM_SINGLE;
    267         if (does_multi_index_search) {
    268         param_type = GSXML.PARAM_TYPE_ENUM_MULTI;
    269         }
    270         if (param_default == null) {
    271           param_default = this.default_index;
    272         }
    273         param = GSXML.createParameterDescription2(this.doc, INDEX_PARAM, getTextString("param."+INDEX_PARAM, lang), param_type, param_default, index_ids, index_names);
    274         param_list.appendChild(param);
    275         return true;
    276     }
    277         else if (name.equals(MAXDOCS_PARAM)) {
    278         if (param_default == null) {
    279         param_default = this.default_max_docs;
    280         }
    281      
    282         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null);
    283         param_list.appendChild(param);
    284         return true;
    285     }
    286     else if(name.equals(HITS_PER_PAGE_PARAM)){
    287         if (param_default == null) {
    288         param_default = this.default_hits_per_page;
    289         }
    290      
    291         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null);
    292         param_list.appendChild(param);
    293         return true;
    294     } else if (name.equals(START_PAGE_PARAM)) {
    295         if (param_default == null) {
    296         param_default = "1";
    297         }
    298        
    299         // start page - set to 1 for the search page
    300         param = GSXML.createParameterDescription(this.doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, param_default, null, null);
    301         param_list.appendChild(param);
    302         return true;
    303     }
    304 
    305     // Get to there then none of the above params matched
    306     // => return false so the chain can continue
    307     return false;
    308     }
    309 
    310 
    311     /** create an element to go into the search results list. A node element
    312      * has the form
    313      * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy' rank='0.23'/>
    314      */
    315     protected Element createDocNode(String node_id, String rank)
    316     {
    317     return this.gs_doc.createDocNode(node_id,rank);
    318     }
    319 
    320     /** returns the document type of the doc that the specified node
    321     belongs to. should be one of
    322     GSXML.DOC_TYPE_SIMPLE,
    323     GSXML.DOC_TYPE_PAGED,
    324     GSXML.DOC_TYPE_HIERARCHY
    325     */
    326     protected String getDocType(String node_id){
    327     return this.gs_doc.getDocType(node_id);
    328     }
    329 
    330     /** returns the node type of the specified node.
    331     should be one of
    332     GSXML.NODE_TYPE_LEAF,
    333     GSXML.NODE_TYPE_INTERNAL,
    334     GSXML.NODE_TYPE_ROOT
    335     */
    336     protected String getNodeType(String node_id, String doc_type)
    337     {
    338     return this.gs_doc.getNodeType(node_id,doc_type);
    339     }
    340    
    341     /** returns true if the node has child nodes */
    342     protected boolean hasChildren(String node_id)
    343     {
    344     return this.gs_doc.hasChildren(node_id);
    345     }
    346    
    347     /** returns true if the node has a parent */
    348     protected boolean hasParent(String node_id)
    349     {
    350     return this.gs_doc.hasParent(node_id);
    351     }
    352 
    353 
    354     /** get the details about the indexes available
    355      * must be implemented by subclass
    356      * there must be at least one index */
    357     abstract protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang);
     47    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.AbstractSearch.class.getName());
     48
     49    // the search service
     50    protected String QUERY_SERVICE = null; // set by subclass
     51
     52    // compulsory params
     53    protected static final String INDEX_PARAM = "index";
     54    protected static final String QUERY_PARAM = "query";
     55
     56    // optional standard params - some of these have to be implemented
     57    protected static final String MAXDOCS_PARAM = "maxDocs";
     58    protected static final String HITS_PER_PAGE_PARAM = "hitsPerPage";
     59    protected static final String START_PAGE_PARAM = "startPage";
     60
     61    protected AbstractSimpleDocument gs_doc = null;
     62
     63    /** can more than one index be searched at the same time? */
     64    protected boolean does_multi_index_search = false;
     65    /** does this service support paging of results? */
     66    protected boolean does_paging = false;
     67    /** does this service support asking for a subset of results? */
     68    protected boolean does_chunking = false;
     69    /**
     70     * the default document type - use if all documents are the same type
     71     */
     72    protected String default_document_type = null;
     73    /**
     74     * the default index, or comma separated list if more than one is the
     75     * default (with start and end commas, eg ,TI,SU,). Should be set by
     76     * configure()
     77     */
     78    protected String default_index = "";
     79
     80    protected String default_max_docs = "100";
     81
     82    protected String default_hits_per_page = "10";
     83
     84    public AbstractSearch()
     85    {
     86    }
     87
     88    /**
     89     * Sets up the short service info for service by QUERY_SERVICE (e.g.
     90     * TextQuery or AudioQuery) If other services will be provided, should be
     91     * added in the subclass configure also looks for search format info, and
     92     * document format info
     93     */
     94    public boolean configure(Element info, Element extra_info)
     95    {
     96        if (!super.configure(info, extra_info))
     97        {
     98            return false;
     99        }
     100
     101        logger.info("Configuring AbstractSearch...");
     102
     103        this.config_info = info;
     104
     105        // set up short_service_info_
     106        // => for now just has id and type. the name (lang dependent)
     107        //    will be added in if the list is requested.
     108
     109        Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM);
     110        tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
     111        tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
     112        this.short_service_info.appendChild(tq_service);
     113
     114        // add some format info to service map if there is any
     115        // => lookin extra info first look in buildConfig
     116
     117        Element format = (Element) GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM);
     118
     119        if (format == null)
     120        {
     121            String path = GSPath.appendLink(GSXML.SEARCH_ELEM, GSXML.FORMAT_ELEM);
     122
     123            // Note by xiao: instead of retrieving the first 'format'
     124            //   element inside the 'search' element, we are trying to
     125            //   find the real format element which has at least one
     126            //   'gsf:template' child element. (extra_info is
     127            //   collectionConfig.xml)
     128
     129            //format = (Element) GSXML.getNodeByPath(extra_info, path);
     130
     131            Element search_elem = (Element) GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
     132            NodeList format_elems = null;
     133            if (search_elem != null)
     134            {
     135                format_elems = search_elem.getElementsByTagName(GSXML.FORMAT_ELEM);
     136            }
     137            for (int i = 0; i < format_elems.getLength(); i++)
     138            {
     139                format = (Element) format_elems.item(i);
     140                if (format.getElementsByTagName("gsf:template").getLength() != 0)
     141                {
     142                    break;
     143                }
     144            }
     145        }//end of if(format==null)
     146            //
     147        if (format != null)
     148        {
     149            this.format_info_map.put(QUERY_SERVICE, this.doc.importNode(format, true));
     150        }
     151
     152        // look for document display format - for documentType
     153        String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM);
     154        Element display_format = (Element) GSXML.getNodeByPath(extra_info, path);
     155        if (display_format != null)
     156        {
     157            // check for docType option.
     158            Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType");
     159            if (doc_type_opt != null)
     160            {
     161                String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT);
     162                if (!value.equals(""))
     163                {
     164                    this.default_document_type = value;
     165                }
     166            }
     167        }
     168
     169        // Base line for document (might be overriden by sub-classes)
     170        gs_doc = new SimpleDocument(this.doc, this.default_document_type);
     171
     172        return true;
     173    }
     174
     175    /**
     176     * returns a basic description for QUERY_SERVICE. If a subclass provides
     177     * other services they need to provide their own descriptions
     178     */
     179    protected Element getServiceDescription(String service, String lang, String subset)
     180    {
     181        if (!service.equals(QUERY_SERVICE))
     182        {
     183            return null;
     184        }
     185
     186        Element tq_service = this.doc.createElement(GSXML.SERVICE_ELEM);
     187        tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
     188        tq_service.setAttribute(GSXML.NAME_ATT, QUERY_SERVICE);
     189        if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER))
     190        {
     191            tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(QUERY_SERVICE, lang)));
     192            tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getServiceSubmit(QUERY_SERVICE, lang)));
     193            tq_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(QUERY_SERVICE, lang)));
     194        }
     195        if (subset == null || subset.equals(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER))
     196        {
     197            Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     198            addCustomQueryParams(param_list, lang);
     199            addStandardQueryParams(param_list, lang);
     200            tq_service.appendChild(param_list);
     201        }
     202        return tq_service;
     203
     204    }
     205
     206    // perhaps these should be changed to search down the class hierarchy for
     207    // values - do can just put the info in the resource bundle to use it
     208    /** returns the default name for the TextQuery service */
     209    protected String getServiceName(String service_id, String lang)
     210    {
     211        return getTextString(service_id + ".name", lang);
     212    }
     213
     214    /** returns the default description for the TextQuery service */
     215    protected String getServiceDescription(String service_id, String lang)
     216    {
     217        return getTextString(service_id + ".description", lang);
     218    }
     219
     220    /** returns the default submit button text for the TextQuery service */
     221    protected String getServiceSubmit(String service_id, String lang)
     222    {
     223        return getTextString(service_id + ".submit", lang);
     224
     225    }
     226
     227    /** adds the standard query params into the service description */
     228    protected void addStandardQueryParams(Element param_list, String lang)
     229    {
     230        // this test is not so good. here we are using absence of default index
     231        // to determine whether we have indexes or not. But in other places,
     232        // absence of default index just means to use the first one as default.
     233        if (!default_index.equals(""))
     234        {
     235            createParameter(INDEX_PARAM, param_list, lang);
     236        }
     237        if (does_chunking)
     238        {
     239            createParameter(MAXDOCS_PARAM, param_list, lang);
     240        }
     241        if (does_paging)
     242        {
     243            createParameter(HITS_PER_PAGE_PARAM, param_list, lang);
     244            createParameter(START_PAGE_PARAM, param_list, lang);
     245        }
     246        createParameter(QUERY_PARAM, param_list, lang);
     247    }
     248
     249    /**
     250     * adds any service specific query params into the service default
     251     * implementation: add nothing. subclasses may need to override this to add
     252     * in their specific parameters
     253     */
     254    protected void addCustomQueryParams(Element param_list, String lang)
     255    {
     256        // default behaviour, do nothing
     257    }
     258
     259    protected void createParameter(String name, Element param_list, String lang)
     260    {
     261        createParameter(name, param_list, lang, null);
     262    }
     263
     264    protected void createParameter(String name, Element param_list, String lang, String default_value)
     265    {
     266        // at this level, not interested in boolean return type
     267        createParameterChain(name, param_list, lang, default_value);
     268    }
     269
     270    /**
     271     * default implementations for the standard parameters plus some other
     272     * common ones index, maxDocs, hitsPerPage, startPage
     273     */
     274
     275    protected boolean createParameterChain(String name, Element param_list, String lang, String default_value)
     276    {
     277        Element param = null;
     278        String param_default = default_value;
     279
     280        if (name.equals(QUERY_PARAM))
     281        {
     282            param = GSXML.createParameterDescription(this.doc, QUERY_PARAM, getTextString("param." + QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, param_default, null, null);
     283            param_list.appendChild(param);
     284            return true;
     285        }
     286        else if (name.equals(INDEX_PARAM))
     287        {
     288
     289            // should we make these class fields?
     290            ArrayList index_ids = new ArrayList();
     291            ArrayList index_names = new ArrayList();
     292            getIndexData(index_ids, index_names, lang);
     293            String param_type = GSXML.PARAM_TYPE_ENUM_SINGLE;
     294            if (does_multi_index_search)
     295            {
     296                param_type = GSXML.PARAM_TYPE_ENUM_MULTI;
     297            }
     298            if (param_default == null)
     299            {
     300                param_default = this.default_index;
     301            }
     302            param = GSXML.createParameterDescription2(this.doc, INDEX_PARAM, getTextString("param." + INDEX_PARAM, lang), param_type, param_default, index_ids, index_names);
     303            param_list.appendChild(param);
     304            return true;
     305        }
     306        else if (name.equals(MAXDOCS_PARAM))
     307        {
     308            if (param_default == null)
     309            {
     310                param_default = this.default_max_docs;
     311            }
     312
     313            param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null);
     314            param_list.appendChild(param);
     315            return true;
     316        }
     317        else if (name.equals(HITS_PER_PAGE_PARAM))
     318        {
     319            if (param_default == null)
     320            {
     321                param_default = this.default_hits_per_page;
     322            }
     323
     324            param = GSXML.createParameterDescription(this.doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null);
     325            param_list.appendChild(param);
     326            return true;
     327        }
     328        else if (name.equals(START_PAGE_PARAM))
     329        {
     330            if (param_default == null)
     331            {
     332                param_default = "1";
     333            }
     334
     335            // start page - set to 1 for the search page
     336            param = GSXML.createParameterDescription(this.doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, param_default, null, null);
     337            param_list.appendChild(param);
     338            return true;
     339        }
     340
     341        // Get to there then none of the above params matched
     342        // => return false so the chain can continue
     343        return false;
     344    }
     345
     346    /**
     347     * create an element to go into the search results list. A node element has
     348     * the form <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy'
     349     * rank='0.23'/>
     350     */
     351    protected Element createDocNode(String node_id, String rank)
     352    {
     353        return this.gs_doc.createDocNode(node_id, rank);
     354    }
     355
     356    /**
     357     * returns the document type of the doc that the specified node belongs to.
     358     * should be one of GSXML.DOC_TYPE_SIMPLE, GSXML.DOC_TYPE_PAGED,
     359     * GSXML.DOC_TYPE_HIERARCHY
     360     */
     361    protected String getDocType(String node_id)
     362    {
     363        return this.gs_doc.getDocType(node_id);
     364    }
     365
     366    /**
     367     * returns the node type of the specified node. should be one of
     368     * GSXML.NODE_TYPE_LEAF, GSXML.NODE_TYPE_INTERNAL, GSXML.NODE_TYPE_ROOT
     369     */
     370    protected String getNodeType(String node_id, String doc_type)
     371    {
     372        return this.gs_doc.getNodeType(node_id, doc_type);
     373    }
     374
     375    /** returns true if the node has child nodes */
     376    protected boolean hasChildren(String node_id)
     377    {
     378        return this.gs_doc.hasChildren(node_id);
     379    }
     380
     381    /** returns true if the node has a parent */
     382    protected boolean hasParent(String node_id)
     383    {
     384        return this.gs_doc.hasParent(node_id);
     385    }
     386
     387    /**
     388     * get the details about the indexes available must be implemented by
     389     * subclass there must be at least one index
     390     */
     391    abstract protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang);
    358392
    359393}
    360 
Note: See TracChangeset for help on using the changeset viewer.