Project

General

Profile

« Previous | Next » 

Revision 2912

Added by harris almost 19 years ago

Integration of the metacat servlet with the spatial option -- rubberbanding is implemented too.

View differences:

src/edu/ucsb/nceas/metacat/spatial/MetacatSpatialDataset.java
49 49
    docs = new Vector();
50 50
  }
51 51

  
52

  
53
  public MetacatSpatialDocument getDocument(int _id) {
54
    return (MetacatSpatialDocument)docs.elementAt(_id);
55
  }
56

  
52 57
  /*
53 58
   * Adds a new MetacatSpatialDocument to this dataset
54 59
   */
......
94 99
 
95 100
    // write the data stored in this object using the persistent layer
96 101
    PersistentMetacatSpatialDataset _writer = new PersistentMetacatSpatialDataset();
97
     _writer.writeTextQueryData(this);
98
  
102
     _writer.writeTextQueryData(this); 
99 103
  }
100 104

  
101 105
  
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
70 70
import com.oreilly.servlet.multipart.Part;
71 71

  
72 72
import edu.ucsb.nceas.utilities.Options;
73
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialQuery;
74
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
75
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDataset;
73 76

  
74 77
/**
75 78
 * A metadata catalog server implemented as a Java Servlet
......
474 477
                PrintWriter out = response.getWriter();
475 478
                handleLoginAction(out, params, request, response);
476 479
                out.close();
480
            }
481
            
482
            else if (action.trim().equals("spatial_query") ) {
483
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
484
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
485
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
486
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
487
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
477 488

  
489
              handleSpatialQuery(params, request, response);
490
        
478 491
                // handle logout action
479 492
            } else if (action.equals("logout")) {
480 493
                PrintWriter out = response.getWriter();
......
740 753
        }
741 754
    }
742 755

  
756
    /////////////////////////////// METACAT SPATIAL ///////////////////////////
757

  
758
    /**
759
     * handles all spatial queries -- these queries may include any of the 
760
     * queries supported by the WFS / WMS standards
761
     */
762
    private void handleSpatialQuery(Hashtable params, 
763
                                    HttpServletRequest request, 
764
                                    HttpServletResponse response) {
765
      Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
766
      MetacatSpatialQuery _spatialQuery = new MetacatSpatialQuery();
767
      
768
      PrintWriter out;
769
      try {
770
        out = response.getWriter();
771
      
772
      // switch -- html/xml print
773
      boolean printXML = false; 
774
      
775
      // get the spatial parameters
776
      logMetacat.warn("params: " +  params);
777
      //String _xmax =  (String)params.get("XMAX");
778
      float _xmax = Float.parseFloat( ((String[]) params.get("XMAX"))[0] );
779
      float _ymax = Float.parseFloat( ((String[]) params.get("YMAX"))[0] );
780
      float _xmin = Float.parseFloat( ((String[]) params.get("XMIN"))[0] );
781
      float _ymin = Float.parseFloat( ((String[]) params.get("YMIN"))[0] );
782
      logMetacat.warn("\nxmax: " + _xmax + " \nymax:" + _ymax +
783
                      "\nxmin: " + _xmin + "\nymin: " + _ymin);
784

  
785

  
786
      // is it UTM or lat/long
787

  
788
      // issue the query 
789
      MetacatSpatialDataset _data =  
790
        _spatialQuery.queryDatasetByCartesianBounds(_xmin, _ymin, _xmax, _ymax);
791

  
792
      // return the list of docs and point at the spatial theme 
793
      if ( printXML) {
794
        response.setContentType("text/xml");
795
        out.println("<?xml version=\"1.0\"?>");
796
        out.println("<urllist>");
797
        //for all data (print url approximations)
798
        for (int i = 0; i < _data.size(); i++) {
799
          out.println("<docid>"+(_data.getDocument(i)).getDocid()+"</docid>"); 
800
          out.println("<url>"+request.getRequestURL()+(_data.getDocument(i)).getDocid()+"</url>");  
801
        } 
802
        out.println("</urllist>");
803
        out.close();
804
      } else {
805
        response.setContentType("text/html");
806
        out.println("<html>\n<body>");
807
        //for all data (print url approximations)
808
        for (int i = 0; i < _data.size(); i++) {
809
          //format like: metacat?action=read&docid=dpennington.38.6&qformat=knb    
810
          out.println("<a href=\""+request.getRequestURL()+"?action=read&docid="+(_data.getDocument(i)).getDocid()+"\">  "+(_data.getDocument(i)).getDocid()+"</a> <br>");  
811
        } 
812
        out.println("</html>\n</body>");
813
        out.close();
814
      
815
      }
816
      
817
      } catch (IOException ioe) { ioe.printStackTrace(); }
818
      
819
      return;
820
    }
821

  
822

  
743 823
    // LOGIN & LOGOUT SECTION
