Changeset 4861
- Timestamp:
- 2003-07-02T16:42:36+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java
r4719 r4861 310 310 if (isClassifier(node_id)) { 311 311 node = doc_.createElement(GSXML.CLASS_NODE_ELEM); 312 String childtype = info.getInfo("childtype");313 String orientation="";314 if (childtype.equals("HList")) {315 orientation = "horizontal";316 } else { // assume vertical317 orientation = "vertical";318 }319 node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation);312 //String childtype = info.getInfo("childtype"); 313 //String orientation=""; 314 //if (childtype.equals("HList")) { 315 // orientation = "horizontal"; 316 //} else { // assume vertical 317 // orientation = "vertical"; 318 //} 319 //node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation); 320 320 } else { 321 321 … … 712 712 for (int m = 0; m < metadata_list.size(); m++) { 713 713 String metadata = (String) metadata_list.get(m); 714 String value = info.getInfo(metadata);714 String value = getMetadata(node_id, info, metadata); 715 715 GSXML.addMetadata(doc_, node_meta_list, metadata, value); 716 716 } 717 717 } 718 //String v = getMetadata (node_id, info, "parent_Title"); 719 //System.out.println("parent title = "+v); 720 //v = getMetadata (node_id, info, "ancestors': '_Title"); 721 //System.out.println("ancestortitle = "+v); 718 722 } 719 723 … … 721 725 } 722 726 723 727 protected final char RELATION_SEP_CHAR = '_'; 728 protected final String SEPARATOR_SEP_STRING = "'"; 729 730 protected String getMetadata(String node_id, DBInfo info, 731 String metadata) { 732 int pos = metadata.indexOf(RELATION_SEP_CHAR); 733 if (pos ==-1) { 734 return info.getInfo(metadata); 735 } 736 737 String relation = metadata.substring(0, pos); 738 if (relation.equals("parent") || relation.startsWith("ancestors")) { 739 String parent_id = OID.getParent(node_id); 740 if (parent_id.equals(node_id)){ 741 // no parents or ancestors 742 return ""; 743 } 744 DBInfo parent_info = gdbm_src_.getInfo(parent_id); 745 if (parent_info == null) return ""; 746 String new_meta = metadata.substring(pos+1); 747 if (relation.equals("parent")) { 748 return parent_info.getInfo(new_meta); 749 } 750 // do ancestor stuff 751 // get teh separating string 752 String items [] = relation.split(SEPARATOR_SEP_STRING); 753 String separator = ""; 754 if (items.length > 1) { 755 separator = items[1]; 756 relation = items[0]; 757 } 758 759 StringBuffer value = new StringBuffer(); 760 value.append(parent_info.getInfo(new_meta)); 761 String current_id = parent_id; 762 parent_id = OID.getParent(current_id); 763 while (!parent_id.equals(current_id)) { 764 parent_info = gdbm_src_.getInfo(parent_id); 765 if (parent_info == null) return value.toString(); 766 value.insert(0, separator); 767 value.insert(0, parent_info.getInfo(new_meta)); 768 769 current_id = parent_id; 770 parent_id = OID.getParent(current_id); 771 } 772 773 return value.toString(); 774 } 775 776 777 // its not a relation after all 778 return info.getInfo(metadata); 779 780 } 781 724 782 /** Retrieve the content of a document - implemented by concrete subclasses */ 725 783 protected abstract Element processDocumentContentRetrieve(Element request);
Note:
See TracChangeset
for help on using the changeset viewer.