Changeset 20240 for greenstone3

Show
Ignore:
Timestamp:
12.08.2009 14:58:09 (11 years ago)
Author:
kjdon
Message:

createParameter now takes an optional defualt_value parameter, to be used as teh default in the option. If not specified, use teh default that it was using previously

Files:
1 modified

Legend:

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

    r20064 r20240  
    244244    } 
    245245 
     246    protected void createParameter(String name, Element param_list, String lang) { 
     247      createParameter(name, param_list, lang, null); 
     248    } 
    246249    /** default implementations for the standard parameters plus some  
    247250     * other common ones  
    248251     * index, maxDocs, hitsPerPage, startPage, query, case, stem,  
    249252    */ 
    250     protected void createParameter(String name, Element param_list, String lang) { 
     253     protected void createParameter(String name, Element param_list, String lang, String default_value) { 
    251254    Element param = null; 
     255    String param_default = default_value; 
    252256    if (name.equals(QUERY_PARAM)) { 
    253         param = GSXML.createParameterDescription(this.doc, QUERY_PARAM, getTextString("param."+QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null); 
     257        param = GSXML.createParameterDescription(this.doc, QUERY_PARAM, getTextString("param."+QUERY_PARAM, lang), GSXML.PARAM_TYPE_STRING, param_default, null, null); 
    254258        param_list.appendChild(param); 
    255259    } else if (name.equals(INDEX_PARAM)) { 
     
    263267        param_type = GSXML.PARAM_TYPE_ENUM_MULTI; 
    264268        } 
    265         param = GSXML.createParameterDescription2(this.doc, INDEX_PARAM, getTextString("param."+INDEX_PARAM, lang), param_type, this.default_index, index_ids, index_names); 
     269        if (param_default == null) { 
     270          param_default = this.default_index; 
     271        } 
     272        param = GSXML.createParameterDescription2(this.doc, INDEX_PARAM, getTextString("param."+INDEX_PARAM, lang), param_type, param_default, index_ids, index_names); 
    266273        param_list.appendChild(param); 
    267274    } 
     
    276283        param_type = GSXML.PARAM_TYPE_ENUM_MULTI; 
    277284        } 
    278         param = GSXML.createParameterDescription2(this.doc, INDEX_SUBCOLLECTION_PARAM, getTextString("param."+INDEX_SUBCOLLECTION_PARAM, lang), param_type, this.default_index_subcollection, index_sub_ids, index_sub_names); 
     285        if (param_default == null) { 
     286          param_default = this.default_index_subcollection; 
     287        } 
     288        param = GSXML.createParameterDescription2(this.doc, INDEX_SUBCOLLECTION_PARAM, getTextString("param."+INDEX_SUBCOLLECTION_PARAM, lang), param_type, param_default, index_sub_ids, index_sub_names); 
    279289        param_list.appendChild(param); 
    280290    } 
     
    289299        param_type = GSXML.PARAM_TYPE_ENUM_MULTI; 
    290300        } 
    291         param = GSXML.createParameterDescription2(this.doc, INDEX_LANGUAGE_PARAM, getTextString("param."+INDEX_LANGUAGE_PARAM, lang), param_type, this.default_index_language, index_lang_ids, index_lang_names); 
     301        if (param_default == null) { 
     302          param_default = this.default_index_language; 
     303        } 
     304        param = GSXML.createParameterDescription2(this.doc, INDEX_LANGUAGE_PARAM, getTextString("param."+INDEX_LANGUAGE_PARAM, lang), param_type, param_default, index_lang_ids, index_lang_names); 
    292305        param_list.appendChild(param); 
    293306    } 
    294307        else if (name.equals(MAXDOCS_PARAM)) { 
    295         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, this.default_max_docs, null, null); 
     308      if (param_default == null) { 
     309        param_default = this.default_max_docs; 
     310      } 
     311 
     312        param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
    296313        param_list.appendChild(param); 
    297314    } 
    298315    else if(name.equals(HITS_PER_PAGE_PARAM)){ 
    299          param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, this.default_hits_per_page, null, null); 
     316      if (param_default == null) { 
     317        param_default = this.default_hits_per_page; 
     318      } 
     319       
     320         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_INTEGER, param_default, null, null); 
    300321        param_list.appendChild(param); 
    301322    } 
    302323    else if (name.equals(CASE_PARAM) || name.equals(STEM_PARAM) || name.equals(ACCENT_PARAM)) { 
     324      if (param_default == null) { 
     325        param_default = BOOLEAN_PARAM_OFF; 
     326      } 
    303327        String[] bool_ops = {"0", "1"}; 
    304328        String[] bool_texts = {getTextString("param.boolean.off", lang),getTextString("param.boolean.on", lang)};  
    305         param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_BOOLEAN, BOOLEAN_PARAM_ON, bool_ops, bool_texts); 
     329        param = GSXML.createParameterDescription(this.doc, name, getTextString("param."+name, lang), GSXML.PARAM_TYPE_BOOLEAN, param_default, bool_ops, bool_texts); 
    306330        param_list.appendChild(param); 
    307331    } else if (name.equals(MATCH_PARAM)) { 
     332      if (param_default == null) { 
     333        param_default = MATCH_PARAM_SOME; 
     334      } 
     335       
    308336        String[] vals = {MATCH_PARAM_SOME, MATCH_PARAM_ALL }; 
    309337        String[] val_texts = {getTextString("param."+MATCH_PARAM+"."+MATCH_PARAM_SOME, lang), getTextString("param."+MATCH_PARAM+"."+MATCH_PARAM_ALL, lang)};  
    310         param = GSXML.createParameterDescription(this.doc, MATCH_PARAM, getTextString("param."+MATCH_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, MATCH_PARAM_SOME, vals, val_texts); 
     338        param = GSXML.createParameterDescription(this.doc, MATCH_PARAM, getTextString("param."+MATCH_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, val_texts); 
    311339        param_list.appendChild(param); 
    312340    } else if (name.equals(START_PAGE_PARAM)) { 
     341      if (param_default == null) { 
     342        param_default = "1"; 
     343      } 
     344       
    313345        // start page - set to 1 for the search page 
    314         param = GSXML.createParameterDescription(this.doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, "1", null, null); 
     346        param = GSXML.createParameterDescription(this.doc, START_PAGE_PARAM, "", GSXML.PARAM_TYPE_INVISIBLE, param_default, null, null); 
    315347        param_list.appendChild(param); 
    316348    }