Changeset 29557
- Timestamp:
- 2014-12-08T14:44:06+13:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
r28964 r29557 20 20 { 21 21 22 public static final String HITS_PER_PAGE = "hitsPerPage"; 22 23 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.action.QueryAction.class.getName()); 23 24 24 25 /** 25 26 * process - processes a request. … … 58 59 String service_name = (String) params.get(GSParams.SERVICE); 59 60 String collection = (String) params.get(GSParams.COLLECTION); 60 61 String lang = request.getAttribute(GSXML.LANG_ATT); 61 62 // collection may be null or empty when we are doing cross coll services 62 63 if (collection == null || collection.equals("")) … … 79 80 page_response.appendChild(doc.importNode(format_elem, true)); 80 81 81 if (request_type.indexOf("d") != -1) 82 { 82 //if (request_type.indexOf("d") != -1) 83 //{ 84 // get the service description 83 85 // we have been asked for the service description 84 86 Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM); … … 93 95 94 96 Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true); 95 page_response.appendChild(service_description); 96 } 97 97 98 99 // have we been asked to return it as part of the response? 100 if (request_type.indexOf("d") != -1) { 101 page_response.appendChild(service_description); 102 } 103 //} 104 boolean does_paging = false; 105 Element meta_list =(Element) GSXML.getChildByTagName(service_description, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER); 106 if (meta_list != null) { 107 String value = GSXML.getMetadataValue(meta_list, "does_paging"); 108 if (value.equals("true")) { 109 does_paging = true; 110 } 111 } 112 113 if (does_paging == false) { 114 // we will do the paging, so lets add in a hitsPerPage param to the service 115 addHitsParamToService(doc, service_description, lang); 116 } 98 117 if (request_type.indexOf("r") == -1) 99 118 { … … 124 143 mr_query_request.appendChild(query_param_list); 125 144 126 logger.debug(GSXML.xmlNodeToString(mr_query_message));127 128 145 // do the query 129 146 Element mr_query_response = (Element) this.mr.process(mr_query_message); … … 186 203 if (doc_metadata.getLength() > 0) 187 204 { 188 logger.error("have already found metadata!");189 205 // why are we not paging these results????? 206 // append the doc list to the result 190 207 page_response.appendChild(doc.importNode(document_list, true)); 191 208 //append site metadata … … 205 222 206 223 // paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata 207 Element filtered_doc_list = filterDocList(doc, params, service_params, document_list); 208 224 Element filtered_doc_list; 225 if (does_paging) { 226 filtered_doc_list = (Element)doc.importNode(document_list, true); 227 } else { 228 filtered_doc_list = filterDocList(doc, params, service_params, document_list); 229 } 209 230 // do the metadata request on the filtered list 210 231 Element mr_metadata_message = doc.createElement(GSXML.MESSAGE_ELEM); … … 251 272 } 252 273 253 logger.debug("Query page:\n" + this.converter.getPrettyString(page_response));274 //logger.debug("Query page:\n" + this.converter.getPrettyString(page_response)); 254 275 //append site metadata 255 276 addSiteMetadata(page_response, userContext); … … 262 283 { 263 284 264 // check the hits_per_page param - is it a service param?? 265 String hits_pp = (String) service_params.get("hitsPerPage"); 266 if (hits_pp == null) 267 { 268 // the service is doing the paging, so we want to display all of the returned docs(???) 269 // return (Element)doc.importNode(orig_doc_list, true); 270 // try hitsPerPage in the globle param 271 hits_pp = (String) params.get("hitsPerPage"); 272 } 273 285 String hits_pp = (String) service_params.get(HITS_PER_PAGE); 286 274 287 int hits = 20; 275 288 if (hits_pp != null && !hits_pp.equals("")) 276 289 { 290 if (hits_pp.equals("all")) { 291 hits = -1; 292 } else { 277 293 try 278 294 { … … 283 299 hits = 20; 284 300 } 285 }286 301 } 302 } 287 303 if (hits == -1) 288 304 { // all … … 319 335 } 320 336 } 321 322 337 int start_from = (start - 1) * hits; 323 338 int end_at = (start * hits) - 1; … … 333 348 end_at = num_docs - 1; 334 349 } 335 336 350 // now we finally have the docs numbers to use 337 351 for (int i = start_from; i <= end_at; i++) … … 343 357 } 344 358 359 protected boolean addHitsParamToService(Document doc, Element service_description, String lang) { 360 Element param_list = (Element)GSXML.getChildByTagName(service_description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 361 Element param = GSXML.createParameterDescription(doc, HITS_PER_PAGE, getTextString("param." + HITS_PER_PAGE, lang, "AbstractSearch", null), GSXML.PARAM_TYPE_INTEGER, "20", null, null); 362 Element query_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "query"); 363 if (query_param != null) { 364 param_list.insertBefore(param, query_param); 365 } else { 366 param_list.appendChild(param); 367 } 368 return true; 369 } 345 370 }
Note:
See TracChangeset
for help on using the changeset viewer.