Changeset 26046 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java
- Timestamp:
- 2012-07-31T15:22:22+12:00 (12 years ago)
- File:
-
- 1 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 }
Note:
See TracChangeset
for help on using the changeset viewer.