Changeset 4858


Ignore:
Timestamp:
2003-07-02T16:39:05+12:00 (21 years ago)
Author:
kjdon
Message:

simple doc types with no sections are returned a bit differently - have document/metadataList and nodeContent, rather than document/documentNode/metadataList and nodeContent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r4827 r4858  
    7070    }
    7171    String document_type = (String) params.get(DOC_TYPE_ARG);
     72    if (document_type == null) {
     73        document_type = "simple";
     74    }
    7275    //whether to retrieve siblings or not
    7376    boolean get_siblings = false;
     
    7982    // get the additional data needed for the page
    8083    getBackgroundData(page_response, collection, lang);
    81 
     84    Element format_elem = (Element)GSXML.getChildByTagName(page_response, GSXML.FORMAT_ELEM);
     85   
    8286    // the_document is where all the doc info - structure and metadata etc
    8387    // is added into, to be returned in the page
     
    137141    }
    138142
    139     boolean dummy_node = false;
     143    boolean has_dummy = false;
    140144    if (get_structure || get_structure_info) {
    141145
     
    178182        doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
    179183        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
    183188        // no structure request, so just put in a dummy doc node
    184189        Element doc_node = doc_.createElement(GSXML.DOC_NODE_ELEM);
    185190        doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
    186191        the_document.appendChild(doc_node);
    187         dummy_node = true;
     192        has_dummy = true;
    188193    }
    189194   
     
    194199    dm_message.appendChild(dm_request);
    195200    // 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);
    198209    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   
    204211    // create the doc node list for the metadata request
    205212    Element dm_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     
    269276
    270277    Element dc_response_message = (Element) mr_.process(dc_message);
    271    
    272278    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
    273279    Element dc_response_doc = (Element) GSXML.getNodeByPath(dc_response_message, path);
    274280    Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM);
     281   
    275282           
    276283    boolean highlight_query_terms = true;
     
    307314    String modified_doc_id = dc_response_doc.getAttribute(GSXML.NODE_ID_ATT);
    308315    the_document.setAttribute("selectedNode", modified_doc_id);
    309     if (dummy_node) {
     316    if (has_dummy) {
    310317        // 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        }
    313335    } else {
    314336        // Merge the document content with the metadata and structure information
     
    323345    }
    324346
    325     System.out.println("(DocumentAction) Page:\n" + converter_.getPrettyString(result));
     347    ///ystem.out.println("(DocumentAction) Page:\n" + converter_.getPrettyString(result));
    326348    return result;
    327349    }
Note: See TracChangeset for help on using the changeset viewer.