Changeset 21655 for main


Ignore:
Timestamp:
2010-01-27T12:13:13+13:00 (14 years ago)
Author:
kjdon
Message:

search types. code was looking for searchtype list in buildconfig, but collconfig had format element. now have searchType elements in search element of collconfig. need to make GLI write that.

File:
1 edited

Legend:

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

    r21437 r21655  
    6969    protected static final String SEARCH_TYPE_ELEM = "searchType";
    7070    protected static final String SEARCH_TYPE_PLAIN = "plain";
    71     protected static final String SEARCH_TYPE_FORM = "form";
    72     protected static final String SEARCH_TYPE_FORM_SIMPLE = "simple";
    73     protected static final String SEARCH_TYPE_FORM_ADVANCED = "advanced";
     71    protected static final String SEARCH_TYPE_SIMPLE_FORM = "simpleform";
     72    protected static final String SEARCH_TYPE_ADVANCED_FORM = "advancedform";
    7473
    7574    protected static final String DEFAULT_LEVEL_ELEM = "defaultLevel";
     
    114113        return false;
    115114    }
    116     // the generic config has set up the text query service, but we may not want it
    117     Element search_type_list = (Element) GSXML.getChildByTagName(info, SEARCH_TYPE_ELEM + GSXML.LIST_MODIFIER);
    118     if (search_type_list == null) {
    119         // assume form and plain
    120         this.plain_search = true;
    121         this.simple_form_search = true;
    122         this.advanced_form_search = true;
    123     } else {
    124         NodeList types = search_type_list.getElementsByTagName(SEARCH_TYPE_ELEM);
    125         for (int i=0; i<types.getLength(); i++) {
    126         Element t = (Element)types.item(i);
    127         String type_name = t.getAttribute(GSXML.NAME_ATT);
    128         if (type_name.equals(SEARCH_TYPE_PLAIN)) {
    129             this.plain_search = true;
    130         } else if (type_name.equals(SEARCH_TYPE_FORM)) {
    131             String type_type = t.getAttribute(GSXML.TYPE_ATT);
    132             if (type_type.equals("")) {
    133             this.simple_form_search = true;
    134             this.advanced_form_search = true;
    135             } else if (type_type.equals(SEARCH_TYPE_FORM_SIMPLE)) {
    136             this.simple_form_search = true;
    137             } else if (type_type.equals(SEARCH_TYPE_FORM_ADVANCED)) {
    138             this.advanced_form_search = true;
    139            
    140             }
    141         }
    142         }
    143     }
    144 
    145     if (!this.plain_search) {
    146         // need to remove the TextQuery service
    147         Element tq_service = GSXML.getNamedElement(short_service_info, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, TEXT_QUERY_SERVICE);
    148         short_service_info.removeChild(tq_service);
    149        
    150     }
    151 
    152        
     115     
    153116    // Get the default level out of <defaultLevel> (buildConfig.xml)
    154117    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_LEVEL_ELEM);
     
    171134    }
    172135   
    173     // get display info from extra info - for levels
     136    // get stuff from from extra info (which is collectionConfig.xml)
    174137    if (extra_info !=null) {
     138
     139      // the search element
     140      Element config_search = (Element)GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
     141     
     142      NodeList search_types = config_search.getElementsByTagName(SEARCH_TYPE_ELEM);
     143      if (search_types == null) {
     144        // none specified, assume plain only
     145        this.plain_search = true;
     146      }
     147      else {
     148        for (int i=0; i<search_types.getLength(); i++) {
     149          Element t = (Element)search_types.item(i);
     150          String type_name = t.getAttribute(GSXML.NAME_ATT);
     151          if (type_name.equals(SEARCH_TYPE_PLAIN)) {
     152        this.plain_search = true;
     153          } else if (type_name.equals(SEARCH_TYPE_SIMPLE_FORM)) {
     154        this.simple_form_search = true;
     155          } else if (type_name.equals(SEARCH_TYPE_ADVANCED_FORM)) {
     156        this.advanced_form_search = true;
     157          }
     158        }
     159      }
     160     
     161      // AbstractGS2Search has set up the text query service, but we may not want it
     162      if (!this.plain_search) {
     163        // need to remove the TextQuery service
     164        Element tq_service = GSXML.getNamedElement(short_service_info, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, TEXT_QUERY_SERVICE);
     165        short_service_info.removeChild(tq_service);
     166       
     167      }
     168
    175169        Document owner = info.getOwnerDocument();
    176170   
    177171        NodeList levels = info.getElementsByTagName(GSXML.LEVEL_ELEM);
    178         Element config_search = (Element)GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM);
     172       
    179173       
    180174        for (int i=0; i<levels.getLength();i++) {
     
    199193        }
    200194        } // for each level
    201     }
    202  
     195    } else {
     196      // for soem reason we don't have the collectionConfig file. assume plain only
     197      this.plain_search = true;
     198    }
     199   
     200   
    203201    // the format info is the same for all services
    204202    Element format_info = (Element)format_info_map.get(TEXT_QUERY_SERVICE);
Note: See TracChangeset for help on using the changeset viewer.