Statistics
| Revision:

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

History | View | Annotate | Download (5.23 KB)

1

    
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.gazetteer.adl.drivers;
43
import es.gva.cit.catalogClient.metadataXML.XMLNode;
44
import es.gva.cit.catalogClient.protocols.HTTPPostProtocol;
45
import es.gva.cit.gazetteer.adl.filters.ADLFilter;
46
import es.gva.cit.gazetteer.adl.parsers.AdlCapabilitiesParser;
47
import es.gva.cit.gazetteer.adl.parsers.AdlFeatureParser;
48
import es.gva.cit.gazetteer.drivers.AsbtractGazetteerServiceDriver;
49
import es.gva.cit.gazetteer.querys.Feature;
50
import es.gva.cit.gazetteer.querys.Query;
51
import es.gva.cit.gazetteer.querys.ThesaurusName;
52
import java.net.URL;
53
import java.util.Collection;
54

    
55
/**
56
 * This class implements the driver to connect with a ADL gazetteer service
57
 * 
58
 * 
59
 * @author Jorge Piera Llodra (piera_jor@gva.es)
60
 * @see http://alexandria.sdc.ucsb.edu/
61
 */
62
public class ADLGazetteerServiceDriver extends AsbtractGazetteerServiceDriver {
63

    
64
/**
65
 * It invokes the getCapabilities operation
66
 * 
67
 * 
68
 * @return 
69
 * @param url 
70
 */
71
    public Collection getCapabilities(URL url) {        
72
       Collection nodes = new java.util.ArrayList();
73
       System.out.println("**************POST*************");
74
       nodes = new HTTPPostProtocol().doQuery(url,
75
               getPOSTMessageCapabilities(), 0);
76
        
77
       return nodes;
78
    } 
79

    
80
/**
81
 * It creates the XML for the getCapabilities request
82
 * 
83
 * 
84
 * @return Name-value pair with a XML request
85
 */
86
    private String getPOSTMessageCapabilities() {        
87
        return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
88
                "<gazetteer-service " +
89
                "xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
90
                "version=\"1.2\">" +
91
                "<get-capabilities-request/>" +
92
                "</gazetteer-service>";
93
        
94
    } 
95

    
96
/**
97
 * It invokes the getFeature operation
98
 * 
99
 * 
100
 * @return 
101
 * @param url 
102
 * @param query 
103
 */
104
    public Collection getFeature(URL url, Query query) {        
105
        Collection nodes = new java.util.ArrayList();
106
        setQuery(query);
107
              
108
        
109
        System.out.println("**************POST*************");
110
        System.out.println(getPOSTGetFeature(getQuery()));
111
        nodes = new HTTPPostProtocol().doQuery(url,
112
                       getPOSTGetFeature(getQuery()), 0);
113
                                    
114
        return nodes;
115
        
116
    } 
117

    
118
/**
119
 * It creates the XML for the getFeature request
120
 * 
121
 * 
122
 * @return Name-value pair with a XML request
123
 * @param query 
124
 */
125
    private String getPOSTGetFeature(Query query) {        
126
               
127
        return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
128
                "<gazetteer-service " +
129
                "xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
130
                "xmlns:gml=\"http://www.opengis.net/gml\" " +
131
                "version=\"1.2\">" +
132
                new ADLFilter().getQuery(query) +
133
                "</gazetteer-service>" ;
134
    } 
135
/* (non-Javadoc)
136
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URL)
137
     */
138

    
139
/**
140
 * 
141
 * 
142
 * 
143
 * @return 
144
 * @param url 
145
 */
146
    public boolean isProtocolSupported(URL url) {        
147
        // TODO Auto-generated method stub
148
        return true;
149
    } 
150
/* (non-Javadoc)
151
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
152
     */
153

    
154
/**
155
 * 
156
 * 
157
 * 
158
 * @return 
159
 * @param url 
160
 * @param feature 
161
 */
162
    public Collection describeFeatureType(URL url, String feature) {        
163
        // TODO Auto-generated method stub
164
        return null;
165
    } 
166
/* (non-Javadoc)
167
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
168
     */
169

    
170
/**
171
 * 
172
 * 
173
 * 
174
 * @return 
175
 * @param nodes 
176
 */
177
    public boolean setParameters(Collection nodes) {        
178
        return new AdlCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]);
179
    } 
180
/* (non-Javadoc)
181
     * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#parseFeatures(org.w3c.dom.Node)
182
     */
183

    
184
/**
185
 * 
186
 * 
187
 * 
188
 * @return 
189
 * @param node 
190
 * @param currentFeature 
191
 * @param attribute 
192
 */
193
    public Feature[] parseFeatures(XMLNode node, ThesaurusName currentFeature, String attribute) {        
194
        return new AdlFeatureParser().parse(node);
195
    } 
196
 }