Changeset 29090 for main/trunk


Ignore:
Timestamp:
2014-06-05T13:39:42+12:00 (10 years ago)
Author:
kjdon
Message:

added code for setting mdoffset attributes for docNodes in a classifier. Can be used to display the correct metadata value for the documents position in the classifier list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java

    r28966 r29090  
    359359        if (query_node_list == null)
    360360        {
    361             logger.error(" ClassifierBrowse request specified no doc nodes.\n");
     361            logger.error(" ClassifierBrowse request specified no classifier nodes.\n");
    362362            return result;
    363363        }
     
    677677    {
    678678        ArrayList<String> child_ids = getChildrenIds(node_id);
     679        String[] offsets = getMDOffsets(node_id);
    679680        if (child_ids == null)
    680681            return;
    681682        Document doc = node.getOwnerDocument();
     683        if (offsets != null && child_ids.size() != offsets.length) {
     684          offsets = null; // something is wrong, they should be the same length
     685        }
    682686        for (int i = 0; i < child_ids.size(); i++)
    683687        {
     
    687691            {
    688692              child_elem = createDocNode(doc, child_id);
     693              if (offsets != null) {
     694                child_elem.setAttribute("mdoffset", offsets[i]);
     695              }
    689696            }
    690697            else
     
    772779  }
    773780
     781  protected String[] getMDOffsets(String node_id) {
     782   
     783    String offset_str =  this.gs_doc.getMetadata(node_id, "mdoffset");
     784    if (offset_str.equals("")) {
     785      return null;
     786    }
     787    return offset_str.split(";"); //, -1); // use -1 limit to get trailing empty strings
     788  }
    774789    /** returns the node id of the parent node, null if no parent */
    775790  protected String getParentId(String node_id) {
Note: See TracChangeset for help on using the changeset viewer.