Changeset 4189


Ignore:
Timestamp:
2003-04-17T15:26:50+12:00 (21 years ago)
Author:
kjdon
Message:

added a bit more info to the page data, now looks for sibling arg

File:
1 edited

Legend:

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

    r4144 r4189  
    1717   
    1818    public static final String CLASSIFIER_ARG = "cl";
    19 
     19    public static final String SIBLING_ARG = "sib";
    2020    /* add the action specific args to the cgi param list
    2121     */
     
    6767    }
    6868   
     69    //whether to retrieve siblings or not
     70    boolean get_siblings = false;
     71    String sibs = (String) params.get(SIBLING_ARG);
     72    if (sibs != null && sibs.equals("1")) {
     73        get_siblings = true;
     74    }
     75
    6976    // the main response for the page is in a pageResponse element
    7077    Element page_response = doc_.createElement(GSXML.PAGE_RESPONSE_ELEM);
     
    114121    }
    115122   
    116     // create a classifier elem to return in the page
    117     Element page_classifier = doc_.createElement(GSXML.CLASSIFIER_ELEM);
    118     page_response.appendChild(page_classifier);
    119 
    120123    // the id of the classifier is the top id of the selected node
    121124    String top_id = OID.getTop(classifier_node);
    122     page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
    123125
    124126    // add in the format info into the stylesheet
    125     System.out.println("transforming format:"+converter_.getString(format_response));
     127    //System.out.println("transforming format:"+converter_.getString(format_response));
    126128    Element format_elem = getAndTransformFormat(format_response);
    127     System.out.println("transformed format:"+converter_.getString(format_elem));
     129    //System.out.println("transformed format:"+converter_.getString(format_elem));
    128130    if (format_elem != null) {
    129131        Element this_format = GSXML.getNamedElement(format_elem, GSXML.CLASSIFIER_ELEM, GSXML.NAME_ATT, top_id);
     
    155157    param.setAttribute(GSXML.NAME_ATT, "structure");
    156158    param.setAttribute(GSXML.VALUE_ATT, "children");
     159    if (get_siblings) {
     160        param = doc_.createElement(GSXML.PARAM_ELEM);
     161        param_list.appendChild(param);
     162        param.setAttribute(GSXML.NAME_ATT, "structure");
     163        param.setAttribute(GSXML.VALUE_ATT, "siblings");
     164    }
    157165
    158166    // put the classifier node into a classifier node list
     
    169177    path = GSPath.appendLink(path, GSXML.CLASS_NODE_ELEM);
    170178    path = GSPath.appendLink(path, GSXML.NODE_STRUCTURE_ELEM);
    171     // assume that we always get back the top level CL1 node - want to throw this away
     179    // assume that we always get back the top level CL1 node - this becomes the page_classifier node
    172180    path = GSPath.appendLink(path, GSXML.CLASS_NODE_ELEM);
    173181    Element cl_structure = (Element)GSXML.getNodeByPath(classify_response,
     
    181189    }   
    182190   
    183     // add the classifier nodes from the structure request into teh page_classifier
    184     NodeList cl_nodes = cl_structure.getChildNodes();
    185     for (int i=0; i<cl_nodes.getLength(); i++) {
    186         Node n = cl_nodes.item(i);
    187         if (n.getNodeType() == Node.TEXT_NODE) {
    188         // ignore
    189         continue;
    190         }
    191         page_classifier.appendChild(doc_.importNode(n, true));
    192     }
    193 
     191    // add the classifier node as the page classifier
     192    Element page_classifier = GSXML.duplicateWithNewName(doc_, cl_structure,  GSXML.CLASSIFIER_ELEM, true);
     193    page_response.appendChild(page_classifier);
     194    page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
    194195   
    195196    // get the metadata for each classifier node,
     
    205206    // create a metadata request for the classifier, and add it to
    206207    // the the message
    207     cl_nodes = page_classifier.getElementsByTagName(GSXML.CLASS_NODE_ELEM);
     208    NodeList cl_nodes = page_classifier.getElementsByTagName(GSXML.CLASS_NODE_ELEM);
    208209   
    209210    if (cl_nodes.getLength() > 0) {
     
    304305       
    305306
    306     //System.out.println("(BrowseAction) Page:\n" + converter_.getPrettyString(page));
     307    System.out.println("(BrowseAction) Page:\n" + converter_.getPrettyString(page));
    307308
    308309    // transform the page
Note: See TracChangeset for help on using the changeset viewer.