Changeset 4858
- Timestamp:
- 2003-07-02T16:39:05+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r4827 r4858 70 70 } 71 71 String document_type = (String) params.get(DOC_TYPE_ARG); 72 if (document_type == null) { 73 document_type = "simple"; 74 } 72 75 //whether to retrieve siblings or not 73 76 boolean get_siblings = false; … … 79 82 // get the additional data needed for the page 80 83 getBackgroundData(page_response, collection, lang); 81 84 Element format_elem = (Element)GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM); 85 82 86 // the_document is where all the doc info - structure and metadata etc 83 87 // is added into, to be returned in the page … … 137 141 } 138 142 139 boolean dummy_node= false;143 boolean has_dummy = false; 140 144 if (get_structure || get_structure_info) { 141 145 … … 178 182 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name); 179 183 the_document.appendChild(doc_node); 180 dummy_node = true; 181 } 182 } else { 184 has_dummy = true; 185 } 186 } else { // a simple type - we dont have a dummy node for simple 187 // should think about this more 183 188 // no structure request, so just put in a dummy doc node 184 189 Element doc_node = doc_.createElement(GSXML.DOC_NODE_ELEM); 185 190 doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name); 186 191 the_document.appendChild(doc_node); 187 dummy_node= true;192 has_dummy = true; 188 193 } 189 194 … … 194 199 dm_message.appendChild(dm_request); 195 200 // Create a parameter list to specify the required metadata information 196 // for now get Title 197 Element dm_param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 201 202 HashSet meta_names = new HashSet(); 203 meta_names.add("Title"); // the default 204 if (format_elem != null) { 205 extractMetadataNames(format_elem, meta_names); 206 } 207 208 Element dm_param_list = createMetadataParamList(meta_names); 198 209 dm_request.appendChild(dm_param_list); 199 Element dm_param = doc_.createElement(GSXML.PARAM_ELEM); 200 dm_param_list.appendChild(dm_param); 201 dm_param.setAttribute(GSXML.NAME_ATT, "metadata"); 202 dm_param.setAttribute(GSXML.VALUE_ATT, "all"); 203 210 204 211 // create the doc node list for the metadata request 205 212 Element dm_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); … … 269 276 270 277 Element dc_response_message = (Element) mr_.process(dc_message); 271 272 278 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM); 273 279 Element dc_response_doc = (Element) GSXML.getNodeByPath(dc_response_message, path); 274 280 Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM); 281 275 282 276 283 boolean highlight_query_terms = true; … … 307 314 String modified_doc_id = dc_response_doc.getAttribute(GSXML.NODE_ID_ATT); 308 315 the_document.setAttribute("selectedNode", modified_doc_id); 309 if ( dummy_node) {316 if (has_dummy) { 310 317 // change the id if necessary and add the content 311 ((Element)doc_nodes.item(0)).setAttribute(GSXML.NODE_ID_ATT, modified_doc_id); 312 doc_nodes.item(0).appendChild(doc_.importNode(dc_response_doc_content, true)); 318 Element dummy_node = (Element)doc_nodes.item(0); 319 320 dummy_node.setAttribute(GSXML.NODE_ID_ATT, modified_doc_id); 321 dummy_node.appendChild(doc_.importNode(dc_response_doc_content, true)); 322 // hack for simple type 323 if (document_type.equals("simple")) { 324 // we dont want the internal docNode, just want the content and metadata in the document 325 // rethink this!! 326 the_document.removeChild(dummy_node); 327 328 NodeList dummy_children = dummy_node.getChildNodes(); 329 //for (int i=0; i<dummy_children.getLength(); i++) { 330 for (int i=dummy_children.getLength()-1; i>=0; i--) { 331 the_document.appendChild(dummy_children.item(i)); 332 333 } 334 } 313 335 } else { 314 336 // Merge the document content with the metadata and structure information … … 323 345 } 324 346 325 System.out.println("(DocumentAction) Page:\n" + converter_.getPrettyString(result));347 ///ystem.out.println("(DocumentAction) Page:\n" + converter_.getPrettyString(result)); 326 348 return result; 327 349 }
Note:
See TracChangeset
for help on using the changeset viewer.