Changeset 5694


Ignore:
Timestamp:
2003-10-21T11:16:31+13:00 (21 years ago)
Author:
kjdon
Message:

added functionality for expand document and expand contents

File:
1 edited

Legend:

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

    r5401 r5694  
    8787        document_name = document_name+"."+sibling_num+".ss";
    8888    }
     89   
     90    boolean expand_document = false;
     91    String ed_arg = (String) params.get(GSParams.EXPAND_DOCUMENT);
     92    if (ed_arg != null && ed_arg.equals("1")) {
     93        expand_document = true;
     94    }
     95       
     96
     97    boolean expand_contents = false;
     98    if (expand_document) { // we always expand the contents with the text
     99        expand_contents = true;
     100    } else {
     101        String ec_arg = (String) params.get(GSParams.EXPAND_CONTENTS);
     102        if (ec_arg != null && ec_arg.equals("1")) {
     103        expand_contents = true;
     104        }
     105    }
    89106    // get the additional data needed for the page
    90107    getBackgroundData(page_response, collection, lang);
     
    129146    } else if (document_type.equals("hierarchy")){
    130147        get_structure = true;
    131         // get the info needed for table of contents
    132         ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
    133         ds_param_list.appendChild(ds_param);
    134         ds_param.setAttribute(GSXML.NAME_ATT, "structure");
    135         ds_param.setAttribute(GSXML.VALUE_ATT, "ancestors");
    136         ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
    137         ds_param_list.appendChild(ds_param);
    138         ds_param.setAttribute(GSXML.NAME_ATT, "structure");
    139         ds_param.setAttribute(GSXML.VALUE_ATT, "children");
    140         if (get_siblings) {
     148        if (expand_contents) {
    141149        ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
    142150        ds_param_list.appendChild(ds_param);
    143151        ds_param.setAttribute(GSXML.NAME_ATT, "structure");
    144         ds_param.setAttribute(GSXML.VALUE_ATT, "siblings");
     152        ds_param.setAttribute(GSXML.VALUE_ATT, "entire");
     153        } else {
     154        // get the info needed for table of contents
     155        ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     156        ds_param_list.appendChild(ds_param);
     157        ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     158        ds_param.setAttribute(GSXML.VALUE_ATT, "ancestors");
     159        ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     160        ds_param_list.appendChild(ds_param);
     161        ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     162        ds_param.setAttribute(GSXML.VALUE_ATT, "children");
     163        if (get_siblings) {
     164            ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
     165            ds_param_list.appendChild(ds_param);
     166            ds_param.setAttribute(GSXML.NAME_ATT, "structure");
     167            ds_param.setAttribute(GSXML.VALUE_ATT, "siblings");
     168        }
    145169        }
    146170    } else {
     
    280304    dc_request.appendChild(dc_param_list);
    281305
    282     // the doc list for the content request is the same as the one for the structure request
    283     dc_request.appendChild(basic_doc_list);
    284 
     306    // the doc list for the content request is the same as the one for the structure request unless we want the whole document, in which case its the same as for the metadata request.
     307    if (expand_document) {
     308        dc_request.appendChild(dm_doc_list);
     309    } else {
     310        dc_request.appendChild(basic_doc_list);
     311    }
    285312    Element dc_response_message = (Element) this.mr.process(dc_message);
    286     path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
    287     Element dc_response_doc = (Element) GSXML.getNodeByPath(dc_response_message, path);
    288     Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM);
     313    Element dc_response_doc_list = (Element) GSXML.getNodeByPath(dc_response_message, path);
     314
     315    if (expand_document) {
     316        // Merge the content with the structure information
     317        NodeList dc_response_docs = dc_response_doc_list.getChildNodes();
     318        for (int i = 0; i < doc_nodes.getLength(); i++) {
     319        doc_nodes.item(i).appendChild(this.doc.importNode(GSXML.getChildByTagName((Element)dc_response_docs.item(i), "nodeContent"), true));
     320        //GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
     321        }
     322    } else {
     323       
     324        //path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
     325        Element dc_response_doc = (Element) GSXML.getChildByTagName(dc_response_doc_list, GSXML.DOC_NODE_ELEM);
     326        Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM);
    289327   
    290328           
    291     boolean highlight_query_terms = true;
    292     if (highlight_query_terms) {
    293         dc_response_doc.removeChild(dc_response_doc_content);
    294        
    295         dc_response_doc_content = highlightQueryTerms(request, dc_response_doc_content);
    296         dc_response_doc.appendChild(dc_response_doc.getOwnerDocument().importNode(dc_response_doc_content, true));
    297     }
     329        boolean highlight_query_terms = true;
     330        if (highlight_query_terms) {
     331        dc_response_doc.removeChild(dc_response_doc_content);
     332       
     333        dc_response_doc_content = highlightQueryTerms(request, dc_response_doc_content);
     334        dc_response_doc.appendChild(dc_response_doc.getOwnerDocument().importNode(dc_response_doc_content, true));
     335        }
     336       
     337    /*
    298338    if (provide_annotations) {
    299339        String service_selected = (String)params.get(ENRICH_DOC_ARG);
     
    323363        }
    324364    }
     365
     366    */
    325367    // use the returned id rather than the sent one cos there may have
    326368    // been modifiers such as .pr that are removed.
     
    357399        }
    358400    }
    359 
     401    }
    360402    ///ystem.out.println("(DocumentAction) Page:\n" + this.converter.getPrettyString(result));
    361403    return result;
     
    383425    // these could all be cached
    384426    Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    385     String path = GSPath.appendLink(collection, "DocumentMetadataRetrieve");
     427    String path = GSPath.appendLink(collection, "DocumentContentRetrieve");
    386428    // the format request - ignore for now, where does this request go to??
    387429    Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, path, lang);
Note: See TracChangeset for help on using the changeset viewer.