Changeset 3938
- Timestamp:
- 2003-03-20T13:51:14+12:00 (21 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java
r3901 r3938 57 57 58 58 /** configure this service */ 59 public boolean configure(Element info )59 public boolean configure(Element info, Element extra_info) 60 60 { 61 61 // Do specific configuration … … 74 74 75 75 // Do generic configuration 76 return super.configure(info );76 return super.configure(info, extra_info); 77 77 } 78 78 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
r3868 r3938 85 85 86 86 /** configure this service */ 87 public boolean configure(Element info )87 public boolean configure(Element info, Element extra_info) 88 88 { 89 89 // Do generic configuration 90 if (super.configure(info ) == false)90 if (super.configure(info, extra_info) == false) 91 91 return false; 92 92 93 93 // Do specific configuration 94 94 System.out.println("Configuring GS2MGPPSearch..."); … … 147 147 service_info_map_.put(ADVANCED_FIELD_QUERY_SERVICE, afq_service_full); 148 148 149 150 //set up format info - the info is the same as that for text query 151 Element format_info = (Element)format_info_map_.get(TEXT_QUERY_SERVICE); 152 if (format_info != null) { 153 format_info_map_.put(FIELD_QUERY_SERVICE, format_info); 154 format_info_map_.put(ADVANCED_FIELD_QUERY_SERVICE, format_info); 155 } 149 156 return true; 150 157 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
r3901 r3938 59 59 60 60 /** configure this service */ 61 public boolean configure(Element info )61 public boolean configure(Element info, Element extra_info) 62 62 { 63 63 // Do specific configuration … … 76 76 77 77 // Do generic configuration 78 return super.configure(info );78 return super.configure(info, extra_info); 79 79 } 80 80 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java
r3910 r3938 25 25 26 26 // XML classes 27 import org.w3c.dom.Document; 27 28 import org.w3c.dom.Element; 28 29 import org.w3c.dom.NodeList; … … 70 71 71 72 /** configure this service */ 72 public boolean configure(Element info )73 public boolean configure(Element info, Element extra_info) 73 74 { 74 75 System.out.println("Configuring GS2Retrieve..."); … … 113 114 } 114 115 116 // get the display and format elements from the coll config file for 117 // the classifiers 118 extractExtraClassifierInfo(info, extra_info); 119 config_info_ = info; 120 115 121 // short_service_info_ - the browse one 116 122 Element cb_service = doc_.createElement(GSXML.SERVICE_ELEM); … … 137 143 138 144 // the format info 139 Element cb_format_info = doc_.createElement(GSXML. STYLESHEET_ELEM);145 Element cb_format_info = doc_.createElement(GSXML.FORMAT_ELEM); 140 146 boolean format_found = false; 141 147 // add in to the description a simplified list of classifiers … … 172 178 } 173 179 180 /** this looks for any classifier specific display or format info from extra_info and adds it in to the correct place in info */ 181 protected boolean extractExtraClassifierInfo(Element info, Element extra_info) { 182 183 if (extra_info == null) { 184 return false; 185 } 186 187 Document owner = info.getOwnerDocument(); 188 // so far we have display and format elements that we need for classifiers 189 NodeList classifiers = info.getElementsByTagName(GSXML.CLASSIFIER_ELEM); 190 Element config_browse = (Element)GSXML.getChildByTagName(extra_info, GSXML.BROWSE_ELEM); 191 192 for (int i=0; i<classifiers.getLength();i++) { 193 Element cl = (Element)classifiers.item(i); 194 String name = cl.getAttribute(GSXML.NAME_ATT); 195 Element node_extra = GSXML.getNamedElement(config_browse, 196 GSXML.CLASSIFIER_ELEM, 197 GSXML.NAME_ATT, 198 name); 199 if (node_extra == null) { 200 System.out.println("haven't found extra info for classifier named "+name); 201 continue; 202 } 203 204 // get the display elements if any - displayName 205 NodeList display_names = node_extra.getElementsByTagName(GSXML.DISPLAYNAME_ELEM); 206 if (display_names !=null) { 207 Element display = owner.createElement(GSXML.DISPLAY_ELEM); 208 for (int j=0; j<display_names.getLength(); j++) { 209 Element e = (Element)display_names.item(j); 210 211 Element display_name = GSXML.createTextElement(owner, GSXML.DISPLAY_NAME_ELEM, GSXML.getNodeText(e)); 212 display_name.setAttribute(GSXML.LANG_ATT, e.getAttribute(GSXML.LANG_ATT)); 213 display.appendChild(display_name); 214 } 215 cl.appendChild(display); 216 } 217 218 // get the format element if any 219 Element format = (Element)GSXML.getChildByTagName(node_extra, GSXML.FORMAT_ELEM); 220 if (format==null) { // try a generic one that applies to all classifiers 221 format = (Element)GSXML.getChildByTagName(extra_info, 222 GSXML.FORMAT_ELEM); 223 } 224 if (format!=null) { // append to index info 225 cl.appendChild(owner.importNode(format, true)); 226 } 227 } // for each classifier 228 return true; 229 } 230 174 231 175 232 /** creates a display element containing all the text strings needed to display the service page, in the language specified -
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.