Changeset 6517
- Timestamp:
- 2004-01-15T17:00:41+13:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGRetrieve.java
r6304 r6517 122 122 //ystem.out.println("translated id = "+doc_id); 123 123 } 124 int doc_num = this.database.OID2MGNum(doc_id); 124 if (GS3OID.isDocTop(doc_id)) { 125 System.out.println("adding the structure bit to doc id"); 126 doc_id = GS3OID.createOID(doc_id, "1"); 127 } 128 String doc_num = this.database.OID2MGNum(doc_id); 129 125 130 //long doc_num = this.gdbm_src.oid2Docnum(doc_id); 126 //ystem.out.println("mg doc num = "+doc_num); 131 System.out.println("mg doc num = "+doc_num); 132 // doc nums have the index prefixed 133 doc_num = doc_num.substring(doc_num.indexOf(".")+1); 134 int doc_int = Integer.parseInt(doc_num); 135 System.out.println("actual mg doc num="+doc_int); 127 136 String doc_content = ""; 128 137 try { 129 doc_content = this.mg_src.getDocument(basedir, textdir, doc_ num);138 doc_content = this.mg_src.getDocument(basedir, textdir, doc_int); 130 139 } catch (Exception e) { 131 140 System.out.println("exception happended with mg_src.getDocument()"); 132 doc_content = "this is the content for section hash id "+ doc_id+", mg doc num "+doc_ num+"\n";141 doc_content = "this is the content for section hash id "+ doc_id+", mg doc num "+doc_int+"\n"; 133 142 } 134 143 //ystem.out.println("Doc content: " + doc_content + "|"); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java
r6304 r6517 140 140 for (int d = 0; d < docs.size(); d++) { 141 141 long docnum = ((MGDocInfo) docs.elementAt(d)).num_; 142 String doc_id = database.MGNum2OID((int)docnum); 142 String mg_id = index+"."+docnum; 143 String doc_id = database.MGNum2OID(mg_id); 143 144 //String doc_id = this.gdbm_src.docnum2Oid(docnum); 144 145 Element doc_node = createDocumentNodeElement(doc_id); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Retrieve.java
r6358 r6517 99 99 dsr_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 100 100 dsr_service.setAttribute(GSXML.NAME_ATT, DOCUMENT_STRUCTURE_RETRIEVE_SERVICE); 101 //this.short_service_info.appendChild(dsr_service);101 this.short_service_info.appendChild(dsr_service); 102 102 103 103 Element dmr_service = this.doc.createElement(GSXML.SERVICE_ELEM); … … 342 342 343 343 node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 344 node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 345 346 // String top_id = OID.getTop(node_id); 344 node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); // need to work this out dynamically 345 346 if (GS3OID.isTop(node_id)) { 347 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 348 } else if (database.documentHasChildren(node_id)){ 349 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 350 } else { 351 node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 352 } 353 // String top_id = GS3OID.getTop(node_id); 347 354 // boolean is_top = (top_id.equals(node_id) ? true : false); 348 355 … … 385 392 protected Element getParent(String doc_id) 386 393 { 387 String parent_id = OID.getParent(doc_id);394 String parent_id = GS3OID.getParent(doc_id); 388 395 if (parent_id.equals(doc_id)) 389 396 return null; … … 398 405 int type, boolean recursive) 399 406 { 407 400 408 if (type == DOCUMENT) { 401 return; 402 } 403 if (type == CLASSIFIER) { 409 ArrayList children = database.getDocumentChildren(doc_id); 410 if (children == null) return; 411 for (int i=0; i<children.size(); i++) { 412 String child_id = (String) children.get(i); 413 Element child = createDocNode(child_id, false, true); 414 doc.appendChild(child); 415 // Apply recursively, if desired 416 if (recursive) { 417 addDescendants(child, child_id, type, recursive); 418 } 419 } 420 421 } 422 else if (type == CLASSIFIER) { 404 423 ArrayList documents = database.getClassifierDocChildren(doc_id); 405 424 for (int i=0; i<documents.size(); i++) { … … 423 442 424 443 /** adds all the siblings of current_id to the parent element. */ 425 //protected Element addSiblings(Element parent, String parent_id, String current_id) {426 //Element current_node = (Element)parent.getFirstChild();427 //if (current_node ==null) {428 //// create a sensible error message429 //System.err.println("GS3Retrieve Error: there should be a first child.");430 //return null;431 //}432 //// remove the current child,- will add it in later in its correct place433 //parent.removeChild(current_node);434 435 //// add in all the siblings,436 // addDescendants(parent, parent_id, false);437 438 //// find the node that is now the current node439 //// this assumes that the new node that was created is the same as440 //// the old one that was removed - we may want to replace the new one441 //// with the old one.442 //Element new_current = GSXML.getNamedElement(parent, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id);443 //return new_current;444 445 //}444 protected Element addSiblings(Element parent, String parent_id, String current_id) { 445 Element current_node = (Element)parent.getFirstChild(); 446 if (current_node ==null) { 447 // create a sensible error message 448 System.err.println("GS3Retrieve Error: there should be a first child."); 449 return null; 450 } 451 // remove the current child,- will add it in later in its correct place 452 parent.removeChild(current_node); 453 454 // add in all the siblings, 455 addDescendants(parent, parent_id, DOCUMENT, false); 456 457 // find the node that is now the current node 458 // this assumes that the new node that was created is the same as 459 // the old one that was removed - we may want to replace the new one 460 // with the old one. 461 Element new_current = GSXML.getNamedElement(parent, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id); 462 return new_current; 463 464 } 446 465 /** Returns true if the OID specifies a leaf node, false otherwise 447 466 Note: this makes a request to the GDBM database so it may not be … … 462 481 } 463 482 464 //protected Element processDocumentStructureRetrieve(Element request) {465 //return genericStructureRetrieve(request, DOCUMENT);466 //}483 protected Element processDocumentStructureRetrieve(Element request) { 484 return genericStructureRetrieve(request, DOCUMENT); 485 } 467 486 468 487 protected Element processClassifierBrowse(Element request) { … … 565 584 String doc_id = doc_ids[i]; 566 585 567 if ( OID.needsTranslating(doc_id)) {586 if (GS3OID.needsTranslating(doc_id)) { 568 587 doc_id = translateOID(doc_id); 569 588 } 570 589 if (type==DOCUMENT && GS3OID.isDocTop(doc_id)) { 590 doc_id = GS3OID.createOID(doc_id, "1"); 591 } 571 592 // Add the document to the list 572 593 Element doc = this.doc.createElement(node_name); … … 593 614 doc.appendChild(structure_elem); 594 615 595 //if (want_entire_structure) {596 // String top_id =OID.getTop(doc_id);597 //Element top_node = createDocNode(top_id, true, false);598 // addDescendants(top_node, top_id, true);599 //structure_elem.appendChild(top_node);600 //continue; // with the next document, we dont need to do any more here601 //}616 if (want_entire_structure) { 617 String top_id = GS3OID.getTop(doc_id); 618 Element top_node = createDocNode(top_id, true, false); 619 addDescendants(top_node, top_id, type, true); 620 structure_elem.appendChild(top_node); 621 continue; // with the next document, we dont need to do any more here 622 } 602 623 603 624 // Add the requested structure information … … 632 653 633 654 //Siblings: get the other descendants of the selected node's parent 634 //if (want_siblings) {635 //Element parent = (Element)current.getParentNode(); // this may be the structure element if there has been no request for parents or ancestors636 // String parent_id =OID.getParent(doc_id);655 if (want_siblings) { 656 Element parent = (Element)current.getParentNode(); // this may be the structure element if there has been no request for parents or ancestors 657 String parent_id = GS3OID.getParent(doc_id); 637 658 638 //// add siblings, - returns a pointer to the new current node639 //current = addSiblings(parent, parent_id, doc_id);640 //}659 // add siblings, - returns a pointer to the new current node 660 current = addSiblings(parent, parent_id, doc_id); 661 } 641 662 642 663 // Children: get the descendants, but only one level deep … … 720 741 String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT); 721 742 722 if ( OID.needsTranslating(node_id)) {743 if (GS3OID.needsTranslating(node_id)) { 723 744 //node_id = this.gdbm_src.translateOID(node_id); 724 745 node_id = translateOID(node_id); … … 786 807 // String relation_id = ""; 787 808 // if (relation.equals("root")) { 788 // relation_id = OID.getTop(node_id);809 // relation_id = GS3OID.getTop(node_id); 789 810 // } else { 790 // relation_id = OID.getParent(node_id);811 // relation_id = GS3OID.getParent(node_id); 791 812 // } 792 813 … … 818 839 // value.append(relation_info.getInfo(new_meta)); 819 840 // String current_id = relation_id; 820 // relation_id = OID.getParent(current_id);841 // relation_id = GS3OID.getParent(current_id); 821 842 // while (!relation_id.equals(current_id)) { 822 843 // relation_info = this.gdbm_src.getInfo(relation_id); … … 826 847 827 848 // current_id = relation_id; 828 // relation_id = OID.getParent(current_id);849 // relation_id = GS3OID.getParent(current_id); 829 850 // } 830 851 … … 838 859 // protected String resolveImages(String doc_content, String doc_id) 839 860 // { 840 // String top_doc_id = OID.getTop(doc_id);861 // String top_doc_id = GS3OID.getTop(doc_id); 841 862 // DBInfo info = this.gdbm_src.getInfo(top_doc_id); 842 863 // String archivedir = info.getInfo("archivedir"); … … 852 873 // String value=""; 853 874 // if (info_type.equals(INFO_NUM_SIBS)) { 854 // String parent_id = OID.getParent(doc_id);875 // String parent_id = GS3OID.getParent(doc_id); 855 876 // if (parent_id.equals(doc_id)) { 856 877 // value="0"; … … 861 882 // value = String.valueOf(getNumChildren(doc_id)); 862 883 // } else if (info_type.equals(INFO_SIB_POS)) { 863 // String parent_id = OID.getParent(doc_id);884 // String parent_id = GS3OID.getParent(doc_id); 864 885 // if (parent_id.equals(doc_id)) { 865 886 // value="-1"; … … 907 928 String suff = oid.substring(p+1); 908 929 if (suff.equals("pr")) { 909 return OID.getParent(top);930 return GS3OID.getParent(top); 910 931 } else if (suff.equals("rt")) { 911 return OID.getTop(top);932 return GS3OID.getTop(top); 912 933 } 913 934 return oid; -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Search.java
r6304 r6517 260 260 boolean is_top = (top_id.equals(node_id) ? true : false); 261 261 262 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple"); 262 doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy"); 263 264 if (GS3OID.isTop(node_id)) { 265 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT); 266 } else if (database.documentHasChildren(node_id)){ 267 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR); 268 } else { 269 doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF); 270 } 271 263 272 return doc_node; 264 273 }
Note:
See TracChangeset
for help on using the changeset viewer.