Project

General

Profile

« Previous | Next » 

Revision 2945

Added by harris about 18 years ago

Fixed a bug in the query system.

View differences:

src/edu/ucsb/nceas/metacat/spatial/SpatialQueryProcessor.java
100 100
    this.MCPASS = mcPass;
101 101
    this.MCUSER = mcUser;
102 102
    this.QUERYFILE = queryFile;
103

  
104

  
105
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
106
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
107
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
108
    log.warn("METACATURL: " + METACATURL 
109
            +"\nMCPASS: " + MCPASS
110
            +"\nMCUSER: " + MCUSER
111
            +"\nQUERYFILE: " + QUERYFILE);
112
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
113
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
114
    log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
103 115
  }
104 116

  
105 117
  public String execute() throws IOException {
......
225 237
    String query = "select docid, nodedata, nodeid from xml_nodes where "
226 238
        + "nodeid =(select  nodeid from  xml_nodes where docid  like '"
227 239
        + docid.trim() + "' and nodename like 'title%');";
228

  
229 240
    try {
230 241
      pstmt = dbconn.prepareStatement(query);
231 242
      pstmt.execute();
......
249 260
    float _coord = MetacatSpatialConstants.FLOAT_NULL;
250 261
    PreparedStatement pstmt = null;
251 262
    ResultSet rs = null;
252
    String query = "select docid, nodedata, nodeid from xml_nodes where "
253
        + "nodeid =(select  nodeid from  xml_nodes where docid  like '"
254
        + docid.trim() + "' and nodename like 'north%')+1;";
263
    String query = "select max(nodedata) from xml_nodes where "
264
        + "parentnodeid in (select  nodeid from  xml_nodes where docid  like '"
265
        + docid.trim() + "' and nodename like 'northBoundingCoordinate');";
255 266

  
256 267
    try {
257 268
      pstmt = dbconn.prepareStatement(query);
258 269
      pstmt.execute();
259 270
      rs = pstmt.getResultSet();
260 271
      if (rs.next())
261
        _coord = rs.getFloat(2);
272
        _coord = rs.getFloat(1);
262 273
      rs.close();
263 274
      pstmt.close();
264 275
    }
......
277 288
    float _coord = MetacatSpatialConstants.FLOAT_NULL;
278 289
    PreparedStatement pstmt = null;
279 290
    ResultSet rs = null;
280
    String query = "select docid, nodedata, nodeid from xml_nodes where "
281
        + "nodeid =(select  nodeid from  xml_nodes where docid  like '"
282
        + docid.trim() + "' and nodename like 'east%')+1;";
291
    String query = "select max(nodedata) from xml_nodes where "
292
        + "parentnodeid in (select  nodeid from  xml_nodes where docid  like '"
293
        + docid.trim() + "' and nodename like 'eastBoundingCoordinate');";
283 294

  
284 295
    try {
285 296
      pstmt = dbconn.prepareStatement(query);
286 297
      pstmt.execute();
287 298
      rs = pstmt.getResultSet();
288 299
      if (rs.next())
289
        _coord = rs.getFloat(2);
300
        _coord = rs.getFloat(1);
290 301
      rs.close();
291 302
      pstmt.close();
292 303
    }
......
305 316
    float _coord = MetacatSpatialConstants.FLOAT_NULL;
306 317
    PreparedStatement pstmt = null;
307 318
    ResultSet rs = null;
308
    String query = "select docid, nodedata, nodeid from xml_nodes where "
309
        + "nodeid =(select  nodeid from  xml_nodes where docid  like '"
310
        + docid.trim() + "' and nodename like 'south%')+1;";
319
    String query = "select max(nodedata) from xml_nodes where "
320
        + "parentnodeid in (select  nodeid from  xml_nodes where docid  like '"
321
        + docid.trim() + "' and nodename like 'southBoundingCoordinate');";
311 322

  
312 323
    try {
313 324
      pstmt = dbconn.prepareStatement(query);
314 325
      pstmt.execute();
315 326
      rs = pstmt.getResultSet();
316 327
      if (rs.next())
317
        _coord = rs.getFloat(2);
328
        _coord = rs.getFloat(1);
318 329
      rs.close();
319 330
      pstmt.close();
320 331
    }
......
334 345
    float _coord = MetacatSpatialConstants.FLOAT_NULL;
335 346
    PreparedStatement pstmt = null;
336 347
    ResultSet rs = null;
337
    String query = "select docid, nodedata, nodeid from xml_nodes where "
338
        + "nodeid =(select  nodeid from  xml_nodes where docid  like '"
339
        + docid.trim() + "' and nodename like 'west%')+1;";
348
    String query = "select max(nodedata) from xml_nodes where "
349
        + "parentnodeid in (select  nodeid from  xml_nodes where docid  like '"
350
        + docid.trim() + "' and nodename like 'westBoundingCoordinate');";
351
        
352
     log.warn("issuing query: " + query);
340 353

  
341 354
    try {
342 355
      pstmt = dbconn.prepareStatement(query);
343 356
      pstmt.execute();
344 357
      rs = pstmt.getResultSet();
345 358
      if (rs.next())
346
        _coord = rs.getFloat(2);
359
        _coord = rs.getFloat(1);
347 360
      rs.close();
348 361
      pstmt.close();
349 362
    }
350 363
    catch(Exception e) {
351
      log.error("Error getting docids from queryExtentsByDocid");
352
      e.printStackTrace();
364
      log.error("Error getting docids from queryWestBoundingCoordinate");
365
      e.getMessage();
353 366
    }
354 367
    return _coord;
355 368
  }
src/edu/ucsb/nceas/metacat/spatial/SpatialQueryManager.java
433 433
  {
434 434
    Hashtable params = new Hashtable();
435 435
    try {
436
      Enumeration enum = request.getParameterNames();
437
      while (enum.hasMoreElements()) {
438
        String name = (String) enum.nextElement();
436
      Enumeration _enum = request.getParameterNames();
437
      while (_enum.hasMoreElements()) {
438
        String name = (String) _enum.nextElement();
439 439
        String values[] = request.getParameterValues(name);
440 440
        if (values != null) {
441 441
          for (int i = 0; i < values.length; i++) {

Also available in: Unified diff