744 824
    /**
745 825
     * Handle the login request. Create a new session object. Do user
......
760 840
            return;
761 841
        }
762 842

  
843
        //}
844

  
763 845
        if(params.get("password") == null){
764 846
            response.setContentType("text/xml");
765 847
            out.println("<?xml version=\"1.0\"?>");
......
3048 3130
        }
3049 3131
        //logMetacat.debug("The docid will be read is "+newAccNum);
3050 3132
        return newAccNum;
3051
    }
3133
  }
3052 3134
}
src/edu/ucsb/nceas/metacat/DocumentImplWrapper.java
39 39
import org.xml.sax.SAXParseException;
40 40
import org.xml.sax.helpers.XMLReaderFactory;
41 41

  
42
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
43

  
42 44
/**
43 45
 * This class a wrapper class for documentimpl for insert or update. It will 
44 46
 * provide deferent parser base on xml document validation by dtd or schema
......
68 70
                      String action, String docid, String user, String[] groups)
69 71
                      throws Exception
70 72
  {
73
    
74
    //jhh register this transaction with the Metacat Spatial Option
75
    MetacatSpatialDocument msdoc = new MetacatSpatialDocument(docid);
76
    
71 77
    return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user, 
72 78
                              groups, ruleBase, needValidation);
73 79
  }
src/edu/ucsb/nceas/metacat/DBQuery.java
59 59
import edu.ucsb.nceas.morpho.datapackage.Triple;
60 60
import edu.ucsb.nceas.morpho.datapackage.TripleCollection;
61 61

  
62
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialQuery;
63
import edu.ucsb.nceas.metacat.spatial.PersistentMetacatSpatialDataset;
64
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDataset;
65
import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
66

  
62 67
/**
63 68
 * A Class that searches a relational DB for elements and attributes that have
64 69
 * free text matches a query string, or structured query matches to a path
......
81 86

  
82 87
    private Logger logMetacat = Logger.getLogger(DBQuery.class);
83 88

  
89
    /** true if the metacat spatial option is installed **/
90
    private final boolean METACAT_SPATIAL = true;
91

  
84 92
    /**
85 93
     * the main routine used to test the DBQuery utility.
86 94
     * <p>
......
249 257
         }
250 258
         catch (Exception ee)
251 259
         {
252
           logMetacat.error("erro to generate QuerySpecification object"
260
           logMetacat.error("error generating QuerySpecification object"
253 261
                                    +" in DBQuery.findDocuments"
254 262
                                    + ee.getMessage());
255 263
         }
......
336 344
        resultset = findResultDoclist(qspec, resultset, out, user, groups,
337 345
                                      dbconn, useXMLIndex);
338 346

  
347
        
348

  
339 349
      } //try
340 350
      catch (IOException ioe)
341 351
      {
......
380 390
                                      DBConnection dbconn, boolean useXMLIndex )
381 391
                                      throws Exception
382 392
    {
393
      
394
      MetacatSpatialDataset metacatSpatialData; 
395
      if ( METACAT_SPATIAL ) 
396
        metacatSpatialData = new MetacatSpatialDataset(); 
397
      
383 398
      int offset = 1;
384 399
      // this is a hack for offset
385 400
      if (out == null)
......
439 454
      while (tableHasRows)
440 455
      {
441 456
        docid = rs.getString(1).trim();
457
        if ( METACAT_SPATIAL ) {
458
          System.out.println("###################################################");
459
          System.out.println("###################################################");
460
          System.out.println("###################################################");
461
          System.out.println("###################################################");
462
          System.out.println("###################################################");
463
          System.out.println("################ " + docid + " ####################");
464
          
465
          // make sure that the spatial dataset is initialized
466
          MetacatSpatialQuery spatialQuery = new  MetacatSpatialQuery();
467
          
468
          // create the spatial document 
469
          MetacatSpatialDocument msdoc = spatialQuery.getSpatialDocument(docid);
470

  
471
          // add the spatial document to the spatial dataset
472
          metacatSpatialData.add(msdoc);
473

  
474
          // write the persistent spatial dataset
475
          //////metacatSpatialData.write();
476
          
477
          System.out.println("###################################################");
478
          System.out.println("###################################################");
479
          System.out.println("###################################################");
480
          System.out.println("###################################################");
481
          System.out.println("###################################################");
482
        }
442 483
        docname = rs.getString(2);
443 484
        doctype = rs.getString(3);
444 485
        createDate = rs.getString(4);
......
612 653
     logMetacat.warn("prepare docid list time: "
613 654
                    + (docListTime - queryExecuteTime));
614 655

  
656
     
657
     //write the persistent spatial dataset
658
     metacatSpatialData.writeTextQueryData();
659

  
615 660
     return resultsetBuffer;
616 661
    }//findReturnDoclist
617 662

  
src/edu/ucsb/nceas/metacat/DBTransform.java
73 73

  
74 74
import java.util.Properties;
75 75

  
76

  
76 77
/**
77 78
 * A Class that transforms XML documents utitlizing XSL style sheets
78 79
 */

Also available in: Unified diff