Changeset 4719


Ignore:
Timestamp:
2003-06-18T12:47:30+12:00 (21 years ago)
Author:
kjdon
Message:

changed the doc node creation (for the docs in the result list) to add in doc type attribute, same as query results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Retrieve.java

    r4707 r4719  
    303303    /** parent is true if this node is definitely the  parent of something,
    304304     * child is true is it definitely is a child of something - just for efficiency purposes */
    305     protected Element createDocNode(String doc_id, boolean parent, boolean child) {
     305    protected Element createDocNode(String node_id, boolean parent, boolean child) {
    306306   
    307307    // create this here or pass it in?
    308     DBInfo db_info = gdbm_src_.getInfo(doc_id);
     308    DBInfo info = gdbm_src_.getInfo(node_id);
    309309    Element node;
    310     if (isClassifier(doc_id)) {
     310    if (isClassifier(node_id)) {
    311311        node = doc_.createElement(GSXML.CLASS_NODE_ELEM);
    312         String childtype = db_info.getInfo("childtype");
     312        String childtype = info.getInfo("childtype");
    313313        String orientation="";
    314314        if (childtype.equals("HList")) {
     
    319319        node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation);
    320320    } else {
     321       
    321322        node = doc_.createElement(GSXML.DOC_NODE_ELEM);
    322         if (/*!child &&*/ OID.isTop(doc_id)) {
     323
     324        String top_id = OID.getTop(node_id);
     325        boolean is_top = (top_id.equals(node_id) ? true : false);
     326   
     327        String children = info.getInfo("contains");
     328        boolean is_leaf = (children.equals("") ? true : false);
     329       
     330        // set teh node type att
     331        if (is_top) {
    323332        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
    324         } else if (!parent && isLeafNode(doc_id)) {
     333        } else if (is_leaf) {
    325334        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
    326335        } else {
    327336        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);
    328337        }
    329     }
    330     node.setAttribute(GSXML.NODE_ID_ATT, doc_id);
     338
     339        // set teh doc type att
     340        if (is_top && is_leaf) { // a single section document
     341        node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
     342       
     343        } else {
     344       
     345        if (!is_top) { // we need to look at the top info
     346            info = gdbm_src_.getInfo(top_id);
     347        }
     348       
     349        String childtype = info.getInfo("childtype");
     350        if (childtype.equals("Paged")) {
     351            node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");
     352        } else {
     353            node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");
     354        }
     355        }
     356       
     357    }
     358    node.setAttribute(GSXML.NODE_ID_ATT, node_id);
    331359    return node;
    332360
Note: See TracChangeset for help on using the changeset viewer.