Changeset 13127


Ignore:
Timestamp:
2006-10-18T17:02:02+13:00 (18 years ago)
Author:
kjdon
Message:

now look for indexOptionList in the config file - currently two options, maxnumeric (currently stored but not used yet) and stemIndexes - determines whether stem, case and accentfold indexes are available. these parameters for the search form are now dependent on this option.

File:
1 edited

Legend:

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

    r13124 r13127  
    6868    private static final String FIELD_STEM_PARAM = "fqs";
    6969    private static final String FIELD_CASE_PARAM = "fqc";
     70    private static final String FIELD_ACCENT_PARAM="fqa";
    7071    private static final String FIELD_FIELD_PARAM = "fqf";
    7172    private static final String FIELD_COMBINE_PARAM = "fqk";
     
    7374    private static final String FIELD_COMBINE_PARAM_OR = "1";
    7475    private static final String FIELD_COMBINE_PARAM_NOT = "2";
     76   
     77    private static final String ACCENT_PARAM="accent";
    7578
    7679    // some stuff for config files
     
    8487    protected static final String LEVEL_ELEM = "level";
    8588
     89    protected static final String STEMINDEX_OPTION = "stemIndexes";
     90    protected static final String MAXNUMERIC_OPTION = "maxnumeric";
     91
    8692    protected static final String EQUIV_TERM_ELEM = "equivTerm";
    8793
     
    106112    private boolean advanced_form_search = false;
    107113
     114    // stem indexes available
     115    private boolean does_case=true;
     116    private boolean does_stem=true;
     117    private boolean does_accent=false;
     118   
     119    // maxnumeric - not used yet. needs to be passed to MGPPWrapper.
     120    private int maxnumeric = 4;
     121
    108122    /** the stem used for the index files */
    109123    protected String index_stem = null;
     
    142156    }
    143157    if (this.index_stem == null || this.index_stem.equals("")) {
    144         logger.error("AbstractMGPPSearch.configure(): indexStem element not found, stem will default to collection name");
     158        logger.warn("AbstractMGPPSearch.configure(): indexStem element not found, stem will default to collection name");
    145159        this.index_stem = this.cluster_name;
     160    }
     161
     162    // get index options
     163    Element index_option_list = (Element) GSXML.getChildByTagName(info, GSXML.INDEX_OPTION_ELEM + GSXML.LIST_MODIFIER);
     164    if (index_option_list != null) {
     165        NodeList options = index_option_list.getElementsByTagName(GSXML.INDEX_OPTION_ELEM);
     166        for (int i=0; i<options.getLength(); i++) {
     167        Element opt = (Element)options.item(i);
     168        String name = opt.getAttribute(GSXML.NAME_ATT);
     169        String value = opt.getAttribute(GSXML.VALUE_ATT);
     170        if (name.equals(MAXNUMERIC_OPTION)) {
     171            int maxnum = Integer.parseInt(value);
     172            if (4 <= maxnum && maxnum < 512) {
     173            maxnumeric = maxnum;
     174            }
     175        }
     176        else if (name.equals(STEMINDEX_OPTION)) {
     177            int stemindex = Integer.parseInt(value);
     178            // stem and case are true by default, accent folding false by defualt
     179            if ((stemindex & 1) == 0) {
     180            does_case = false;
     181            }
     182            if ((stemindex & 2) == 0) {
     183            does_stem = false;
     184            }
     185            if ((stemindex & 4) != 0) {
     186            does_accent = true;
     187            }
     188        }
     189        }
    146190    }
    147191
     
    295339        param_list.appendChild(multiparam);
    296340       
    297         createParameter(FIELD_COMBINE_PARAM, multiparam,  lang);
    298         createParameter(FIELD_QUERY_PARAM, multiparam,  lang);
    299         createParameter(FIELD_CASE_PARAM, multiparam,  lang);
    300         createParameter(FIELD_STEM_PARAM, multiparam,  lang);
    301         createParameter(FIELD_FIELD_PARAM, multiparam,  lang);   
     341        createParameter(FIELD_COMBINE_PARAM, multiparam, lang);
     342        createParameter(FIELD_QUERY_PARAM, multiparam, lang);
     343        if (this.does_case) {
     344            createParameter(FIELD_CASE_PARAM, multiparam, lang);
     345        }
     346        if (this.does_stem) {
     347            createParameter(FIELD_STEM_PARAM, multiparam, lang);
     348        }
     349        if (this.does_accent) {
     350            createParameter(FIELD_ACCENT_PARAM, multiparam, lang);
     351        }
     352        createParameter(FIELD_FIELD_PARAM, multiparam, lang);   
    302353       
    303354        }
     
    311362    {
    312363    createParameter(LEVEL_PARAM, param_list, lang);
    313     createParameter(CASE_PARAM, param_list, lang);
    314     createParameter(STEM_PARAM, param_list, lang);
     364    if (this.does_case){
     365        createParameter(CASE_PARAM, param_list, lang);
     366    }
     367    if (this.does_stem){
     368        createParameter(STEM_PARAM, param_list, lang);
     369    }
     370    if (this.does_accent){
     371        createParameter(ACCENT_PARAM, param_list, lang);
     372    }
    315373    createParameter(MATCH_PARAM, param_list, lang);
    316374    createParameter(RANK_PARAM, param_list, lang);
    317 
    318375    }
    319376
     
    341398       
    342399       
    343     } else if (name.equals(FIELD_CASE_PARAM) || name.equals(FIELD_STEM_PARAM)) {
     400    } else if (name.equals(FIELD_CASE_PARAM) || name.equals(FIELD_STEM_PARAM) || name.equals(FIELD_ACCENT_PARAM)) {
    344401        String[] bool_ops = {"0", "1"};
    345402        String[] bool_texts = {getTextString("param.boolean.off", lang, "AbstractSearch"),getTextString("param.boolean.on", lang, "AbstractSearch")};
Note: See TracChangeset for help on using the changeset viewer.