Ignore:
Timestamp:
2003-07-11T16:29:16+12:00 (21 years ago)
Author:
kjdon
Message:

tidied up a lot of stuff, particularly the display text stuff, including how its formatted, and some of the service rack methods

File:
1 edited

Legend:

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

    r4098 r4903  
    8484
    8585    // set up short_service_info_ - for now just has name and type
    86     Element tq_service = doc_.createElement(GSXML.SERVICE_ELEM);
    87     tq_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_ENRICH);
    88     tq_service.setAttribute(GSXML.NAME_ATT, GATE_POS_TAG_SERVICE);
    89     short_service_info_.appendChild(tq_service);
    90 
    91     // set up service_info_map_ - for now, just has the same elements as above
    92     // should have full details about each service incl params lists etc.
    93     Element tq_service_full = (Element) tq_service.cloneNode(true);
    94     Element param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    95     createParameter(ANNOTATION_TYPE_PARAM, param_list, false, null);
    96     tq_service_full.appendChild(param_list);
    97     service_info_map_.put(GATE_POS_TAG_SERVICE, tq_service_full);
    98 
    99     // add some format info to service map if there is any
    100     // Element format = (Element) GSXML.getChildByTagName(info, GSXML.FORMAT_ELEM);
    101     // if (format != null) {
    102     //     format_info_map_.put(GATE_POS_TAG_SERVICE, doc_.importNode(format, true));
    103     // }
     86    Element tag_service = doc_.createElement(GSXML.SERVICE_ELEM);
     87    tag_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_ENRICH);
     88    tag_service.setAttribute(GSXML.NAME_ATT, GATE_POS_TAG_SERVICE);
     89    short_service_info_.appendChild(tag_service);
     90
    10491
    10592    // Configure GATE for use
     
    141128    }
    142129
    143 
    144     /** creates a display element containing all the text strings needed to display
    145     the service page, in the language specified */
    146     protected Element createServiceDisplay(String service, String lang)
    147     {
    148     // Create a service display for the basic text query service
    149     Element display = doc_.createElement(GSXML.DISPLAY_ELEM);
    150     display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang)));
    151     display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang)));
    152 
    153     // now need to add in the params
    154     if (service.equals(GATE_POS_TAG_SERVICE)) {
    155         createParameter(ANNOTATION_TYPE_PARAM, display, true, lang);
    156     }
    157 
    158     return display;
     130    protected Element getServiceDescription(String service, String lang) {
     131
     132    if (!service.equals(GATE_POS_TAG_SERVICE)) {
     133        return null;
     134    }
     135    Element tag_service = doc_.createElement(GSXML.SERVICE_ELEM);
     136    tag_service.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_ENRICH);
     137    tag_service.setAttribute(GSXML.NAME_ATT, GATE_POS_TAG_SERVICE);
     138    tag_service.appendChild(GSXML.createDisplayTextElement(doc_, GSXML.DISPLAY_TEXT_NAME, getTextString(service+".name", lang)));
     139    tag_service.appendChild(GSXML.createDisplayTextElement(doc_, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(service+".submit", lang)));
     140    Element param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     141    createParameter(ANNOTATION_TYPE_PARAM, param_list, lang);
     142    tag_service.appendChild(param_list);
     143
     144    return tag_service;
    159145    }
    160146
     
    162148    /** creates a new param element and adds it to the param list */
    163149    protected void createParameter(String name, Element param_list,
    164                    boolean display, String lang)
     150                   String lang)
    165151    {
    166152    Element param = null;
    167153
    168154    if (name.equals(ANNOTATION_TYPE_PARAM)) {
    169         if (display) {
    170         int len = annotation_types_.length;
    171         String[] annotation_type_names = new String[len];
    172         for (int i = 0; i < len; i++) {
    173             annotation_type_names[i] = getTextString("param." + name + "." + annotation_types_[i], lang);
    174         }
    175        
    176         param = GSXML.createParameterDisplay(doc_, name, getTextString("param." + name, lang), annotation_types_, annotation_type_names);
     155        int len = annotation_types_.length;
     156        String[] annotation_type_names = new String[len];
     157        for (int i = 0; i < len; i++) {
     158        annotation_type_names[i] = getTextString("param." + name + "." + annotation_types_[i], lang);
    177159        }
    178         else {
    179         param = GSXML.createParameterDescription(doc_, name, GSXML.PARAM_TYPE_ENUM_MULTI, annotation_types_[0], annotation_types_);
    180         }
     160       
     161        param = GSXML.createParameterDescription(doc_, name, getTextString("param." + name, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, annotation_types_[0], annotation_types_, annotation_type_names);
     162        param_list.appendChild(param);
    181163    }
    182164   
    183     // Add the parameter to the list
    184     if (param != null) {
    185         param_list.appendChild(param);
    186     }   
    187     }
    188 
    189 
     165    }
     166   
     167   
    190168    protected Element processGatePOSTag(Element request)
    191169    {
Note: See TracChangeset for help on using the changeset viewer.