Changeset 26039 for main/trunk


Ignore:
Timestamp:
2012-07-31T11:30:08+12:00 (12 years ago)
Author:
kjdon
Message:

rank now optional for docNode as we will use these classes for browse/retrieve. getDocType now checks default_document_type

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/AbstractSimpleDocument.java

    r24395 r26039  
    3535    }
    3636
    37     /** create an element to go into the search results list. A node element
     37    /** create an element to go into a results list. A node element
    3838     * has the form
    39      * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy' rank='0.23'/>
     39     * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy'/>
     40     */
     41  public Element createDocNode(String node_id) {
     42    return createDocNode(node_id, null);
     43  }
     44    /** create an element to go into a results list. A node element
     45     * has the form
     46     * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy' [rank='0.23']/>
    4047     */
    4148    public Element createDocNode(String node_id, String rank) {
    4249    Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    4350    node.setAttribute(GSXML.NODE_ID_ATT, node_id);
    44     node.setAttribute(GSXML.NODE_RANK_ATT, rank);
     51    if (rank != null) {
     52      node.setAttribute(GSXML.NODE_RANK_ATT, rank);
     53    }
    4554    String doc_type = getDocType(node_id);
    4655    node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
     
    7988    GSXML.DOC_TYPE_SIMPLE,
    8089    GSXML.DOC_TYPE_PAGED,
     90    GSXML.DOC_TYPE_PAGEDHIERARCHY,
    8191    GSXML.DOC_TYPE_HIERARCHY
    8292    */
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/SimpleDocument.java

    r24395 r26039  
    3939    }
    4040
    41     /** create an element to go into the search results list. A node element
    42      * has the form
    43      * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy' rank='0.23'/>
    44      */
    45     public Element createDocNode(String node_id, String rank) {
    46     // override to provide version that checks 'default_document_type'
    47  
    48     Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    49     node.setAttribute(GSXML.NODE_ID_ATT, node_id);
    50     node.setAttribute(GSXML.NODE_RANK_ATT, rank);
    51     String doc_type = null;
    52     if (default_document_type != null) {
    53         doc_type = default_document_type;
    54     } else {
    55         doc_type = getDocType(node_id);
    56     }
    57     node.setAttribute(GSXML.DOC_TYPE_ATT, doc_type);
    58     String node_type = getNodeType(node_id, doc_type); 
    59     node.setAttribute(GSXML.NODE_TYPE_ATT, node_type);
    60     return node;
    61     }
    62 
    63 
    6441    /** returns the document type of the doc that the specified node
    6542    belongs to. should be one of
     
    6744    GSXML.DOC_TYPE_PAGED,
    6845    GSXML.DOC_TYPE_HIERARCHY
     46    GSXML.DOC_TYPE_PAGEDHIERARCHY
    6947    default implementation returns GSXML.DOC_TYPE_SIMPLE, over ride
    7048    if documents can be hierarchical
    7149    */
    7250    public String getDocType(String node_id) {
    73     return GSXML.DOC_TYPE_SIMPLE;
     51      if (default_document_type != null) {
     52    return default_document_type;
     53      }
     54      return GSXML.DOC_TYPE_SIMPLE;
    7455    }
    7556   
Note: See TracChangeset for help on using the changeset viewer.