root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / drivers / ADLGazetteerServiceDriver.java @ 3069
History | View | Annotate | Download (4.81 KB)
1 |
/* 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 |
import es.gva.cit.gazetteer.parsers.adl.AdlCapabilitiesParser; |
48 |
import es.gva.cit.gazetteer.parsers.adl.AdlFeatureParser; |
49 |
import es.gva.cit.gazetteer.protocols.ADLPOSTProtocol; |
50 |
import es.gva.cit.gazetteer.querys.ADLQuery; |
51 |
import es.gva.cit.gazetteer.querys.Feature; |
52 |
import es.gva.cit.gazetteer.querys.Query; |
53 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
54 |
|
55 |
|
56 |
/**
|
57 |
* This class implements the driver to connect with a ADL gazetteer service
|
58 |
*
|
59 |
* @see http://alexandria.sdc.ucsb.edu/
|
60 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
61 |
*/
|
62 |
public class ADLGazetteerServiceDriver extends AsbtractGazetteerServiceDriver{ |
63 |
/**
|
64 |
* It invokes the getCapabilities operation
|
65 |
*/
|
66 |
public Node[] getCapabilities(URL url) { |
67 |
Node[] nodes = null; |
68 |
|
69 |
System.out.println("**************POST*************"); |
70 |
nodes = new ADLPOSTProtocol().doQuery(url,
|
71 |
getPOSTMessageCapabilities(), 0);
|
72 |
|
73 |
return nodes;
|
74 |
} |
75 |
|
76 |
/**
|
77 |
* It creates the XML for the getCapabilities request
|
78 |
*
|
79 |
* @return
|
80 |
* Name-value pair with a XML request
|
81 |
*/
|
82 |
private String getPOSTMessageCapabilities() { |
83 |
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 |
/**
|
93 |
* It invokes the getFeature operation
|
94 |
*/
|
95 |
|
96 |
public Node[] getFeature(URL url, Query query) { |
97 |
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 |
} |
110 |
|
111 |
/**
|
112 |
* It creates the XML for the getFeature request
|
113 |
*
|
114 |
* @return
|
115 |
* Name-value pair with a XML request
|
116 |
*/
|
117 |
private String getPOSTGetFeature(Query query) { |
118 |
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 |
} |
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 |
|
140 |
/* (non-Javadoc)
|
141 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
|
142 |
*/
|
143 |
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 |
public boolean setParameters(Node[] nodes) { |
152 |
return new AdlCapabilitiesParser(this).parse(nodes[0]); |
153 |
} |
154 |
|
155 |
/* (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 |
|
163 |
|
164 |
} |