Revision 3069 trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/gazetteer/ui/SearchDialogPanel.java
SearchDialogPanel.java | ||
---|---|---|
44 | 44 |
import org.w3c.dom.Node; |
45 | 45 |
|
46 | 46 |
import es.gva.cit.gazetteer.GazetteerClient; |
47 |
import es.gva.cit.gazetteer.parsers.adl.adlFeatureParser;
|
|
48 |
import es.gva.cit.gazetteer.parsers.wfsg.wfsgDescribeFeatureTypeParser;
|
|
47 |
import es.gva.cit.gazetteer.parsers.adl.AdlFeatureParser;
|
|
48 |
import es.gva.cit.gazetteer.parsers.wfsg.WfsgDescribeFeatureTypeParser;
|
|
49 | 49 |
import es.gva.cit.gazetteer.querys.Feature; |
50 | 50 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
51 | 51 |
import es.gva.cit.gazetteer.querys.Query; |
... | ... | |
80 | 80 |
protected GazetteerClient client = null; |
81 | 81 |
protected Node[] nodesRecords = null; |
82 | 82 |
protected ThesaurusName currentFeature = null; |
83 |
protected String attribute = null; |
|
83 | 84 |
|
84 | 85 |
/** |
85 | 86 |
* This method initializes |
... | ... | |
119 | 120 |
controlsPanel = new SearchPanel(client.getLnkIGazetteerDriver().getVectorFeatures()); |
120 | 121 |
controlsPanel.setPreferredSize(new java.awt.Dimension(727, 455)); |
121 | 122 |
controlsPanel.setLocation(0, 0); |
122 |
|
|
123 |
if (client.getProtocol().equals("IDEC")) |
|
124 |
controlsPanel.getJScrollThesauro().setEnabled(false); |
|
123 | 125 |
} |
124 | 126 |
|
125 | 127 |
return controlsPanel; |
... | ... | |
177 | 179 |
if (e.getActionCommand() == "Cerrar") { |
178 | 180 |
closeButtonActionPerformed(); |
179 | 181 |
} |
182 |
|
|
183 |
|
|
180 | 184 |
} |
181 | 185 |
|
182 | 186 |
protected void searchButtonActionPerformed(){ |
183 |
Query currentQuery = doQuery(); |
|
184 | 187 |
doSearch(); |
185 | 188 |
|
186 | 189 |
if ((nodesRecords != null) && (nodesRecords.length > 0)) { |
... | ... | |
196 | 199 |
return new Query(controlsPanel.getName(), |
197 | 200 |
controlsPanel.getConcordancia(), |
198 | 201 |
controlsPanel.getType(), |
202 |
getFieldAttribute(), |
|
199 | 203 |
controlsPanel.getNPaginas(), |
200 | 204 |
controlsPanel.getCoordenadas(), |
201 | 205 |
controlsPanel.getCoordenadasOpcion()); |
202 | 206 |
} |
207 |
/** |
|
208 |
* it opens a window with a combo and returns a field attribute name |
|
209 |
* @return |
|
210 |
*/ |
|
211 |
private String getFieldAttribute(){ |
|
212 |
if (!(client.getProtocol().equals("WFS-G"))) |
|
213 |
return null; |
|
214 |
|
|
215 |
Object[] possibilities = new Object[currentFeature.getFields().length]; |
|
216 |
for (int i=0 ; i< possibilities.length ; i++) |
|
217 |
possibilities[i] = currentFeature.getFields()[i].getName(); |
|
218 |
|
|
219 |
String s = (String)JOptionPane.showInputDialog( |
|
220 |
this, |
|
221 |
"Elige un atributo para hacer la b?squeda", |
|
222 |
"WFS-G", |
|
223 |
JOptionPane.PLAIN_MESSAGE, |
|
224 |
null, |
|
225 |
possibilities, |
|
226 |
currentFeature.getFields()[0].getName()); |
|
203 | 227 |
|
228 |
if ((s != null) && (s.length() > 0)) { |
|
229 |
attribute = s; |
|
230 |
return s; |
|
231 |
} |
|
232 |
|
|
233 |
return null; |
|
234 |
} |
|
235 |
|
|
204 | 236 |
public void doSearch() { |
205 | 237 |
nodesRecords = client.getLnkIGazetteerDriver().getFeature(client.getUrl(), |
206 | 238 |
doQuery()); |
... | ... | |
214 | 246 |
} |
215 | 247 |
|
216 | 248 |
public void showResults() { |
217 |
Feature[] features = new adlFeatureParser().parse(nodesRecords[0]); |
|
249 |
Feature[] features = client.getLnkIGazetteerDriver().parseFeatures(nodesRecords[0],currentFeature,attribute); |
|
250 |
|
|
218 | 251 |
if (features.length == 0){ |
219 | 252 |
JOptionPane.showMessageDialog(this, |
220 | 253 |
"La b?squeda no ha producido ning?n resultado", "B?squeda de Gazetteer", |
... | ... | |
225 | 258 |
} |
226 | 259 |
|
227 | 260 |
public void ShowResultsActionPerformed(Feature[] features){ |
228 |
new ShowResultsDialog(this.client,features,controlsPanel.getNPaginas());
|
|
261 |
new ShowResultsDialog(client,features,controlsPanel.getNPaginas()); |
|
229 | 262 |
} |
230 | 263 |
|
231 | 264 |
|
... | ... | |
234 | 267 |
* It loads the fields for the feature |
235 | 268 |
* @param feature |
236 | 269 |
*/ |
237 |
protected void loadCurrentFeature(ThesaurusName feature){
|
|
270 |
private void loadCurrentFeature(){
|
|
238 | 271 |
Node[] fields = client.getLnkIGazetteerDriver().describeFeatureType(client.getUrl(), |
239 |
feature.getName());
|
|
272 |
currentFeature.getName());
|
|
240 | 273 |
|
241 | 274 |
if (client.getProtocol().equals("WFS-G")) |
242 |
new wfsgDescribeFeatureTypeParser().parse(fields[0],feature); |
|
243 |
|
|
244 |
System.out.println(currentFeature.getName()); |
|
275 |
new WfsgDescribeFeatureTypeParser().parse(fields[0],currentFeature); |
|
276 |
|
|
245 | 277 |
} |
246 | 278 |
|
247 | 279 |
/* (non-Javadoc) |
... | ... | |
250 | 282 |
public void valueChanged(TreeSelectionEvent e) { |
251 | 283 |
if (currentFeature == null){ |
252 | 284 |
currentFeature = getFeatureSelected(); |
253 |
loadCurrentFeature(currentFeature);
|
|
285 |
loadCurrentFeature(); |
|
254 | 286 |
}else{ |
255 | 287 |
ThesaurusName feature = getFeatureSelected(); |
256 | 288 |
if (!(currentFeature.equals(feature))){ |
257 | 289 |
if (feature != null){ |
258 | 290 |
currentFeature = feature; |
259 |
loadCurrentFeature(currentFeature);
|
|
291 |
loadCurrentFeature(); |
|
260 | 292 |
} |
261 | 293 |
} |
262 | 294 |
} |
Also available in: Unified diff