1 | /*
|
---|
2 | * GS2MGSearch.java
|
---|
3 | * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 | package org.greenstone.gsdl3.service;
|
---|
20 |
|
---|
21 | import org.greenstone.gsdl3.util.*;
|
---|
22 |
|
---|
23 | import org.w3c.dom.Document;
|
---|
24 | import org.w3c.dom.Node;
|
---|
25 | import org.w3c.dom.Text;
|
---|
26 | import org.w3c.dom.Element;
|
---|
27 | import org.w3c.dom.NodeList;
|
---|
28 | /**
|
---|
29 | *
|
---|
30 | * @author <a href="mailto:[email protected]">Katherine Don</a>
|
---|
31 | * @version $Revision: 3649 $
|
---|
32 | */
|
---|
33 |
|
---|
34 | public class GS2MGSearch
|
---|
35 | extends ServiceRack {
|
---|
36 |
|
---|
37 | // the services on offer
|
---|
38 | private static final String TEXT_QUERY_SERVICE = "TextQuery";
|
---|
39 |
|
---|
40 |
|
---|
41 | /** creates a display element containing all the text strings needed to display the service page, in the language specified */
|
---|
42 | protected Element createServiceDisplay(String service, String lang) {
|
---|
43 | Element display = doc_.createElement(GSXML.DISPLAY_ELEM);
|
---|
44 | display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang)));
|
---|
45 | display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang)));
|
---|
46 |
|
---|
47 | Element param;
|
---|
48 |
|
---|
49 | return display;
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | /** configure this service */
|
---|
54 | public boolean configure(Element info) {
|
---|
55 |
|
---|
56 | System.out.println("configuring GS2MGSearch");
|
---|
57 |
|
---|
58 | Element e = null;
|
---|
59 | // these entries should reflect the build config file - some services may not be available depending on how the colleciton was built.
|
---|
60 | // set up short_service_info_ - for now just has name and type
|
---|
61 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
62 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
63 | e.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE);
|
---|
64 | short_service_info_.appendChild(e);
|
---|
65 |
|
---|
66 | // set up service_info_map_ - for now, just has the same elements as above
|
---|
67 | // should have full details about each service incl params lists etc.
|
---|
68 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
69 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
70 | e.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE);
|
---|
71 | service_info_map_.put(TEXT_QUERY_SERVICE, e);
|
---|
72 |
|
---|
73 | return true;
|
---|
74 | }
|
---|
75 | /** process a text query */
|
---|
76 | protected Element processTextQuery(Element request) {
|
---|
77 | Element result = doc_.createElement(GSXML.RESPONSE_ELEM);
|
---|
78 | result.setAttribute(GSXML.NAME_ATT, TEXT_QUERY_SERVICE);
|
---|
79 |
|
---|
80 | // dummy result
|
---|
81 | Text t = null;
|
---|
82 | t = doc_.createTextNode(TEXT_QUERY_SERVICE+" result... ");
|
---|
83 | result.appendChild(t);
|
---|
84 | return result;
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | }
|
---|