Changeset 8823
- Timestamp:
- 2004-12-16T12:02:20+13:00 (19 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java
r8690 r8823 83 83 protected GS2MacroResolver macro_resolver = null; 84 84 85 protected String default_document_type = null; 85 86 /** constructor */ 86 87 protected GS2Retrieve() … … 125 126 if (display_format != null) { 126 127 this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.doc.importNode(display_format, true)); 127 // shoudl we make a copy? 128 // should we keep a copy? 129 // check for docType option. 130 Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType"); 131 if (doc_type_opt != null) { 132 String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT); 133 if (!value.equals("")) { 134 this.default_document_type = value; 135 } 136 } 128 137 } 129 138 … … 370 379 * child is true is it definitely is a child of something - just for efficiency purposes */ 371 380 protected Element createDocNode(String node_id, boolean parent, boolean child) { 372 373 381 // create this here or pass it in? 374 382 DBInfo info = this.gdbm_src.getInfo(node_id); … … 376 384 if (isClassifier(node_id)) { 377 385 node = this.doc.createElement(GSXML.CLASS_NODE_ELEM); 386 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 387 return node; 378 388 //String childtype = info.getInfo("childtype"); 379 389 //String orientation=""; … … 384 394 //} 385 395 //node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation); 396 } 397 398 399 node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 400 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 401 402 String doc_type = null; 403 if (default_document_type != null) { 404 doc_type = default_document_type; 405 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 406 if (doc_type.equals("simple")) { 407 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 408 return node; 409 } 410 } 411 412 String top_id = OID.getTop(node_id); 413 boolean is_top = (top_id.equals(node_id) ? true : false); 414 415 String children = info.getInfo("contains"); 416 boolean is_leaf = (children.equals("") ? true : false); 417 418 // set the doc type att 419 if (doc_type == null) { 420 doc_type = info.getInfo("doctype"); 421 if (!doc_type.equals("")&&!doc_type.equals("doc")) { 422 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 423 if (doc_type.equals("simple")) { 424 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 425 return node; 426 } 427 } else { 428 if (is_top && is_leaf) { // a single section document 429 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 430 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 431 return node; 432 433 } 434 435 if (!is_top) { // we need to look at the top info 436 info = this.gdbm_src.getInfo(top_id); 437 } 438 439 String childtype = info.getInfo("childtype"); 440 if (childtype.equals("Paged")) { 441 node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 442 } else { 443 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 444 } 445 } 446 447 } 448 // set the node type att 449 if (doc_type.equals("simple")) { 450 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 386 451 } else { 387 388 node = this.doc.createElement(GSXML.DOC_NODE_ELEM);389 390 String top_id = OID.getTop(node_id);391 boolean is_top = (top_id.equals(node_id) ? true : false);392 393 String children = info.getInfo("contains");394 boolean is_leaf = (children.equals("") ? true : false);395 396 // set the node type att397 452 if (is_top) { 398 453 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); … … 402 457 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 403 458 } 404 405 // set the doc type att 406 String doc_type = info.getInfo("doctype"); 407 if (!doc_type.equals("")&&!doc_type.equals("doc")) { 408 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 409 } else { 410 if (is_top && is_leaf) { // a single section document 411 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 412 413 } else { 414 415 if (!is_top) { // we need to look at the top info 416 info = this.gdbm_src.getInfo(top_id); 417 } 418 419 String childtype = info.getInfo("childtype"); 420 if (childtype.equals("Paged")) { 421 node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 422 } else { 423 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 424 } 425 } 426 } 427 428 } 429 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 459 } 460 461 462 430 463 return node; 431 464 … … 768 801 if (extlink) { 769 802 if (OID.needsTranslating(node_id)) { 803 770 804 // just ignore the extension cos it has no meaning here 771 805 // or should it be added back on for the next step??? -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Search.java
r8572 r8823 73 73 /** the default index */ 74 74 protected String default_index = null; 75 75 76 protected String default_document_type = null; 76 77 77 78 /** constructor */ … … 119 120 this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(format, true)); 120 121 } 121 122 123 // look for document display format - for documentType 124 String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM); 125 Element display_format = (Element)GSXML.getNodeByPath(extra_info, path); 126 if (display_format != null) { 127 // check for docType option. 128 Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType"); 129 if (doc_type_opt != null) { 130 String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT); 131 if (!value.equals("")) { 132 this.default_document_type = value; 133 } 134 } 135 } 136 122 137 return true; 123 138 } … … 248 263 protected Element createDocumentNodeElement(String node_id) 249 264 { 250 Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 251 doc_node.setAttribute(GSXML.NODE_ID_ATT, node_id); 252 265 266 Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 267 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 268 269 String doc_type = null; 270 if (default_document_type != null) { 271 doc_type = default_document_type; 272 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 273 if (doc_type.equals("simple")) { 274 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 275 return node; 276 } 277 } 278 253 279 String top_id = OID.getTop(node_id); 254 280 boolean is_top = (top_id.equals(node_id) ? true : false); … … 256 282 DBInfo info = this.gdbm_src.getInfo(node_id); 257 283 if (info == null) { // make it up - cant query the gdbm db 258 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 259 return doc_node; 284 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 285 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 286 return node; 260 287 } 261 288 String children = info.getInfo("contains"); 262 289 boolean is_leaf = (children.equals("") ? true : false); 263 264 // check for simple doc types 265 if (is_top && is_leaf) { // a single section document 266 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 267 return doc_node; 268 } 269 // set teh node type att 270 if (is_top) { 271 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 272 } else if (is_leaf) { 273 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 290 291 // set the doc type att 292 if (doc_type == null) { 293 doc_type = info.getInfo("doctype"); 294 if (!doc_type.equals("")&&!doc_type.equals("doc")) { 295 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 296 if (doc_type.equals("simple")) { 297 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 298 return node; 299 } 300 } else { 301 if (is_top && is_leaf) { // a single section document 302 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 303 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 304 return node; 305 306 } 307 308 if (!is_top) { // we need to look at the top info 309 info = this.gdbm_src.getInfo(top_id); 310 } 311 312 String childtype = info.getInfo("childtype"); 313 if (childtype.equals("Paged")) { 314 node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 315 } else { 316 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 317 } 318 } 319 320 } 321 // set the node type att 322 if (doc_type.equals("simple")) { 323 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 274 324 } else { 275 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 276 } 277 278 if (!is_top) { // we need to look at the top info 279 info = this.gdbm_src.getInfo(top_id); 280 } 281 282 String childtype = info.getInfo("childtype"); 283 if (childtype.equals("Paged")) { 284 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "paged"); 285 } else { 286 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 287 } 288 return doc_node; 325 if (is_top) { 326 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 327 } else if (is_leaf) { 328 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 329 } else { 330 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 331 } 332 } 333 return node; 289 334 } 290 335
Note:
See TracChangeset
for help on using the changeset viewer.