Changeset 29427

Show
Ignore:
Timestamp:
13.11.2014 13:13:51 (4 years ago)
Author:
kjdon
Message:

read in defaultSort element and store it. Use this for default rank param. Also, use paramDefaults value for sort order param, that way user can set it in config file

Files:
1 modified

Legend:

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

    r29318 r29427  
    4040 
    4141  protected static final String SORT_ELEM = "sort"; 
     42  protected static final String DEFAULT_SORT_ELEM = "defaultSort"; 
    4243  protected static final String SORT_ORDER_PARAM = "sortOrder"; 
    4344  protected static final String SORT_ORDER_DESCENDING = "1"; 
    4445  protected static final String SORT_ORDER_ASCENDING = "0"; 
    4546 
    46     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.SharedSoleneGS2FieldSearch.class.getName()); 
    47  
    48     protected SharedSoleneQuery solene_src = null; 
    49  
     47  static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.SharedSoleneGS2FieldSearch.class.getName()); 
     48 
     49  protected SharedSoleneQuery solene_src = null; 
     50  protected String default_sort = ""; 
    5051   
    5152    public SharedSoleneGS2FieldSearch() 
     
    100101              } 
    101102          } // for each sortfield 
     103 
     104        // get the default sort field 
     105        Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_SORT_ELEM); 
     106        if (def != null) 
     107        { 
     108            this.default_sort = def.getAttribute(GSXML.SHORTNAME_ATT); 
     109        } 
     110         
    102111        // Lucene/Solr doesn't do case folding or stemming or accent folding at the  
    103112        // moment 
     
    138147            ArrayList<String> fields = new ArrayList<String>(); 
    139148            ArrayList<String> field_names = new ArrayList<String>(); 
     149            param_default = default_sort; 
    140150            if (!getSortData(fields, field_names, lang)) { 
    141151              fields.add(RANK_PARAM_RANK); 
     
    143153              field_names.add(getTextString("param." + RANK_PARAM + "." + RANK_PARAM_RANK, lang)); 
    144154              field_names.add(getTextString("param." + RANK_PARAM + "." + RANK_PARAM_NONE, lang)); 
     155              param_default = RANK_PARAM_RANK; 
    145156            } 
    146              
    147             param = GSXML.createParameterDescription2(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, fields.get(0), fields, field_names); 
     157            else { 
     158              if (param_default == null) { 
     159                param_default = fields.get(0); 
     160              } 
     161            } 
     162            param = GSXML.createParameterDescription2(doc, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, fields, field_names); 
    148163             
    149164        } else if (name.equals(SORT_ORDER_PARAM)) { 
     
    151166        String[] vals_texts = { getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_ASCENDING, lang), getTextString("param." + SORT_ORDER_PARAM + "." + SORT_ORDER_DESCENDING, lang) }; 
    152167 
    153         param = GSXML.createParameterDescription(doc, SORT_ORDER_PARAM, getTextString("param." + SORT_ORDER_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, SORT_ORDER_DESCENDING, vals, vals_texts); 
     168        param = GSXML.createParameterDescription(doc, SORT_ORDER_PARAM, getTextString("param." + SORT_ORDER_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, param_default, vals, vals_texts); 
    154169      } 
    155170