Statistics
| Revision:

root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / drivers / ADLGazetteerServiceDriver.java @ 3069

History | View | Annotate | Download (4.81 KB)

1 2921 jorpiell
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*
19
* For more information, contact:
20
*
21
*  Generalitat Valenciana
22
*   Conselleria d'Infraestructures i Transport
23
*   Av. Blasco Ib??ez, 50
24
*   46010 VALENCIA
25
*   SPAIN
26
*
27
*      +34 963862235
28
*   gvsig@gva.es
29
*      www.gvsig.gva.es
30
*
31
*    or
32
*
33
*   IVER T.I. S.A
34
*   Salamanca 50
35
*   46005 Valencia
36
*   Spain
37
*
38
*   +34 963163400
39
*   dac@iver.es
40
*/
41
package es.gva.cit.gazetteer.drivers;
42
43
import java.net.URL;
44
45
import org.w3c.dom.Node;
46
47 3069 jorpiell
import es.gva.cit.gazetteer.parsers.adl.AdlCapabilitiesParser;
48
import es.gva.cit.gazetteer.parsers.adl.AdlFeatureParser;
49 2932 jorpiell
import es.gva.cit.gazetteer.protocols.ADLPOSTProtocol;
50 2953 jorpiell
import es.gva.cit.gazetteer.querys.ADLQuery;
51 3069 jorpiell
import es.gva.cit.gazetteer.querys.Feature;
52 2921 jorpiell
import es.gva.cit.gazetteer.querys.Query;
53 3069 jorpiell
import es.gva.cit.gazetteer.querys.ThesaurusName;
54 2921 jorpiell
55 2955 jorpiell
56 2921 jorpiell
/**
57
 * This class implements the driver to connect with a ADL gazetteer service
58
 *
59 2953 jorpiell
 * @see http://alexandria.sdc.ucsb.edu/
60 2921 jorpiell
 * @author Jorge Piera Llodra (piera_jor@gva.es)
61
 */
62
public class ADLGazetteerServiceDriver extends AsbtractGazetteerServiceDriver{
63 2955 jorpiell
    /**
64
     * It invokes the getCapabilities operation
65
     */
66 2921 jorpiell
    public Node[] getCapabilities(URL url) {
67 2932 jorpiell
        Node[] nodes = null;
68
69 2955 jorpiell
       System.out.println("**************POST*************");
70
       nodes = new ADLPOSTProtocol().doQuery(url,
71
               getPOSTMessageCapabilities(), 0);
72 2953 jorpiell
73 2955 jorpiell
       return nodes;
74 2921 jorpiell
    }
75
76 2932 jorpiell
    /**
77
     * It creates the XML for the getCapabilities request
78
     *
79
     * @return
80
     * Name-value pair with a XML request
81
     */
82 2955 jorpiell
    private String getPOSTMessageCapabilities() {
83 2932 jorpiell
        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
84
                "<gazetteer-service " +
85
                "xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
86
                "version=\"1.2\">" +
87
                "<get-capabilities-request/>" +
88
                "</gazetteer-service>";
89
90
    }
91
92 2955 jorpiell
    /**
93
     * It invokes the getFeature operation
94 2921 jorpiell
     */
95 2955 jorpiell
96 2921 jorpiell
    public Node[] getFeature(URL url, Query query) {
97 2953 jorpiell
        Node[] nodes = null;
98
        setQuery(query);
99
100
101
        System.out.println("**************POST*************");
102
        System.out.println(getPOSTGetFeature(getQuery()));
103
        nodes = new ADLPOSTProtocol().doQuery(url,
104
                       getPOSTGetFeature(getQuery()), 0);
105
106
107
        return nodes;
108
109 2921 jorpiell
    }
110 2953 jorpiell
111
    /**
112
     * It creates the XML for the getFeature request
113
     *
114
     * @return
115
     * Name-value pair with a XML request
116
     */
117 2955 jorpiell
    private String getPOSTGetFeature(Query query) {
118 2953 jorpiell
        ADLQuery adlQuery = new ADLQuery(query);
119
120
        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
121
                "<gazetteer-service " +
122
                "xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
123
                "version=\"1.2\">" +
124
                "<query-request>" +
125
                adlQuery.getQuery() +
126
                "<report-format>standard</report-format>" +
127
                "</query-request>" +
128
                "</gazetteer-service>" ;
129 2955 jorpiell
    }
130
131
132
    /* (non-Javadoc)
133
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URL)
134
     */
135
    public boolean isProtocolSupported(URL url) {
136
        // TODO Auto-generated method stub
137
        return true;
138
    }
139 2921 jorpiell
140
    /* (non-Javadoc)
141
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
142
     */
143 2955 jorpiell
    public Node[] describeFeatureType(URL url, String feature) {
144
        // TODO Auto-generated method stub
145
        return null;
146
    }
147
148
    /* (non-Javadoc)
149
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
150
     */
151 2921 jorpiell
    public boolean setParameters(Node[] nodes) {
152 3069 jorpiell
        return new AdlCapabilitiesParser(this).parse(nodes[0]);
153 2921 jorpiell
    }
154
155 3069 jorpiell
    /* (non-Javadoc)
156
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#parseFeatures(org.w3c.dom.Node)
157
     */
158
    public Feature[] parseFeatures(Node node,ThesaurusName currentFeature,String attribute) {
159
        return new AdlFeatureParser().parse(node);
160
    }
161
162 2921 jorpiell
163
164
}