Changeset 11229


Ignore:
Timestamp:
2006-02-09T15:13:12+13:00 (18 years ago)
Author:
kjdon
Message:

first look for a format from the serviceRack element before using the default. Also added an 'all' opiton to the collection list

File:
1 edited

Legend:

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

    r11014 r11229  
    7373    this.short_service_info.appendChild(dmr_service);
    7474
    75     // add in the default format statement
    76     String format_info = "<format xmlns:gsf='http://www.greenstone.org/greenstone3/schema/ConfigFormat' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><gsf:template match='documentNode'><td><a><xsl:attribute name='href'>?a=d&amp;c=<xsl:value-of select='@collection'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test=\"@nodeType='leaf'\">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/>&amp;p.a=q&amp;&amp;p.s="+TEXT_QUERY_SERVICE+"&amp;p.c=";
    77     if (this.cluster_name!=null) {
    78         format_info += this.cluster_name;
    79     }
    80     format_info += "</xsl:attribute><gsf:icon/></a></td><td><gsf:metadata name='Title'/> (<xsl:value-of select='@collection'/>, rank:<xsl:value-of select='@rank'/>) </td></gsf:template></format>";
    81     this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(this.converter.getDOM(format_info).getDocumentElement(), true));
     75    // get any format info
     76    Element format_info = (Element)GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM);
     77    if (format_info != null) {
     78        this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(format_info, true));
     79    } else {
     80        // add in a default format statement
     81        String format_string = "<format xmlns:gsf='http://www.greenstone.org/greenstone3/schema/ConfigFormat' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><gsf:template match='documentNode'><td><a><xsl:attribute name='href'>?a=d&amp;c=<xsl:value-of select='@collection'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test=\"@nodeType='leaf'\">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/>&amp;p.a=q&amp;&amp;p.s="+TEXT_QUERY_SERVICE+"&amp;p.c=";
     82        if (this.cluster_name!=null) {
     83        format_string += this.cluster_name;
     84        }
     85        format_string += "</xsl:attribute><gsf:icon/></a></td><td><gsf:metadata name='Title'/> (<xsl:value-of select='@collection'/>) </td></gsf:template></format>";
     86        this.format_info_map.put(TEXT_QUERY_SERVICE, this.doc.importNode(this.converter.getDOM(format_string).getDocumentElement(), true));
     87    }
    8288    return true;
    8389    }
     
    104110            initCollectionList();
    105111        }
    106         Element param = GSXML.createParameterDescription(this.doc, COLLECTION_PARAM, getTextString("param."+COLLECTION_PARAM, lang), GSXML.PARAM_TYPE_ENUM_MULTI, null, coll_ids_list, coll_names_list);
     112        Element param = GSXML.createParameterDescription(this.doc, COLLECTION_PARAM, getTextString("param."+COLLECTION_PARAM, lang), GSXML.PARAM_TYPE_ENUM_MULTI, "all", coll_ids_list, coll_names_list);
    107113        param_list.appendChild(param);
    108114        // query param
     
    140146
    141147    // get the collection list
     148    String [] colls_list;
    142149    Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT,  COLLECTION_PARAM);
    143     String coll_list = GSXML.getValue(coll_param);
    144    
    145     String [] colls = coll_list.split(",");
     150    if (coll_param == null) {
     151        colls_list = coll_ids_list;
     152    } else {
     153        String coll_list = GSXML.getValue(coll_param);
     154        if (coll_list.equals("all") || coll_list.equals("")) {
     155        colls_list = coll_ids_list;
     156        } else {
     157        colls_list = coll_list.split(",");
     158        }
     159    }
     160   
    146161    Element query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    147162    // we are sending the same request to each collection - build up the to
    148163    // attribute for the request
    149164    StringBuffer to_att = new StringBuffer();
    150     for (int i=0; i<colls.length; i++) {
     165    for (int i=0; i<colls_list.length; i++) {
    151166        if (i>0) {
    152167        to_att.append(",");
    153168        }
    154         to_att.append(GSPath.appendLink(colls[i], "TextQuery"));
     169        to_att.append(GSPath.appendLink(colls_list[i], "TextQuery"));
    155170       
    156171    }
     
    266281        return false;
    267282    }
     283    valid_colls.add(0, "all");
     284    valid_coll_names.add(0, getTextString("param."+COLLECTION_PARAM+".all", "en" ));
    268285    this.coll_ids_list = new String[1];
    269286    this.coll_names_list = new String[1];
Note: See TracChangeset for help on using the changeset viewer.