Ignore:
Timestamp:
2011-07-14T21:39:43+12:00 (13 years ago)
Author:
ak19
Message:

Commits for ticket 770 concerning the display of multiple values for a metadata (like dc.Title) when classified by that metadata. So when the user browses by dc.Title, they no longer merely see a doc listed once for each dc.Title assigned but under the same (first retrieved) dc.Title, but they should now see the doc listed once for each dc.Title assigned to it with a different dc.Title value each time.

File:
1 edited

Legend:

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

    r23050 r24254  
    574574     * <docNode nodeId='xxx' nodeType='leaf' docType='hierarchy'/>
    575575     */
    576     protected Element createDocNode(String node_id) {
     576    protected Element createDocNode(String node_id, int offset) {
    577577    Element node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    578578    node.setAttribute(GSXML.NODE_ID_ATT, node_id);
     
    587587    String node_type = getNodeType(node_id, doc_type); 
    588588    node.setAttribute(GSXML.NODE_TYPE_ATT, node_type);
     589   
     590    // mdoffset information stored in DB determines which of multiple values for
     591    // a metadata needs to be displayed when a classifier is built on that metadata
     592    node.setAttribute(GSXML.NODE_MDOFFSET_ATT, Integer.toString(offset));
    589593    return node;
    590594    }
     
    621625    ArrayList child_ids = getChildrenIds(node_id);
    622626    if (child_ids==null) return;
     627   
     628    // get a list of all mdoffsets at this point
     629    ArrayList child_offsets = getOffsetsForChildrenIds(node_id);
     630    // make sure that if it's doesn't match up with child_ids in length,
     631    // it is padded with 0s to make up the length
     632    if(child_offsets == null) {
     633        child_offsets = new ArrayList(child_ids.size());
     634    }
     635    if(child_offsets.size() < child_ids.size()) {
     636        Integer zero = new Integer(0);
     637        for(int i = child_offsets.size()-1; i < child_ids.size(); i++) {
     638        child_offsets.add(zero);
     639        }
     640    }
     641
    623642    for (int i=0; i< child_ids.size(); i++) {
    624643        String child_id = (String)child_ids.get(i);
     644        int child_offset = ((Integer)child_offsets.get(i)).intValue(); // counts both docnodes and classnodes at the childlevel, is this right?
    625645        Element child_elem;
    626646        if (isDocumentId(child_id)) {
    627         child_elem = createDocNode(child_id);
     647        child_elem = createDocNode(child_id, child_offset);
    628648        } else {
    629649        child_elem = createClassifierNode(child_id);
     
    684704    }
    685705
     706    /** Override to get a list of mdoffsets of children. Return null if no children or if no mdoffsets for them */
     707    protected ArrayList getOffsetsForChildrenIds(String node_id) {
     708    return null;
     709    }
     710
    686711    /** if id ends in .fc, .pc etc, then translate it to the correct id */
    687712    abstract protected String translateId(String node_id);
Note: See TracChangeset for help on using the changeset viewer.