Changeset 26046 for main/trunk/greenstone3
- Timestamp:
- 2012-07-31T15:22:22+12:00 (12 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java
r25977 r26046 23 23 24 24 import org.apache.log4j.Logger; 25 import org.greenstone.gsdl3.util.AbstractBasicDocument; 26 import org.greenstone.gsdl3.util.BasicDocument; 25 27 import org.greenstone.gsdl3.util.GSPath; 26 28 import org.greenstone.gsdl3.util.GSXML; … … 61 63 protected static final String INFO_SIB_POS = "siblingPosition"; 62 64 65 protected AbstractBasicDocument gs_doc = null; 66 63 67 protected Element config_info = null; // the xml from the config file 64 68 65 69 protected MacroResolver macro_resolver = null; 66 70 71 /** 72 * the default document type - use if all documents are the same type 73 */ 67 74 protected String default_document_type = null; 68 75 … … 175 182 } 176 183 } 184 185 // Base line for document (might be overriden by sub-classes) 186 gs_doc = new BasicDocument(this.doc, this.default_document_type); 177 187 178 188 return true; … … 644 654 protected Element createDocNode(String node_id) 645 655 { 646 Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 647 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 648 649 String doc_type = null; 650 if (default_document_type != null) 651 { 652 doc_type = default_document_type; 653 } 654 else 655 { 656 doc_type = getDocType(node_id); 657 } 658 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 659 String node_type = getNodeType(node_id, doc_type); 660 node.setAttribute(GSXML.NODE_TYPE_ATT, node_type); 661 return node; 656 return this.gs_doc.createDocNode(node_id); 662 657 } 663 658 … … 668 663 protected String getNodeType(String node_id, String doc_type) 669 664 { 670 if (doc_type.equals(GSXML.DOC_TYPE_SIMPLE)) 671 { 672 return GSXML.NODE_TYPE_LEAF; 673 } 674 675 if (getParentId(node_id) == null) 676 { 677 return GSXML.NODE_TYPE_ROOT; 678 } 679 if (doc_type.equals(GSXML.DOC_TYPE_PAGED)) 680 { 681 return GSXML.NODE_TYPE_LEAF; 682 } 683 if (getChildrenIds(node_id) == null) 684 { 685 return GSXML.NODE_TYPE_LEAF; 686 } 687 return GSXML.NODE_TYPE_INTERNAL; 688 665 return this.gs_doc.getNodeType(node_id, doc_type); 689 666 } 690 667 … … 734 711 parent_node.removeChild(current_node); 735 712 736 // add in all the siblings, 713 // add in all the siblings,- might be classifier/document nodes 737 714 addDescendants(parent_node, parent_id, false); 738 715 … … 743 720 Element new_current = GSXML.getNamedElement(parent_node, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id); 744 721 return new_current; 722 745 723 } 746 724 … … 758 736 protected ArrayList<String> getSiblingIds(String node_id) 759 737 { 760 String parent_id = getParentId(node_id); 761 if (parent_id == null) 762 { 763 return null; 764 } 765 return getChildrenIds(parent_id); 766 738 return this.gs_doc.getSiblingIds(node_id); 767 739 } 768 740 … … 778 750 * GSXML.DOC_TYPE_HIERARCHY 779 751 */ 780 abstract protected String getDocType(String node_id); 752 protected String getDocType(String node_id) { 753 return this.gs_doc.getDocType(node_id); 754 } 781 755 782 756 /** … … 784 758 * . may be the same as node_id 785 759 */ 786 abstract protected String getRootId(String node_id); 760 protected String getRootId(String node_id) { 761 return this.gs_doc.getRootId(node_id); 762 } 787 763 788 764 /** returns a list of the child ids in order, null if no children */ 789 abstract protected ArrayList<String> getChildrenIds(String node_id); 765 protected ArrayList<String> getChildrenIds(String node_id) { 766 return this.gs_doc.getChildrenIds(node_id); 767 } 790 768 791 769 /** returns the node id of the parent node, null if no parent */ 792 abstract protected String getParentId(String node_id); 770 protected String getParentId(String node_id) { 771 return this.gs_doc.getParentId(node_id); 772 } 793 773 794 774 /** … … 815 795 /** 816 796 * returns the structural information asked for. info_type may be one of 817 * INFO_NUM_SIBS, INFO_NUM_CHILDREN, INFO_SIB_POS 818 */ 819 abstract protected String getStructureInfo(String node_id, String info_type); 797 * INFO_NUM_SIBS, INFO_NUM_CHILDREN, INFO_SIB_POS, INFO_DOC_TYPE 798 */ 799 protected String getStructureInfo(String node_id, String info_type) { 800 return this.gs_doc.getStructureInfo(node_id, info_type); 801 } 820 802 821 803 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractDocumentRetrieve.java
r25818 r26046 24 24 import org.greenstone.util.GlobalProperties; 25 25 import org.greenstone.gsdl3.core.GSException; 26 import org.greenstone.gsdl3.util.AbstractBasicDocument; 27 import org.greenstone.gsdl3.util.BasicDocument; 26 28 import org.greenstone.gsdl3.util.GSXML; 27 29 import org.greenstone.gsdl3.util.GSPath; … … 67 69 protected static final String STRUCT_ENTIRE = "entire"; 68 70 69 protected static final String INFO_NUM_SIBS = "numSiblings"; 70 protected static final String INFO_NUM_CHILDREN = "numChildren"; 71 protected static final String INFO_SIB_POS = "siblingPosition"; 72 protected static final String INFO_DOC_TYPE = "documentType"; 71 72 protected AbstractBasicDocument gs_doc = null; 73 73 74 74 // means the id is not a greenstone id and needs translating … … 169 169 } 170 170 } 171 172 // Base line for document (might be overriden by sub-classes) 173 gs_doc = new BasicDocument(this.doc, this.default_document_type); 171 174 172 175 return true; … … 631 634 protected Element createDocNode(String node_id) 632 635 { 633 Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM); 634 node.setAttribute(GSXML.NODE_ID_ATT, node_id); 635 636 String doc_type = null; 637 if (default_document_type != null) 638 { 639 doc_type = default_document_type; 640 } 641 else 642 { 643 doc_type = getDocType(node_id); 644 } 645 node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type); 646 String node_type = getNodeType(node_id, doc_type); 647 node.setAttribute(GSXML.NODE_TYPE_ATT, node_type); 648 return node; 636 return this.gs_doc.createDocNode(node_id); 649 637 } 650 638 … … 655 643 protected void addDescendants(Element doc, String doc_id, boolean recursive) 656 644 { 657 ArrayList<String> child_ids = getChildrenIds(doc_id); 658 if (child_ids == null) 659 return; 660 for (int i = 0; i < child_ids.size(); i++) 661 { 662 String child_id = child_ids.get(i); 663 Element child_elem = createDocNode(child_id); 664 doc.appendChild(child_elem); 665 if (recursive && (!child_elem.getAttribute(GSXML.NODE_TYPE_ATT).equals(GSXML.NODE_TYPE_LEAF) || child_elem.getAttribute(GSXML.DOC_TYPE_ATT).equals(GSXML.DOC_TYPE_PAGED))) 666 { 667 addDescendants(child_elem, child_id, recursive); 668 } 669 } 645 this.gs_doc.addDescendants(doc, doc_id, recursive); 670 646 } 671 647 … … 676 652 protected Element addSiblings(Element parent_node, String parent_id, String current_id) 677 653 { 678 Element current_node = GSXML.getFirstElementChild(parent_node);//(Element)parent_node.getFirstChild(); 679 if (current_node == null) 680 { 681 // create a sensible error message 682 logger.error(" there should be a first child."); 683 return null; 684 } 685 // remove the current child,- will add it in later in its correct place 686 parent_node.removeChild(current_node); 687 688 // add in all the siblings, 689 addDescendants(parent_node, parent_id, false); 690 691 // find the node that is now the current node 692 // this assumes that the new node that was created is the same as 693 // the old one that was removed - we may want to replace the new one 694 // with the old one. 695 Element new_current = GSXML.getNamedElement(parent_node, current_node.getNodeName(), GSXML.NODE_ID_ATT, current_id); 696 return new_current; 654 return this.gs_doc.addSiblings(parent_node, parent_id, current_id); 697 655 } 698 656 … … 725 683 protected String getNodeType(String node_id, String doc_type) 726 684 { 727 if (doc_type.equals(GSXML.DOC_TYPE_SIMPLE)) 728 { 729 return GSXML.NODE_TYPE_LEAF; 730 } 731 732 if (getParentId(node_id) == null) 733 { 734 return GSXML.NODE_TYPE_ROOT; 735 } 736 if (doc_type.equals(GSXML.DOC_TYPE_PAGED)) 737 { 738 return GSXML.NODE_TYPE_LEAF; 739 } 740 if (getChildrenIds(node_id) == null) 741 { 742 return GSXML.NODE_TYPE_LEAF; 743 } 744 return GSXML.NODE_TYPE_INTERNAL; 745 746 } 747 748 /** 749 * if id ends in .fc, .pc etc, then translate it to the correct id default 750 * implementation: just remove the suffix 685 return this.gs_doc.getNodeType(node_id, doc_type); 686 } 687 688 /** 689 * if id ends in .fc, .pc etc, then translate it to the correct id 690 * default implementation: just remove the suffix 751 691 */ 752 692 protected String translateId(String id) … … 784 724 * returns the document type of the doc that the specified node belongs to. 785 725 * should be one of GSXML.DOC_TYPE_SIMPLE, GSXML.DOC_TYPE_PAGED, 786 * GSXML.DOC_TYPE_HIERARCHY default implementation: return DOC_TYPE_SIMPLE726 * GSXML.DOC_TYPE_HIERARCHY 787 727 */ 788 728 protected String getDocType(String node_id) 789 729 { 790 return GSXML.DOC_TYPE_HIERARCHY;730 return this.gs_doc.getDocType(node_id); 791 731 } 792 732 793 733 /** 794 734 * returns the id of the root node of the document containing node node_id. 795 * may be the same as node_id default implemntation: return node_id735 * may be the same as node_id 796 736 */ 797 737 protected String getRootId(String node_id) 798 738 { 799 return node_id; 800 } 801 802 /** 803 * returns a list of the child ids in order, null if no children default 804 * implementation: return null 739 return this.gs_doc.getRootId(node_id); 740 } 741 742 /** 743 * returns a list of the child ids in order, null if no children 805 744 */ 806 745 protected ArrayList<String> getChildrenIds(String node_id) 807 746 { 808 return null; 809 } 810 811 /** 812 * returns the node id of the parent node, null if no parent default 813 * implementation: return null 747 return this.gs_doc.getChildrenIds(node_id); 748 } 749 750 /** 751 * returns the node id of the parent node, null if no parent 814 752 */ 815 753 protected String getParentId(String node_id) 816 754 { 817 return null;755 return this.gs_doc.getParentId(node_id); 818 756 } 819 757 … … 834 772 * INFO_NUM_SIBS, INFO_NUM_CHILDREN, INFO_SIB_POS 835 773 */ 836 abstract protected String getStructureInfo(String doc_id, String info_type); 837 838 protected String getHrefOID(String href_url) 839 { 840 return null; 841 } 774 protected String getStructureInfo(String doc_id, String info_type) { 775 776 return this.gs_doc.getStructureInfo(doc_id, info_type); 777 } 778 842 779 843 780 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r26023 r26046 21 21 // Greenstone classes 22 22 import org.greenstone.gsdl3.core.GSException; 23 import org.greenstone.gsdl3.util.BasicDocumentDatabase; 23 24 import org.greenstone.gsdl3.util.GSXML; 24 25 import org.greenstone.gsdl3.util.GSFile; … … 63 64 64 65 protected SimpleCollectionDatabase coll_db = null; 65 66 BasicDocumentDatabase gs_doc_db = null; 66 67 /** constructor */ 67 68 protected AbstractGS2DocumentRetrieve() … … 74 75 super.cleanUp(); 75 76 this.coll_db.closeDatabase(); 77 this.gs_doc_db.cleanUp(); 76 78 } 77 79 … … 124 126 return false; 125 127 } 128 129 gs_doc_db = new BasicDocumentDatabase(this.doc, database_type, this.site_home, this.cluster_name, this.index_stem); 130 if (!gs_doc_db.isValid()) 131 { 132 logger.error("Failed to open Document Database."); 133 return false; 134 } 135 this.gs_doc = gs_doc_db; 126 136 127 137 // we need to set the database for our GS2 macro resolver … … 153 163 protected String getRootId(String node_id) 154 164 { 155 return OID.getTop(node_id); 156 } 157 158 /** returns a list of the child ids in order, null if no children */ 159 protected ArrayList<String> getChildrenIds(String node_id) 160 { 161 DBInfo info = this.coll_db.getInfo(node_id); 162 if (info == null) 163 { 164 return null; 165 } 166 167 String contains = info.getInfo("contains"); 168 if (contains.equals("")) 169 { 170 return null; 171 } 172 ArrayList<String> children = new ArrayList<String>(); 173 StringTokenizer st = new StringTokenizer(contains, ";"); 174 while (st.hasMoreTokens()) 175 { 176 String child_id = StringUtils.replace(st.nextToken(), "\"", node_id); 177 children.add(child_id); 178 } 179 return children; 180 181 } 182 183 /** returns the node id of the parent node, null if no parent */ 184 protected String getParentId(String node_id) 185 { 186 String parent = OID.getParent(node_id); 187 if (parent.equals(node_id)) 188 { 189 return null; 190 } 191 return parent; 192 } 165 return this.gs_doc.getRootId(node_id); 166 } 167 168 193 169 194 170 /** … … 236 212 } 237 213 238 /**239 * returns the structural information asked for. info_type may be one of240 * INFO_NUM_SIBS, INFO_NUM_CHILDREN, INFO_SIB_POS241 */242 protected String getStructureInfo(String doc_id, String info_type)243 {244 String value = "";245 if (info_type.equals(INFO_NUM_SIBS))246 {247 String parent_id = OID.getParent(doc_id);248 if (parent_id.equals(doc_id))249 {250 value = "0";251 }252 else253 {254 value = String.valueOf(getNumChildren(parent_id));255 }256 return value;257 }258 259 if (info_type.equals(INFO_NUM_CHILDREN))260 {261 return String.valueOf(getNumChildren(doc_id));262 }263 264 if (info_type.equals(INFO_SIB_POS))265 {266 String parent_id = OID.getParent(doc_id);267 if (parent_id.equals(doc_id))268 {269 return "-1";270 }271 272 DBInfo info = this.coll_db.getInfo(parent_id);273 if (info == null)274 {275 return "-1";276 }277 278 String contains = info.getInfo("contains");279 contains = StringUtils.replace(contains, "\"", parent_id);280 String[] children = contains.split(";");281 for (int i = 0; i < children.length; i++)282 {283 String child_id = children[i];284 if (child_id.equals(doc_id))285 {286 return String.valueOf(i + 1); // make it from 1 to length287 288 }289 }290 291 return "-1";292 }293 if (info_type.equals(INFO_DOC_TYPE))294 295 {296 return getDocType(doc_id);297 }298 return null;299 }300 214 301 215 protected int getNumChildren(String node_id) 302 216 { 303 DBInfo info = this.coll_db.getInfo(node_id); 304 if (info == null) 305 { 306 return 0; 307 } 308 String contains = info.getInfo("contains"); 309 if (contains.equals("")) 310 { 311 return 0; 312 } 313 String[] children = contains.split(";"); 314 return children.length; 315 } 316 317 /** 318 * returns the document type of the doc that the specified node belongs to. 319 * should be one of GSXML.DOC_TYPE_SIMPLE, GSXML.DOC_TYPE_PAGED, 320 * GSXML.DOC_TYPE_HIERARCHY 321 */ 322 protected String getDocType(String node_id) 323 { 324 DBInfo info = this.coll_db.getInfo(node_id); 325 if (info == null) 326 { 327 return GSXML.DOC_TYPE_SIMPLE; 328 } 329 String doc_type = info.getInfo("doctype"); 330 if (!doc_type.equals("") && !doc_type.equals("doc")) 331 { 332 return doc_type; 333 } 334 335 String top_id = OID.getTop(node_id); 336 boolean is_top = (top_id.equals(node_id) ? true : false); 337 338 String children = info.getInfo("contains"); 339 boolean is_leaf = (children.equals("") ? true : false); 340 341 if (is_top && is_leaf) 342 { // a single section document 343 return GSXML.DOC_TYPE_SIMPLE; 344 } 345 346 // now we just check the top node 347 if (!is_top) 348 { // we need to look at the top info 349 info = this.coll_db.getInfo(top_id); 350 } 351 if (info == null) 352 { 353 return GSXML.DOC_TYPE_HIERARCHY; 354 } 355 356 String childtype = info.getInfo("childtype"); 357 if (childtype.equals("Paged")) 358 { 359 return GSXML.DOC_TYPE_PAGED; 360 } 361 if (childtype.equals("PagedHierarchy")) 362 { 363 return GSXML.DOC_TYPE_PAGED_HIERARCHY; 364 } 365 return GSXML.DOC_TYPE_HIERARCHY; 366 } 217 return this.gs_doc.getNumChildren(node_id); 218 } 219 367 220 368 221 /** … … 591 444 } 592 445 593 protected Element getInfo(String doc_id, String info_type) 594 { 595 596 String value = ""; 597 if (info_type.equals(INFO_NUM_SIBS)) 598 { 599 String parent_id = OID.getParent(doc_id); 600 if (parent_id.equals(doc_id)) 601 { 602 value = "0"; 603 } 604 else 605 { 606 value = String.valueOf(getNumChildren(parent_id)); 607 } 608 } 609 else if (info_type.equals(INFO_NUM_CHILDREN)) 610 { 611 value = String.valueOf(getNumChildren(doc_id)); 612 } 613 else if (info_type.equals(INFO_SIB_POS)) 614 { 615 String parent_id = OID.getParent(doc_id); 616 if (parent_id.equals(doc_id)) 617 { 618 value = "-1"; 619 } 620 else 621 { 622 DBInfo info = this.coll_db.getInfo(parent_id); 623 if (info == null) 624 { 625 value = "-1"; 626 } 627 else 628 { 629 String contains = info.getInfo("contains"); 630 contains = StringUtils.replace(contains, "\"", parent_id); 631 String[] children = contains.split(";"); 632 for (int i = 0; i < children.length; i++) 633 { 634 String child_id = children[i]; 635 if (child_id.equals(doc_id)) 636 { 637 value = String.valueOf(i + 1); // make it from 1 to length 638 break; 639 } 640 } 641 } 642 } 643 } 644 else 645 { 646 return null; 647 } 648 Element info_elem = this.doc.createElement("info"); 649 info_elem.setAttribute(GSXML.NAME_ATT, info_type); 650 info_elem.setAttribute(GSXML.VALUE_ATT, value); 651 return info_elem; 652 } 653 654 protected String getHrefOID(String href_url) 655 { 656 return this.coll_db.docnum2OID(href_url); 657 } 446 658 447 659 448 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2TextSearch.java
r26042 r26046 18 18 package org.greenstone.gsdl3.service; 19 19 20 // Greenstone classes21 20 import java.util.ArrayList; 22 21 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Browse.java
r25967 r26046 26 26 27 27 import org.apache.log4j.Logger; 28 import org.greenstone.gsdl3.util.BasicDocumentDatabase; 28 29 import org.greenstone.gsdl3.util.DBInfo; 29 30 import org.greenstone.gsdl3.util.GS2MacroResolver; … … 45 46 46 47 protected SimpleCollectionDatabase coll_db = null; 47 48 BasicDocumentDatabase gs_doc_db = null; 48 49 public GS2Browse() 49 50 { … … 54 55 super.cleanUp(); 55 56 this.coll_db.closeDatabase(); 57 this.gs_doc_db.cleanUp(); 56 58 } 57 59 … … 88 90 database_type = "gdbm"; // the default 89 91 } 92 93 // do we still need this???? 90 94 coll_db = new SimpleCollectionDatabase(database_type); 91 95 if (!coll_db.databaseOK()) … … 103 107 } 104 108 this.macro_resolver = new GS2MacroResolver(this.coll_db); 109 110 gs_doc_db = new BasicDocumentDatabase(this.doc, database_type, this.site_home, this.cluster_name, index_stem); 111 if (!gs_doc_db.isValid()) 112 { 113 logger.error("Failed to open Document Database."); 114 return false; 115 } 116 this.gs_doc = gs_doc_db; 117 118 105 119 return true; 106 120 } … … 122 136 } 123 137 124 /** 125 * returns the document type of the doc that the specified node belongs to. 126 * should be one of GSXML.DOC_TYPE_SIMPLE, GSXML.DOC_TYPE_PAGED, 127 * GSXML.DOC_TYPE_HIERARCHY 128 */ 129 protected String getDocType(String node_id) 130 { 131 DBInfo info = this.coll_db.getInfo(node_id); 132 if (info == null) 133 { 134 return GSXML.DOC_TYPE_SIMPLE; 135 } 136 String doc_type = info.getInfo("doctype"); 137 if (!doc_type.equals("") && !doc_type.equals("doc")) 138 { 139 return doc_type; 140 } 141 142 String top_id = OID.getTop(node_id); 143 boolean is_top = (top_id.equals(node_id) ? true : false); 144 145 String children = info.getInfo("contains"); 146 boolean is_leaf = (children.equals("") ? true : false); 147 148 if (is_top && is_leaf) 149 { // a single section document 150 return GSXML.DOC_TYPE_SIMPLE; 151 } 152 153 // now we just check the top node 154 if (!is_top) 155 { // we need to look at the top info 156 info = this.coll_db.getInfo(top_id); 157 } 158 if (info == null) 159 { 160 return GSXML.DOC_TYPE_HIERARCHY; 161 } 162 163 String childtype = info.getInfo("childtype"); 164 if (childtype.equals("Paged")) 165 { 166 return GSXML.DOC_TYPE_PAGED; 167 } 168 if (childtype.equals("PagedHierarchy")) 169 { 170 return GSXML.DOC_TYPE_PAGED_HIERARCHY; 171 } 172 return GSXML.DOC_TYPE_HIERARCHY; 173 174 } 175 176 /** 177 * returns the id of the root node of the document containing node node_id. 178 * . may be the same as node_id 179 */ 180 protected String getRootId(String node_id) 181 { 182 return OID.getTop(node_id); 183 } 184 185 /** returns a list of the child ids in order, null if no children */ 186 protected ArrayList<String> getChildrenIds(String node_id) 187 { 188 DBInfo info = this.coll_db.getInfo(node_id); 189 if (info == null) 190 { 191 return null; 192 } 193 194 ArrayList<String> children = new ArrayList<String>(); 195 196 String contains = info.getInfo("contains"); 197 StringTokenizer st = new StringTokenizer(contains, ";"); 198 while (st.hasMoreTokens()) 199 { 200 String child_id = st.nextToken().replaceAll("\"", node_id); 201 children.add(child_id); 202 } 203 return children; 204 205 } 206 207 /** returns the node id of the parent node, null if no parent */ 208 protected String getParentId(String node_id) 209 { 210 String parent = OID.getParent(node_id); 211 if (parent.equals(node_id)) 212 { 213 return null; 214 } 215 return parent; 216 } 138 139 217 140 218 141 protected String getMetadata(String node_id, String key) … … 281 204 } 282 205 283 /**284 * returns the structural information asked for. info_type may be one of285 * INFO_NUM_SIBS, INFO_NUM_CHILDREN, INFO_SIB_POS286 */287 protected String getStructureInfo(String doc_id, String info_type)288 {289 String value = "";290 if (info_type.equals(INFO_NUM_SIBS))291 {292 String parent_id = OID.getParent(doc_id);293 if (parent_id.equals(doc_id))294 {295 value = "0";296 }297 else298 {299 value = String.valueOf(getNumChildren(parent_id));300 }301 return value;302 }303 304 if (info_type.equals(INFO_NUM_CHILDREN))305 {306 return String.valueOf(getNumChildren(doc_id));307 }308 309 if (info_type.equals(INFO_SIB_POS))310 {311 String parent_id = OID.getParent(doc_id);312 if (parent_id.equals(doc_id))313 {314 return "-1";315 }316 317 DBInfo info = this.coll_db.getInfo(parent_id);318 if (info == null)319 {320 return "-1";321 }322 323 String contains = info.getInfo("contains");324 contains = contains.replaceAll("\"", parent_id);325 String[] children = contains.split(";");326 for (int i = 0; i < children.length; i++)327 {328 String child_id = children[i];329 if (child_id.equals(doc_id))330 {331 return String.valueOf(i + 1); // make it from 1 to length332 333 }334 }335 336 return "-1";337 }338 else339 {340 return null;341 }342 343 }344 206 345 207 protected int getNumChildren(String node_id) 346 208 { 347 DBInfo info = this.coll_db.getInfo(node_id); 348 if (info == null) 349 { 350 return 0; 351 } 352 String contains = info.getInfo("contains"); 353 if (contains.equals("")) 354 { 355 return 0; 356 } 357 String[] children = contains.split(";"); 358 return children.length; 209 return this.gs_doc.getNumChildren(node_id); 359 210 } 360 211
Note:
See TracChangeset
for help on using the changeset viewer.