- Timestamp:
- 2013-10-10T17:21:30+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
r27145 r28382 11 11 import org.greenstone.gsdl3.util.GSXSLT; 12 12 import org.greenstone.gsdl3.util.UserContext; 13 import org.w3c.dom.Document; 13 14 import org.w3c.dom.Element; 14 15 import org.w3c.dom.Node; … … 26 27 public Node process(Node message_node) 27 28 { 28 29 29 Element message = this.converter.nodeToElement(message_node); 30 30 Document doc = message.getOwnerDocument(); 31 31 32 // get the request - assume there is only one 32 33 Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM); 33 34 34 35 // create the return message 35 Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);36 Element result = doc.createElement(GSXML.MESSAGE_ELEM); 36 37 Element response = basicQuery(request); 37 result.appendChild( this.doc.importNode(response, true));38 result.appendChild(doc.importNode(response, true)); 38 39 return result; 39 40 } … … 47 48 { 48 49 // the result 49 Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM); 50 Document doc = request.getOwnerDocument(); 51 Element page_response = doc.createElement(GSXML.RESPONSE_ELEM); 50 52 51 53 // extract the params from the cgi-request, and check that we have a coll specified … … 75 77 format_elem.setAttribute(GSXML.TYPE_ATT, "search"); 76 78 // for now just add to the response 77 page_response.appendChild( this.doc.importNode(format_elem, true));79 page_response.appendChild(doc.importNode(format_elem, true)); 78 80 79 81 if (request_type.indexOf("d") != -1) 80 82 { 81 83 // we have been asked for the service description 82 Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);83 Element mr_info_request = GSXML.createBasicRequest( this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);84 Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM); 85 Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext); 84 86 mr_info_message.appendChild(mr_info_request); 85 87 … … 90 92 Element service_response = (Element) GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM); 91 93 92 Element service_description = (Element) this.doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);94 Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true); 93 95 page_response.appendChild(service_description); 94 96 } … … 114 116 115 117 // create the query request 116 Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);117 Element mr_query_request = GSXML.createBasicRequest( this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);118 Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM); 119 Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 118 120 mr_query_message.appendChild(mr_query_request); 119 121 120 Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);121 GSXML.addParametersToList( this.doc, query_param_list, service_params);122 Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 123 GSXML.addParametersToList(doc, query_param_list, service_params); 122 124 mr_query_request.appendChild(query_param_list); 123 125 … … 144 146 else 145 147 { // add it into the page response 146 page_response.appendChild( this.doc.importNode(query_result_metadata_list, true));148 page_response.appendChild(doc.importNode(query_result_metadata_list, true)); 147 149 } 148 150 … … 154 156 else 155 157 { // add it into the page response 156 page_response.appendChild( this.doc.importNode(query_term_info_list, true));158 page_response.appendChild(doc.importNode(query_term_info_list, true)); 157 159 } 158 160 … … 164 166 else 165 167 { // add it into the page response 166 page_response.appendChild( this.doc.importNode(facet_list, true));168 page_response.appendChild(doc.importNode(facet_list, true)); 167 169 } 168 170 … … 173 175 { 174 176 // add in a dummy doc node list - used by the display. need to think about this 175 page_response.appendChild( this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));177 page_response.appendChild(doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER)); 176 178 //append site metadata 177 179 addSiteMetadata(page_response, userContext); … … 186 188 logger.error("have already found metadata!"); 187 189 // append the doc list to the result 188 page_response.appendChild( this.doc.importNode(document_list, true));190 page_response.appendChild(doc.importNode(document_list, true)); 189 191 //append site metadata 190 192 addSiteMetadata(page_response, userContext); … … 203 205 204 206 // paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata 205 Element filtered_doc_list = filterDocList( params, service_params, document_list);207 Element filtered_doc_list = filterDocList(doc, params, service_params, document_list); 206 208 207 209 // do the metadata request on the filtered list 208 Element mr_metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);210 Element mr_metadata_message = doc.createElement(GSXML.MESSAGE_ELEM); 209 211 to = "DocumentMetadataRetrieve"; 210 212 if (collection != null) … … 212 214 to = GSPath.prependLink(to, collection); 213 215 } 214 Element mr_metadata_request = GSXML.createBasicRequest( this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);216 Element mr_metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext); 215 217 mr_metadata_message.appendChild(mr_metadata_request); 216 218 … … 228 230 } 229 231 230 Element dm_param_list = createMetadataParamList( metadata_names);232 Element dm_param_list = createMetadataParamList(doc,metadata_names); 231 233 232 234 mr_metadata_request.appendChild(dm_param_list); … … 246 248 if (query_result_document_list != null) 247 249 { 248 page_response.appendChild( this.doc.importNode(query_result_document_list, true));250 page_response.appendChild(doc.importNode(query_result_document_list, true)); 249 251 } 250 252 … … 257 259 258 260 /** this filters out some of the doc results for result paging */ 259 protected Element filterDocList( HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list)261 protected Element filterDocList(Document doc, HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list) 260 262 { 261 263 … … 265 267 { 266 268 // the service is doing the paging, so we want to display all of the returned docs(???) 267 // return (Element) this.doc.importNode(orig_doc_list, true);269 // return (Element)doc.importNode(orig_doc_list, true); 268 270 // try hitsPerPage in the globle param 269 271 hits_pp = (String) params.get("hitsPerPage"); … … 285 287 if (hits == -1) 286 288 { // all 287 return (Element) this.doc.importNode(orig_doc_list, true);289 return (Element) doc.importNode(orig_doc_list, true); 288 290 } 289 291 NodeList result_docs = orig_doc_list.getElementsByTagName(GSXML.DOC_NODE_ELEM); … … 293 295 { 294 296 // too few docs to do paging 295 return (Element) this.doc.importNode(orig_doc_list, true);297 return (Element) doc.importNode(orig_doc_list, true); 296 298 } 297 299 298 300 // now we need our own doc list 299 Element result_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);301 Element result_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 300 302 301 303 String start_p = (String) service_params.get("startPage"); … … 335 337 for (int i = start_from; i <= end_at; i++) 336 338 { 337 result_list.appendChild( this.doc.importNode(result_docs.item(i), true));339 result_list.appendChild(doc.importNode(result_docs.item(i), true)); 338 340 } 339 341
Note:
See TracChangeset
for help on using the changeset viewer.