- Timestamp:
- 2003-03-20T13:51:14+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Search.java
r3862 r3938 26 26 // XML classes 27 27 import org.w3c.dom.Element; 28 import org.w3c.dom.Document; 28 29 import org.w3c.dom.NodeList; 29 30 … … 82 83 83 84 /** configure this service */ 84 public boolean configure(Element info )85 public boolean configure(Element info, Element extra_info) 85 86 { 86 87 System.out.println("Configuring GS2Search..."); 88 addExtraQueryInfo(info, extra_info); 87 89 config_info_ = info; 88 90 … … 119 121 } 120 122 123 // add some format info to service map if there is any 124 Element format = (Element) GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM); 125 if (format != null) { 126 format_info_map_.put(TEXT_QUERY_SERVICE, doc_.importNode(format, true)); 127 } 128 121 129 return true; 122 130 } 123 131 124 132 125 /** creates a new param element and adds it to the param list */ 133 protected boolean addExtraQueryInfo(Element info, Element extra_info){ 134 135 if (extra_info == null) { 136 return false; 137 } 138 139 Document owner = info.getOwnerDocument(); 140 // so far we have index specific display elements, and global format elements 141 NodeList indexes = info.getElementsByTagName(GSXML.INDEX_ELEM); 142 Element config_search = (Element)GSXML.getChildByTagName(extra_info, GSXML.SEARCH_ELEM); 143 144 for (int i=0; i<indexes.getLength();i++) { 145 Element ind = (Element)indexes.item(i); 146 String name = ind.getAttribute(GSXML.NAME_ATT); 147 Element node_extra = GSXML.getNamedElement(config_search, 148 GSXML.INDEX_ELEM, 149 GSXML.NAME_ATT, 150 name); 151 if (node_extra == null) { 152 System.out.println("haven't found extra info for index named "+name); 153 continue; 154 } 155 156 // get the display elements if any - displayName 157 NodeList display_names = node_extra.getElementsByTagName(GSXML.DISPLAYNAME_ELEM); 158 if (display_names !=null) { 159 Element display = owner.createElement(GSXML.DISPLAY_ELEM); 160 for (int j=0; j<display_names.getLength(); j++) { 161 Element e = (Element)display_names.item(j); 162 163 Element display_name = GSXML.createTextElement(owner, GSXML.DISPLAY_NAME_ELEM, GSXML.getNodeText(e)); 164 display_name.setAttribute(GSXML.LANG_ATT, e.getAttribute(GSXML.LANG_ATT)); 165 display.appendChild(display_name); 166 } 167 ind.appendChild(display); 168 } 169 } // for each index 170 171 // get the format element if any 172 Element format = (Element)GSXML.getChildByTagName(extra_info, 173 GSXML.FORMAT_ELEM); 174 if (format!=null) { // append to info 175 info.appendChild(owner.importNode(format, true)); 176 } 177 return true; 178 179 180 } 181 /** creates a new param element and adds it to the param list */ 126 182 protected void createParameter(String name, Element param_list, 127 183 boolean display, String lang)
Note:
See TracChangeset
for help on using the changeset viewer.