Changeset 8823


Ignore:
Timestamp:
2004-12-16T12:02:20+13:00 (19 years ago)
Author:
kjdon
Message:

added functionality to specify document type (simple, hierarchy, paged etc) in the config file - needed for gsarch collection, whose ids have per.iods in them, and look like hierarchical ids, but aren't

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/service
Files:
2 edited

Legend:

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

    r8690 r8823  
    8383    protected GS2MacroResolver macro_resolver = null;
    8484
     85    protected String default_document_type = null;
    8586    /** constructor */
    8687    protected GS2Retrieve()
     
    125126    if (display_format != null) {
    126127        this.format_info_map.put(DOCUMENT_CONTENT_RETRIEVE_SERVICE, this.doc.importNode(display_format, true));
    127         // shoudl we make a copy?
     128        // should we keep a copy?
     129        // check for docType option.
     130        Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType");
     131        if (doc_type_opt != null) {
     132        String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT);
     133        if (!value.equals("")) {
     134            this.default_document_type = value;
     135        }
     136        }
    128137    }
    129138
     
    370379     * child is true is it definitely is a child of something - just for efficiency purposes */
    371380    protected Element createDocNode(String node_id, boolean parent, boolean child) {
    372    
    373381    // create this here or pass it in?
    374382    DBInfo info = this.gdbm_src.getInfo(node_id);
     
    376384    if (isClassifier(node_id)) {
    377385        node = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
     386        node.setAttribute(GSXML.NODE_ID_ATT, node_id);
     387        return node;
    378388        //String childtype = info.getInfo("childtype");
    379389        //String orientation="";
     
    384394        //}
    385395        //node.setAttribute(GSXML.CLASS_NODE_ORIENTATION_ATT, orientation);
     396    }
     397
     398   
     399    node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     400    node.setAttribute(GSXML.NODE_ID_ATT, node_id);
     401   
     402    String doc_type = null;
     403    if (default_document_type != null) {
     404        doc_type = default_document_type;
     405        node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
     406        if (doc_type.equals("simple")) {
     407        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     408        return node;
     409        }
     410    }
     411 
     412    String top_id = OID.getTop(node_id);
     413    boolean is_top = (top_id.equals(node_id) ? true : false);
     414   
     415    String children = info.getInfo("contains");
     416    boolean is_leaf = (children.equals("") ? true : false);
     417   
     418    // set the doc type att
     419    if (doc_type == null) {
     420        doc_type = info.getInfo("doctype");
     421        if (!doc_type.equals("")&&!doc_type.equals("doc")) {
     422        node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
     423        if (doc_type.equals("simple")) {
     424            node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     425            return node;
     426        }
     427        } else {
     428        if (is_top && is_leaf) { // a single section document
     429            node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
     430            node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     431            return node;
     432           
     433        }
     434       
     435        if (!is_top) { // we need to look at the top info
     436            info = this.gdbm_src.getInfo(top_id);
     437        }
     438       
     439        String childtype = info.getInfo("childtype");
     440        if (childtype.equals("Paged")) {
     441            node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");
     442        } else {
     443            node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");
     444        }
     445        }
     446       
     447    }
     448    // set the node type att
     449    if (doc_type.equals("simple")) {
     450        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
    386451    } else {
    387        
    388         node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    389 
    390         String top_id = OID.getTop(node_id);
    391         boolean is_top = (top_id.equals(node_id) ? true : false);
    392    
    393         String children = info.getInfo("contains");
    394         boolean is_leaf = (children.equals("") ? true : false);
    395        
    396         // set the node type att
    397452        if (is_top) {
    398453        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
     
    402457        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);
    403458        }
    404 
    405         // set the doc type att
    406         String doc_type = info.getInfo("doctype");
    407         if (!doc_type.equals("")&&!doc_type.equals("doc")) {
    408         node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
    409         } else {
    410         if (is_top && is_leaf) { // a single section document
    411             node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
    412        
    413         } else {
    414            
    415             if (!is_top) { // we need to look at the top info
    416             info = this.gdbm_src.getInfo(top_id);
    417             }
    418            
    419             String childtype = info.getInfo("childtype");
    420             if (childtype.equals("Paged")) {
    421             node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");
    422             } else {
    423             node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");
    424             }
    425         }
    426         }
    427        
    428     }
    429     node.setAttribute(GSXML.NODE_ID_ATT, node_id);
     459    }
     460   
     461   
     462   
    430463    return node;
    431464
     
    768801        if (extlink) {
    769802        if (OID.needsTranslating(node_id)) {
     803           
    770804            // just ignore the extension cos it has no meaning here
    771805            // or should it be added back on for the next step???
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Search.java

    r8572 r8823  
    7373    /** the default index */
    7474    protected String default_index = null;
    75 
     75   
     76    protected String default_document_type = null;
    7677
    7778    /** constructor */
     
    119120        this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(format, true));
    120121    }
    121        
     122     
     123    // look for document display format - for documentType
     124    String path = GSPath.appendLink(GSXML.DISPLAY_ELEM, GSXML.FORMAT_ELEM);
     125    Element display_format = (Element)GSXML.getNodeByPath(extra_info, path);
     126    if (display_format != null) {
     127        // check for docType option.
     128        Element doc_type_opt = GSXML.getNamedElement(display_format, "gsf:option", GSXML.NAME_ATT, "documentType");
     129        if (doc_type_opt != null) {
     130        String value = doc_type_opt.getAttribute(GSXML.VALUE_ATT);
     131        if (!value.equals("")) {
     132            this.default_document_type = value;
     133        }
     134        }
     135    }
     136
    122137    return true;
    123138    }
     
    248263    protected Element createDocumentNodeElement(String node_id)
    249264    {
    250     Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    251     doc_node.setAttribute(GSXML.NODE_ID_ATT, node_id);
    252 
     265
     266    Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     267    node.setAttribute(GSXML.NODE_ID_ATT, node_id);
     268   
     269    String doc_type = null;
     270    if (default_document_type != null) {
     271        doc_type = default_document_type;
     272        node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
     273        if (doc_type.equals("simple")) {
     274        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     275        return node;
     276        }
     277    }
     278 
    253279    String top_id = OID.getTop(node_id);
    254280    boolean is_top = (top_id.equals(node_id) ? true : false);
     
    256282    DBInfo info = this.gdbm_src.getInfo(node_id);
    257283    if (info == null) { // make it up - cant query the gdbm db
    258         doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
    259         return doc_node;
     284        node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
     285        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     286        return node;
    260287    }
    261288    String children = info.getInfo("contains");
    262289    boolean is_leaf = (children.equals("") ? true : false);
    263 
    264     // check for simple doc types
    265     if (is_top && is_leaf) { // a single section document
    266         doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
    267         return doc_node;
    268     }
    269     // set teh node type att
    270     if (is_top) {
    271         doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
    272     } else if (is_leaf) {
    273         doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     290   
     291    // set the doc type att
     292    if (doc_type == null) {
     293        doc_type = info.getInfo("doctype");
     294        if (!doc_type.equals("")&&!doc_type.equals("doc")) {
     295        node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
     296        if (doc_type.equals("simple")) {
     297            node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     298            return node;
     299        }
     300        } else {
     301        if (is_top && is_leaf) { // a single section document
     302            node.setAttribute(GSXML.DOC_TYPE_ATT, "simple");
     303            node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     304            return node;
     305           
     306        }
     307       
     308        if (!is_top) { // we need to look at the top info
     309            info = this.gdbm_src.getInfo(top_id);
     310        }
     311       
     312        String childtype = info.getInfo("childtype");
     313        if (childtype.equals("Paged")) {
     314            node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");
     315        } else {
     316            node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");
     317        }
     318        }
     319       
     320    }
     321    // set the node type att
     322    if (doc_type.equals("simple")) {
     323        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
    274324    } else {
    275         doc_node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);
    276     }
    277    
    278     if (!is_top) { // we need to look at the top info
    279         info = this.gdbm_src.getInfo(top_id);
    280     }
    281 
    282     String childtype = info.getInfo("childtype");
    283     if (childtype.equals("Paged")) {
    284         doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "paged");
    285     } else {
    286         doc_node.setAttribute(GSXML.DOC_TYPE_ATT, "hierarchy");
    287     }
    288     return doc_node;
     325        if (is_top) {
     326        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_ROOT);
     327        } else if (is_leaf) {
     328        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_LEAF);
     329        } else {
     330        node.setAttribute(GSXML.NODE_TYPE_ATT, GSXML.NODE_TYPE_INTERIOR);
     331        }
     332    }
     333    return node;
    289334    }
    290335   
Note: See TracChangeset for help on using the changeset viewer.