Changeset 5644 for trunk/gsdl3
- Timestamp:
- 2003-10-16T09:59:02+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
r5188 r5644 71 71 private static final String FIELD_COMBINE_PARAM_NOT = "2"; 72 72 73 // some stuff for config files 74 private static final String SEARCH_TYPE_ELEM = "searchType"; 75 private static final String SEARCH_TYPE_PLAIN = "plain"; 76 private static final String SEARCH_TYPE_FORM = "form"; 77 private static final String SEARCH_TYPE_FORM_SIMPLE = "simple"; 78 private static final String SEARCH_TYPE_FORM_ADVANCED = "advanced"; 79 80 73 81 private static final int TEXT_QUERY = 0; 74 82 private static final int SIMPLE_QUERY = 1; … … 80 88 // the default level for retrieval - and we'll use it for searching too 81 89 private String default_level=null; 90 // which search services will we offer?? 91 private boolean plain_search = false; 92 private boolean simple_form_search = false; 93 private boolean advanced_form_search = false; 82 94 83 95 /** constructor */ … … 95 107 return false; 96 108 109 // the format info is the same for all services 110 Element format_info = (Element)format_info_map.get(TEXT_QUERY_SERVICE); 111 112 // the generic config has set up the text query service, but we may not want it 113 Element search_type_list = (Element) GSXML.getChildByTagName(info, SEARCH_TYPE_ELEM + GSXML.LIST_MODIFIER); 114 if (search_type_list == null) { 115 // assume form and plain 116 this.plain_search = true; 117 this.simple_form_search = true; 118 this.advanced_form_search = true; 119 } else { 120 NodeList types = search_type_list.getElementsByTagName(SEARCH_TYPE_ELEM); 121 for (int i=0; i<types.getLength(); i++) { 122 Element t = (Element)types.item(i); 123 String type_name = t.getAttribute(GSXML.NAME_ATT); 124 if (type_name.equals(SEARCH_TYPE_PLAIN)) { 125 this.plain_search = true; 126 } else if (type_name.equals(SEARCH_TYPE_FORM)) { 127 String type_type = t.getAttribute(GSXML.TYPE_ATT); 128 if (type_type.equals("")) { 129 this.simple_form_search = true; 130 this.advanced_form_search = true; 131 } else if (type_type.equals(SEARCH_TYPE_FORM_SIMPLE)) { 132 this.simple_form_search = true; 133 } else if (type_type.equals(SEARCH_TYPE_FORM_ADVANCED)) { 134 this.advanced_form_search = true; 135 136 } 137 } 138 } 139 } 140 141 if (!this.plain_search) { 142 // need to remove the TextQuery service 143 Element tq_service = GSXML.getNamedElement(short_service_info, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, TEXT_QUERY_SERVICE); 144 short_service_info.removeChild(tq_service); 145 146 } 147 148 97 149 // Do specific configuration 98 150 System.out.println("Configuring GS2MGPPSearch..."); … … 126 178 // else set up the fielded query services 127 179 128 // set up short_service_info_ - for now just has id and type - name will be added in on teh fly 129 Element fq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 130 fq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 131 fq_service.setAttribute(GSXML.NAME_ATT, FIELD_QUERY_SERVICE); 132 this.short_service_info.appendChild(fq_service); 133 134 Element afq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 135 afq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 136 afq_service.setAttribute(GSXML.NAME_ATT, ADVANCED_FIELD_QUERY_SERVICE); 137 this.short_service_info.appendChild(afq_service); 138 139 140 //set up format info - the info is the same as that for text query 141 Element format_info = (Element)format_info_map.get(TEXT_QUERY_SERVICE); 142 if (format_info != null) { 143 this.format_info_map.put(FIELD_QUERY_SERVICE, format_info); 144 this.format_info_map.put(ADVANCED_FIELD_QUERY_SERVICE, format_info); 180 if (this.simple_form_search) { 181 // set up short_service_info_ - for now just has id and type - name will be added in on teh fly 182 Element fq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 183 fq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 184 fq_service.setAttribute(GSXML.NAME_ATT, FIELD_QUERY_SERVICE); 185 this.short_service_info.appendChild(fq_service); 186 187 if (format_info != null) { 188 this.format_info_map.put(FIELD_QUERY_SERVICE, format_info); 189 } 190 } 191 192 if (this.advanced_form_search) { 193 Element afq_service = this.doc.createElement(GSXML.SERVICE_ELEM); 194 afq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); 195 afq_service.setAttribute(GSXML.NAME_ATT, ADVANCED_FIELD_QUERY_SERVICE); 196 this.short_service_info.appendChild(afq_service); 197 198 if (format_info != null) { 199 this.format_info_map.put(ADVANCED_FIELD_QUERY_SERVICE, format_info); 200 } 145 201 } 146 202 return true; … … 148 204 149 205 protected Element getServiceDescription(String service_id, String lang, String subset) { 206 // should we check that the service is actually on offer? presumably we wont get asked for services that we haven't advertised previously. 150 207 151 208 if (!service_id.equals(FIELD_QUERY_SERVICE) && !service_id.equals(ADVANCED_FIELD_QUERY_SERVICE)) { 152 209 return super.getServiceDescription(service_id, lang, subset); 153 210 } 211 154 212 155 213 Element service = this.doc.createElement(GSXML.SERVICE_ELEM);
Note:
See TracChangeset
for help on using the changeset viewer.