Changeset 28966 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java
- Timestamp:
- 2014-04-10T14:39:33+12:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java
r25727 r28966 88 88 89 89 // set up short_service_info_ - for now just has name and type 90 Element e = this.d oc.createElement(GSXML.SERVICE_ELEM);90 Element e = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 91 91 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_APPLET); 92 92 e.setAttribute(GSXML.NAME_ATT, PHIND_SERVICE); … … 95 95 // set up the static applet description 96 96 97 applet_description = this.d oc.createElement(GSXML.SERVICE_ELEM);97 applet_description = this.desc_doc.createElement(GSXML.SERVICE_ELEM); 98 98 applet_description.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_APPLET); 99 99 applet_description.setAttribute(GSXML.NAME_ATT, PHIND_SERVICE); … … 116 116 } 117 117 Element app_elem = dom.getDocumentElement(); 118 applet_description.appendChild(this.d oc.importNode(app_elem, true));118 applet_description.appendChild(this.desc_doc.importNode(app_elem, true)); 119 119 120 120 return true; 121 121 } 122 122 123 protected Element getServiceDescription( String service, String lang, String subset) {123 protected Element getServiceDescription(Document doc, String service, String lang, String subset) { 124 124 if (!service.equals(PHIND_SERVICE)) { 125 125 return null; 126 126 } 127 127 Element describe = (Element) applet_description.cloneNode(true); 128 describe.appendChild(GSXML.createDisplayTextElement( this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(PHIND_SERVICE+".name", lang)));129 describe.appendChild(GSXML.createDisplayTextElement( this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(PHIND_SERVICE+".description", lang)));128 describe.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(PHIND_SERVICE+".name", lang))); 129 describe.appendChild(GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(PHIND_SERVICE+".description", lang))); 130 130 return describe; 131 131 } 132 132 133 133 protected Element processPhindApplet(Element request) { 134 134 Document result_doc = XMLConverter.newDOM(); 135 135 Element param_elem = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 136 136 HashMap<String, Serializable> params = GSXML.extractParams(param_elem, false); … … 156 156 157 157 // the result element 158 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);158 Element result = result_doc.createElement(GSXML.RESPONSE_ELEM); 159 159 result.setAttribute(GSXML.FROM_ATT, PHIND_SERVICE); 160 160 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 161 161 162 162 // applet result info must be in appletInfo element 163 Element applet_data = this.doc.createElement(GSXML.APPLET_DATA_ELEM);163 Element applet_data = result_doc.createElement(GSXML.APPLET_DATA_ELEM); 164 164 result.appendChild(applet_data); 165 Element phind_data = this.doc.createElement("phindData");165 Element phind_data = result_doc.createElement("phindData"); 166 166 applet_data.appendChild(phind_data); 167 167 … … 170 170 if (phrase == 0) { 171 171 if (word==null || word.equals("")) { 172 Element error = phindError( "no word or phrase");172 Element error = phindError(result_doc, "no word or phrase"); 173 173 phind_data.appendChild(error); 174 174 return result; … … 179 179 // the word is not in the collection 180 180 // return a phind error string 181 Element error = phindError( "the term "+word+" is not in the collection");181 Element error = phindError(result_doc, "the term "+word+" is not in the collection"); 182 182 phind_data.appendChild(error); 183 183 return result; … … 215 215 long last_d) { 216 216 217 217 synchronized (mgpp_retrieve_src) { 218 218 String record = this.mgpp_retrieve_src.getDocument(this.basepath+File.separatorChar+"pdata", "Document", 219 219 phrase); 220 220 if (record.equals("")) { 221 Element error = phindError( "somethings gone wrong - we haven't got a record for phrase number "+phrase);221 Element error = phindError(phind_data.getOwnerDocument(), "somethings gone wrong - we haven't got a record for phrase number "+phrase); 222 222 phind_data.appendChild(error); 223 223 return false; … … 258 258 phind_data.setAttribute("lf", lf); 259 259 phind_data.setAttribute("tf", tf); 260 GSXML.createTextElement(this.doc, "phrase", word);260 // GSXML.createTextElement(result_doc, "phrase", word); ??? - this needs to be appended somewhere???? 261 261 262 262 addExpansionList(phind_data, expansions, word, ef, first_e, last_e); … … 266 266 } 267 267 return true; 268 } 268 } // end of synchronized (mgpp_retrieve_src) 269 269 } 270 270 … … 273 273 String freq, 274 274 long first, long last) { 275 276 Element expansion_list = this.doc.createElement("expansionList");275 Document phind_doc = phind_data.getOwnerDocument(); 276 Element expansion_list = phind_doc.createElement("expansionList"); 277 277 phind_data.appendChild(expansion_list); 278 278 expansion_list.setAttribute("length", freq); … … 286 286 for (long i = first; i < last; i++) { 287 287 long num = Long.parseLong(expansions[(int)i]); 288 Element expansion = getExpansion( num, word);288 Element expansion = getExpansion(phind_doc, num, word); 289 289 expansion.setAttribute("num", Long.toString(i)); 290 290 expansion_list.appendChild(expansion); … … 293 293 } 294 294 295 protected Element getExpansion( long phrase_num,295 protected Element getExpansion(Document phind_doc, long phrase_num, 296 296 String orig_phrase) { 297 297 … … 311 311 String df = fields[3]; 312 312 313 Element expansion = this.doc.createElement("expansion");313 Element expansion = phind_doc.createElement("expansion"); 314 314 expansion.setAttribute("tf", tf); 315 315 expansion.setAttribute("df", df); … … 319 319 String [] ends = splitPhraseOnWord(phrase, orig_phrase); 320 320 if (!ends[0].equals("")) { 321 expansion.appendChild(GSXML.createTextElement( this.doc, "prefix", ends[0]));321 expansion.appendChild(GSXML.createTextElement(phind_doc, "prefix", ends[0])); 322 322 } 323 323 if (!ends[1].equals("")) { 324 expansion.appendChild(GSXML.createTextElement( this.doc, "suffix", ends[1]));324 expansion.appendChild(GSXML.createTextElement(phind_doc, "suffix", ends[1])); 325 325 } 326 326 … … 333 333 String freq, 334 334 long first, long last) { 335 336 Element document_list = this.doc.createElement("documentList");335 Document phind_doc = phind_data.getOwnerDocument(); 336 Element document_list = phind_doc.createElement("documentList"); 337 337 phind_data.appendChild(document_list); 338 338 document_list.setAttribute("length", freq); … … 357 357 doc_freq = doc_elem.substring(p+1); 358 358 } 359 Element document = getDocument( doc_num);359 Element document = getDocument(phind_doc, doc_num); 360 360 document.setAttribute("freq", doc_freq); 361 361 document.setAttribute("num", Long.toString(i)); … … 368 368 369 369 370 protected Element getDocument( long doc_num) {370 protected Element getDocument(Document phind_doc, long doc_num) { 371 371 372 372 // look up the phrase in the docs thingy … … 383 383 String title = fields[1]; 384 384 385 Element d = this.doc.createElement("document");385 Element d = phind_doc.createElement("document"); 386 386 d.setAttribute("hash", hash); 387 d.appendChild(GSXML.createTextElement( this.doc, "title", title));387 d.appendChild(GSXML.createTextElement(phind_doc, "title", title)); 388 388 389 389 return d; … … 395 395 long first, long last) { 396 396 397 398 Element thesaurus_list = this.doc.createElement("thesaurusList");397 Document phind_doc = phind_data.getOwnerDocument(); 398 Element thesaurus_list = phind_doc.createElement("thesaurusList"); 399 399 phind_data.appendChild(thesaurus_list); 400 400 thesaurus_list.setAttribute("length", freq); … … 414 414 if (index >= first && index < last) { // only output the ones we want 415 415 long phrase = Long.parseLong(items[j]); 416 Element t = getThesaurus(ph rase);416 Element t = getThesaurus(phind_doc, phrase); 417 417 t.setAttribute("type", type); 418 418 thesaurus_list.appendChild(t); … … 424 424 } 425 425 426 protected Element getThesaurus( long phrase_num) {426 protected Element getThesaurus(Document phind_doc, long phrase_num) { 427 427 428 428 // look up the phrase in the pdata thingy … … 441 441 String df = fields[3]; 442 442 443 Element thesaurus = this.doc.createElement("thesaurus");443 Element thesaurus = phind_doc.createElement("thesaurus"); 444 444 thesaurus.setAttribute("tf", tf); 445 445 thesaurus.setAttribute("df", df); 446 446 thesaurus.setAttribute("id", Long.toString(phrase_num)); 447 thesaurus.appendChild(GSXML.createTextElement( this.doc, "phrase", phrase));447 thesaurus.appendChild(GSXML.createTextElement(phind_doc, "phrase", phrase)); 448 448 return thesaurus; 449 449 … … 464 464 } 465 465 466 protected Element phindError( String message) {467 Element e = this.doc.createElement("phindError");468 Text t = this.doc.createTextNode(message);466 protected Element phindError(Document phind_doc, String message) { 467 Element e = phind_doc.createElement("phindError"); 468 Text t = phind_doc.createTextNode(message); 469 469 e.appendChild(t); 470 470 return e;
Note:
See TracChangeset
for help on using the changeset viewer.