Changeset 3895


Ignore:
Timestamp:
2003-03-18T15:01:35+12:00 (21 years ago)
Author:
kjdon
Message:

tidied up a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r3868 r3895  
    5252        return null;
    5353    }
     54    Document style_doc = converter_.getDOM(new File(stylesheet));
     55
     56    // part of the data for the page is the cgi-params
     57    // if we have this here, do we need to overwrite default values in the
     58    // param list down below??
     59    Element cgi_request = (Element)doc_.importNode(request, true);
     60    page.appendChild(cgi_request);
    5461
    5562    // extract the params from the cgi-request, and check that we have a coll specified
    5663    Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    57    
    5864    HashMap params = GSXML.extractParams(cgi_param_list, false);
    5965   
     
    6571        return null;
    6672    }
    67 
    68     // get the service info from the MR - this will probably need to be cached somehow later on. and add the service node to the page
    69     Element mr_info_message = doc_.createElement(GSXML.MESSAGE_ELEM);
    70     Element mr_info_request = doc_.createElement(GSXML.REQUEST_ELEM);
    71     mr_info_message.appendChild(mr_info_request);
    72     mr_info_request.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_DESCRIBE);
    73     mr_info_request.setAttribute(GSXML.LANG_ATT, page.getAttribute(GSXML.LANG_ATT));
    74 
    75     String to = collection;
    76     to = GSPath.appendLink(to, service_name);
    77     mr_info_request.setAttribute(GSXML.TO_ATT, to);
    78 
     73   
     74    String lang = request.getAttribute(GSXML.LANG_ATT);
     75    String to = GSPath.appendLink(collection, service_name);
     76
     77    // the second part of the page is the service description
     78    // for now get this again from the service.
     79    // this will probably need to be cached somehow later on.
     80    Element mr_info_message = createDescribeRequest(to, lang, null);
    7981    Element mr_info_response = (Element) mr_.process(mr_info_message);
    80     String path = GSXML.RESPONSE_ELEM;
    81     path = GSPath.appendLink(path, GSXML.SERVICE_ELEM);
     82   
     83    String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
    8284    Element description = (Element)doc_.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
    8385    Element pl = (Element)GSXML.getChildByTagName(description, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    8486   
    8587    if (pl !=null) {
    86         System.out.println("adding shortnames");
    8788        // add short names to the params in the param list
    8889        cgi_.paramListAddShortNames(pl);
     
    116117    }
    117118   
    118     // part of the data for the description is the cgi-params
    119     // if we have this here, do we need to do the previous step?
    120     Element cgi_request = (Element)doc_.importNode(request, true);
    121     page.appendChild(cgi_request);
    122 
     119    // append the description to the page
    123120    page.appendChild(description);
    124 
     121   
    125122    // just a display request
    126123    if (request_type.equals("d")) {
    127124        // output the page
    128125        // process using the stylesheet
    129         Document style_doc = converter_.getDOM(new File(stylesheet));
    130126        GSXSLT.absoluteIncludePaths(style_doc, config_);
    131127        return (Element)transformer_.transform(style_doc, page);   
    132128    }
    133        
     129   
    134130    // do the query
    135131    Element mr_query_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     
    145141       
    146142       
    147     System.out.println("Query request: " + converter_.getString(mr_query_request));
     143    //System.out.println("Query request: " + converter_.getString(mr_query_request));
    148144    Element mr_query_response = (Element)mr_.process(mr_query_message);
    149     System.out.println("Query response: " + converter_.getString(mr_query_response));
     145    //System.out.println("Query response: " + converter_.getString(mr_query_response));
    150146
    151147    Element query_result_metadata_list = (Element) GSXML.getNodeByPath(mr_query_response, "response/metadataList");
     
    154150    }
    155151
    156     Element query_term_info_list = (Element) GSXML.getNodeByPath(mr_query_response, "response/content/termList");
     152    Element query_term_info_list = (Element) GSXML.getNodeByPath(mr_query_response, "response/termList");
    157153    if (query_term_info_list == null) {
    158154        System.err.println("Warning: No query term information.\n");
     
    165161   
    166162    // check that there are some documents - for now check the list, but later should use a numdocs metadata elem
    167     path = GSXML.RESPONSE_ELEM;
    168     //path = GSPath.appendLink(path, GSXML.CONTENT_ELEM);
    169     path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     163    path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    170164   
    171165    Element document_list = (Element)GSXML.getNodeByPath(mr_query_response,
    172                                  path); // documentList not present if no docs found
     166                                 path);
     167    // documentList not present if no docs found
    173168    if (document_list == null) {
    174169       
     
    177172        page.appendChild(doc_.importNode(result_response, true));
    178173       
    179         Document style_doc = converter_.getDOM(new File(stylesheet));
    180174        GSXSLT.absoluteIncludePaths(style_doc, config_);
    181175        return (Element)transformer_.transform(style_doc, page);   
     
    202196    dm_param.setAttribute(GSXML.VALUE_ATT, "Title");
    203197
    204     //Element meta_content = doc_.createElement(GSXML.CONTENT_ELEM);
    205     //mr_metadata_request.appendChild(meta_content);
    206    
    207     // the first part of the content is the doc list
    208     //meta_content.appendChild(doc_.importNode(document_list, true));
    209198    mr_metadata_request.appendChild(doc_.importNode(document_list, true));
    210199    // System.out.println("Metadata request: " + converter_.getString(mr_metadata_message));
     
    219208    // If there is some metadata about the query results, add it in
    220209    if (query_term_info_list != null) {
    221         //Element result_content = (Element) GSXML.getChildByTagName(result_response, GSXML.CONTENT_ELEM);
    222         //result_content.appendChild(query_term_info_list);
    223210        result_response.appendChild(query_term_info_list);
    224211    }
     
    226213    page.appendChild(doc_.importNode(result_response, true));
    227214   
    228     System.out.println("XMLTransformer input: " + converter_.getString(page));
     215    System.out.println("Query XMLTransformer input:\n " + converter_.getString(page));
    229216   
    230217    // output the page
    231218    // process using the stylesheet
    232     Document style_doc = converter_.getDOM(new File(stylesheet));
    233219    GSXSLT.absoluteIncludePaths(style_doc, config_);
    234     // Node temp = transformer_.transform(style_doc, page);
    235         // System.out.println("XMLTransformer output: " + converter_.getString(temp));
    236     // return (Element) temp;
    237220    return (Element)transformer_.transform(style_doc, page);
    238221   
    239222    }
    240 
    241 
    242223}
Note: See TracChangeset for help on using the changeset viewer.