Project

General

Profile

« Previous | Next » 

Revision 304

Added by berkley almost 24 years ago

no message

View differences:

lib/marine/marine.xsl
7 7
  *               National Center for Ecological Analysis and Synthesis
8 8
  *  For Details: http://www.nceas.ucsb.edu/
9 9
  *      Created: 2000 July 20
10
  *    File Info: '$Id$'
10
  *    File Info: '$Id$' 
11 11
  *
12 12
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
13 13
  * convert an XML file showing the resultset of a query
......
24 24
	<link rel="stylesheet" type="text/css" href="/xmltodb/lib/rowcol.css" />
25 25
      </head>
26 26
      <body class="emlbody">
27
      
28
      	<form action="http://alpha.nceas.ucsb.edu/servlets/marineServlet" 
27
        <a name="top" />
28
        <center><h1>MARINE Query Interface</h1></center>
29
        
30
        <p><h3>You can either <a href="#browse">browse the database</a> or start with 
31
           step 1 below.</h3></p>
32
        
33
        <table width="100%" border="1">
34
          <tr>
35
             <td valign="bottom">
36
        	<img src="http://alpha.nceas.ucsb.edu/xmltodb/lib/marine/step1.png" />
37
        	<p>Enter data about the owner of the dataset.  There may be more than one
38
        	   owner of any given dataset.  Any field(s) left blank will not be used
39
        	   in the search criteria.
40
        	</p>
41
              </td>
42
          </tr>
43
        </table>
44
             
45
      	<form action="http://alpha.nceas.ucsb.edu/servlets/marineServlet#browse" 
29 46
              method="POST"> 
30 47
           <table width="100%">
31 48
             <tr>
32 49
                <td>First Name:</td>
33
                <td>Organization:</td>
34
                <td>Address:</td>
35
                <td>Postal Code:</td>
50
                <td><input type="text" name="given_name" /></td>
51
                <td>Last Name:</td>
52
                <td><input type="text" name="surname" /></td>
36 53
             </tr>
37 54
             <tr>
38
             	<td><input type="text" name="given_name"></td>
39
             	<td><input type="text" name="organization"></td>
40
             	<td><input type="text" name="deliveryPoint"></td>
41
             	<td><input type="text" name="postalCode"></td>
42
             </td>
55
             	<td>Organization:</td>
56
             	<td><input type="text" name="organization" /></td>
57
             	<td>Address:</td>
58
             	<td><input type="text" name="deliveryPoint" /></td>
59
             </tr>
43 60
             <tr>
44
             	<td>Last Name:</td>
61
             	<td>City:</td>
62
             	<td><input type="text" name="city" /></td>
63
             	<td>Postal Code:</td>
64
             	<td><input type="text" name="postalCode" /></td>
65
             </tr>
66
             <tr>
45 67
             	<td>Email Address:</td>
46
             	<td>City:</td>
68
             	<td><input type="text" name="electronicMailAddress" /></td>
47 69
             	<td>Phone:</td>
70
             	<td><input type="text" name="voice" /></td>
48 71
             </tr>
72
           </table>
73
        
74
        <table width="100%" border="1">
75
          <tr>
76
             <td valign="bottom">
77
        	<img src="http://alpha.nceas.ucsb.edu/xmltodb/lib/marine/step2.png" />
78
        	<p>Enter bibliographic data relevent to the dataset.  
79
        	   Any field(s) left blank will not be used in the search criteria.  
80
        	   Some fields might not be relevent to the dataset for which you are 
81
        	   searching.
82
        	</p>
83
             </td>
84
          </tr>
85
        </table>
86
           
87
        <table width="100%">
49 88
             <tr>
50
             	<td><input type="text" name="surname"></td>
51
             	<td><input type="text" name="electronicMailAddress></td>
52
             	<td><input type="text" name="city"></td>
53
             	<td><input type="text" name="voice"></td>
89
             	<td>Publisher:</td>
90
                <td><input type="text" name="publisher" /></td>
91
                <td>Title:</td>
92
                <td><input type="text" name="title" /></td>
54 93
             </tr>
94
             <tr>
95
             	<td>Publication Date:</td>
96
             	<td><input type="text" name="pubdate" /></td>
97
             	<td>Alternate Title:</td>
98
             	<td><input type="text" name="alttitle" /></td>
99
             </tr>
100
             <tr>
101
             	<td>Publication Place:</td>
102
             	<td><input type="text" name="pubplace" /></td>
103
             	<td>URL:</td>
104
             	<td><input type="text" name="url" /></td>
105
             </tr>
106
             <tr>
107
             	<td>ISBN:</td>
108
             	<td><input type="text" name="isbn" /></td>
109
             	<td>Geospatial Representation Form:</td>
110
             	<!-- <td><input type="text" name="geoform" /></td> -->
111
             	<td>
112
             	<select name="geoform">
113
             	  <option value="" />
114
             	  <option value="atlas" />Atlas
115
             	  <option value="audio" />Audio
116
             	  <option value="diagram" />Diagram
117
             	  <option value="document" />Document
118
             	  <option value="globe" />Globe
119
             	  <option value="map" />Map
120
             	  <option value="model" />Model
121
             	  <option value="multimediaPresentation" />Multimedia Presentation
122
             	  <option value="profile" />Profiles
123
             	  <option value="rasterDigitalData" />Raster Digital Data
124
             	  <option value="remoteSensingImage" />Remote Sensing Image
125
             	  <option value="section" />Section
126
             	  <option value="spreadsheet" />Spreadsheet
127
             	  <option value="tabularDigialData" />Tabular Digial Data
128
             	  <option value="vectorDigitalData" />Vector Digital Data
129
             	  <option value="video" />Video
130
             	  <option value="view" />View
131
             	</select>
132
             	</td>
133
             </tr>
134
             <tr>
135
             	<td>ISSN:</td>
136
             	<td><input type="text" name="issn" /></td>
137
             	<td></td>
138
             	<td></td>
139
             </tr>
140
             <tr>
141
             	<td>Editor:</td>
142
             	<td><input type="text" name="editor" /></td>
143
             	<td></td>
144
             	<td></td>
145
             </tr>
146
             <tr>
147
             	<td>Edition:</td>
148
             	<td><input type="text" name="edition" /></td>
149
             	<td></td>
150
             	<td></td>
151
             </tr>
152
             <tr>
153
             	<td>Volume:</td>
154
             	<td><input type="text" name="volume" /></td>
155
             	<td></td>
156
             	<td></td>
157
             </tr>
158
        </table>
159

  
160
        <table width="100%" border="1">
161
          <tr>
162
             <td valign="bottom">
163
        	<img src="http://alpha.nceas.ucsb.edu/xmltodb/lib/marine/step3.png" />
164
        	<p>Enter any keywords that might partain to the dataset you are looking 
165
        	   for.  The "Any Field" text box will search any field in any document
166
        	   for the text you provide.
167
        	   Field(s) left blank will not be used in the search criteria.  
168
        	</p>
169
             </td>
170
          </tr>
171
        </table>
55 172
           
173
        <table width="100%">
174
             <tr>
175
             	<td>Keywords:</td>
176
                <td><input type="text" name="keyword" /></td>
177
                <td>Any Field:</td>
178
                <td><input type="text" name="anyfield" /></td>
179
             </tr>
180
        </table>
181
           
182
        <table width="100%" border="1">
183
          <tr>
184
             <td valign="bottom">
185
        	<img src="http://alpha.nceas.ucsb.edu/xmltodb/lib/marine/step4.png" />
186
        	<p>Click the Query button to submit your query.  The results will be
187
        	   displayed below under the heading "Query Results".
188
        	</p>
189
             </td>
190
          </tr>
191
        </table>
192
        <input type="hidden" name="action" value="squery" />   
193
    	<input type="hidden" name="query" value="" />
194
    	<input type="hidden" name="qformat" value="html" />
195
    	<input type="hidden" name="operator" value="UNION" />
196
        
197
        <input type="submit" value="Query" /><input type="reset" value="Clear Form" />
198
        
56 199
        </form>
57
      
200
             
201
        <a name="browse" />
202
	
58 203
	<center>
59
          <u><h2>Query Results</h2></u>
204
          <u><h2>Results</h2></u>
60 205
        </center>
61 206
        
62 207
        <form action="/servlets/marineServlet" method="POST">
63 208
        <input type="hidden" name="action" value="getdocument"/>
64 209

  
65
        <xsl:text>Output Format: </xsl:text>
66
        <select name="qformat">
67
          <option value="html">HTML</option>
68
          <option value="xml">XML</option>
69
        </select>
70

  
71 210
        <table width="100%">
72 211
        <tr class="rowodd">
73 212
        <th>&nbsp;</th>
74 213
        <th><xsl:text>Title</xsl:text></th>
75 214
        <th><xsl:text>Resource Name</xsl:text></th>
76
<!--        <th><xsl:text>Document Type</xsl:text></th> -->
77 215
        </tr>
78 216

  
79 217
        <xsl:for-each select="resultset/document">
......
86 224
            </xsl:attribute>
87 225

  
88 226
          <td>
89
<!--
90
              <input type="radio" name="docid">
91
                <xsl:attribute name="value">
92
                  <xsl:value-of select="./docid"/>
93
                </xsl:attribute>
94
              </input>
95
              <input type="submit" value="Display"/>
96
-->
97 227
              <input border="0" type="image">
98 228
                <xsl:attribute name="src">
99 229
                  <xsl:choose>
......
114 244
          <td>
115 245
              <xsl:value-of select="./docname"/> 
116 246
              <xsl:text> </xsl:text>
117
<!--              <xsl:value-of select="./docid"/>
118
              <xsl:text>&nbsp;</xsl:text>
119
-->
120 247
          </td>
121
<!--          <td><xsl:value-of select="./doctype"/>
122
              <xsl:text>&nbsp;</xsl:text>
123
         </td> 
124
-->
125 248
          </tr>
126 249
        </xsl:for-each>
127 250
        </table>
128 251
        </form>
129 252

  
253
        <h3><a href="#top">New Query</a></h3>
254
        
130 255
      </body>
131 256
    </html>
132 257
  </xsl:template>
lib/marine/marineResultset.dtd
1
<!--         
2
      '$RCSfile$'
3
      Purpose: This dtd defines the resultset for the marineServlet.
4
    Copyright: 2000 Regents of the University of California and the
5
               National Center for Ecological Analysis and Synthesis
6
      Authors: Chad Berkley
7

  
8
     '$Author$'
9
       '$Date$'
10
   '$Revision$'
11
-->
0 12

  
lib/marine/marine.properties
1 1
#
2
# Properties file defining options for the MetaCatServlet.java servlet
3
# Matt Jones, Dan Higgins
2
# Properties file defining options for the marineServlet.java servlet
3
# Matt Jones, Dan Higgins, Chad Berkley
4 4
# '$Id$'
5 5
#
6 6
user=jones
7 7
password=kinkaj0u
8
defaultDB=jdbc:oracle:thin:@24.237.20.124:1521:test
8
defaultDB=jdbc:oracle:thin:@24.237.21.98:1521:test
9 9
dbDriver=oracle.jdbc.driver.OracleDriver
10
resultStyleURL=file:///home/httpd/html/marine/marine.xsl
11
xmlcatalogfile=/home/httpd/html/xmltodb/lib/catalog.txt
10
resultStyleURL=http://alpha.nceas.ucsb.edu/xmltodb/lib/marine/marine.xsl
11
xmlcatalogfile=http://alpha.nceas.ucsb.edu/xmltodb/lib/catalog.txt
12 12
defaultdatapath=C:\Temp\
13 13
executescript=test.bat
14 14
defaultGlobalName=NCEAS
lib/marine/index.html
1
<!-- MARINE UI Test main page
2
     Author: Chad Berkley
3
     Date: 6/26/00
4
     Comments: Test User Interface for MARINE Scientists
5
-->
6
     
7 1
<html>
8
  <head>
9
  <title>MetaCat MARINE Interface</title>
10
  </head>
11
  <frameset cols="*" frameborder=1 border=1>
12

  
13
    <frameset rows="400,*"  frameborder=1 border=1>
14
    
15
    <frame src="marinetest.html" border=1 border="top">
16

  
17
    <frame src="http://alpha.nceas.ucsb.edu/servlets/marineServlet?action=query&query=NCEAS%25&qformat=html&doctype=-//NCEAS//eml-dataset//EN" border=1 name="bottom">
18

  
19
    </frameset>
20
  </frameset>
21
</html>
2
<head>
3
<title>MARINE Database Query Engine: Enter...</title>
4
</head>
5
<body bgcolor="white">
6
  <center>
7
     <img src="nceas.gif">
8
     <img src="nsf.gif">
9
     <img src="mms.gif">
10
  </center>
11
  <center><h1>Welcome to the MARINE database query engine</h1></center>
12
  
13
  <p>
14
     This page is used to query information for 
15
     <a href="http://www.mms.gov/omm/pacific/enviro/mint.htm">MARINE</a> scientists from
16
     the NCEAS Ecological Metadata Database.  For more information on
17
     this project, please read the 
18
     <a href="https://www2.nceas.ucsb.edu/admin/db/web.ppage?projid_in=2841">
19
     proposal abstract</a>.
20
  </p>
21
  
22
  <p>
23
  Once you enter the query page, you will be asked to fill out a form in 4 steps.  Each
24
  step contains several fields relating to a part of the dataset.  You may also browse
25
  the entire database by simply clicking the browse link at the top of the query page
26
  or by clicking the browse button below.
27
  Clicking on the buttons next to each data line will give you more
28
  information about the dataset or allow you to download the entire dataset.  Please note 
29
  some fields in the query forms will not be pertinent to your dataset.  If this is the case,
30
  simply leave any field blank to omit it from the searching.  
31
  </p>
32
       
33
 <center>
34
  <form action="http://alpha.nceas.ucsb.edu/servlets/marineServlet" 
35
              method="POST"> 
36
    <input type="hidden" name="action" value="init">   
37
    <input type="hidden" name="query" value="">
38
    <input type="hidden" name="doctype" value="ANY">
39
    <input type="hidden" name="qformat" value="html">
40
    <input type="submit" value="Query the Database">
41
  </form>
42
  <form action="http://alpha.nceas.ucsb.edu/servlets/marineServlet#browse" 
43
              method="POST"> 
44
    <input type="hidden" name="action" value="init">   
45
    <input type="hidden" name="query" value="">
46
    <input type="hidden" name="doctype" value="ANY">
47
    <input type="hidden" name="qformat" value="html">
48
    <input type="submit" value="Browse the Database">
49
  </form>
50
 </center
51
</body>
52
</html>
src/edu/ucsb/nceas/metacat/marine/marineServlet.java
59 59
      			queryobj = new DBQuery(conn,saxparser);
60 60
        		docreader = new DBReader(conn);
61 61
        		dbt = new DBTransform(conn);
62
        		/*
63
        		msg = new String(conn.toString());
62
        	/*
63
        		msg += new String(conn.toString());
64 64
      			msg += "\n" + saxparser;
65 65
      			msg += "\n" + queryobj;
66 66
      			msg += "\n" + docreader;
67 67
      			msg += "\n" + dbt;
68
      			*/
68
      		*/	
69 69
      		}
70 70
      		catch(Exception e)
71 71
      		{
72
      			msg = new String("Error in init\n " 
72
      			msg += new String("Error in init\n " 
73 73
      			      + e.fillInStackTrace().toString() );
74 74
      		}
75 75
	}
......
98 98
    		
99 99
    		try
100 100
    		{
101
    			init(out); // remove this when init() 
102
    			           //actually works
101
    			init(out);
103 102
		}
104 103
    		catch(Exception e)
105 104
      		{
106
      			System.err.println("Exception in handleGetOrPost: ");
105
      			System.err.println("marineServlet: Exception in handleGetOrPost: ");
107 106
      			System.err.println(e.toString());
108
      			System.err.println(msg);
109 107
      		}
110
      		
111
    		if (conn == null) 
112
    		{
113
      			System.err.println("Connection to database lost"+  
114
      			                    "...Reopening...");
115
      			try 
116
      			{
117
        			conn = util.openDBConnection();
118
        			queryobj = new DBQuery(conn, saxparser);
119
        			docreader = new DBReader(conn);
120
        			dbt = new DBTransform(conn);
121
      			}
122
      			catch (Exception e) 
123
      			{
124
        			System.err.println("Error opening" +
125
        			                   " database connection");
126
      			}
127
    		}   	
128 108
    		
129 109
    		String name = null;
130 110
    		String[] value = null;
......
185 165
    		
186 166
    		//Jivka's login code should go here!
187 167
    		
188
    		if (action.equals("query") || action.equals("squery")) 
168
    		try{
169
    		if (action.equals("query") || action.equals("squery")
170
    		    || action.equals("init")) 
189 171
    		{
190 172
      			handleQueryAction(out, params, response);
191 173
    		} 
......
194 176
      			out.println("Error: action not registered" +
195 177
      			  "Please report this error.");
196 178
    		}
197
		
198
		//out.print("msg:<br> ");
199
		//out.println(msg);
200
		//out.println("<br><br>marineServlet says: ok");
201
		out.close();
179
    		}
180
		catch(Exception e)
181
		{
182
			out.print("msg:<br> ");
183
			//System.err.println("\n\n\n");
184
			System.err.println(e.fillInStackTrace().toString());
185
			System.err.println(msg);
186
			//out.println(msg);
187
			out.println("<br><br>marineServlet says: ok");
188
			out.close();
189
		}
190
		System.err.println(msg);
202 191
    	}
203
/** 
204
   * Handle the database query request and return a result set, possibly
205
   * transformed from XML into HTML
206
   */
192

  
207 193
  	private void handleQueryAction(PrintWriter out, Hashtable params, 
208 194
               HttpServletResponse response)
209 195
        {
......
245 231
        		//correctly. For this reason, I have ommited the doctype
246 232
        		//here for the time being (7/20). 
247 233
        		xmlquery = new StringReader(createSQuery(params));
248
        		//msg = createSQuery(params);
234
        		//msg += " created sql query in squery ";
235
        		msg = createSQuery(params);
249 236
      		} 
250 237
      		else if(action.equals("init"))
251 238
      		{
252
      			
239
      			//msg += createBrowseList();
240
      			//System.err.println("in init: " + msg);
241
      			xmlquery = new StringReader(createBrowseList());
253 242
      		}
254 243
      		else 
255 244
      		{
256
        		msg = "Error handling query -- illegal action value";
245
        		msg = "marineServlet: Error handling query -- illegal action value";
257 246
      		}
258 247
      
259 248
      		if (queryobj != null) 
260 249
      		{
261 250
      			doclist = queryobj.findDocuments(xmlquery);
251
      			//msg += "\n\n" + doclist.toString();
262 252
      		} 
263 253
      		else 
264 254
      		{
265
        		out.println("Query Object Init failed.");
255
        		out.println("marineServlet: Query Object Init failed.");
266 256
        		return;
267 257
      		}
268 258
 
......
303 293
        		//out.println("Converting to HTML...");
304 294
        		XMLDocumentFragment htmldoc = null;
305 295
        		
306
        		try 
296
        		try  
307 297
        		{
308 298
          			XSLStylesheet style = new XSLStylesheet(
309 299
                                    new URL(resultStyleURL), null);
......
314 304
        		} 
315 305
        		catch (Exception e) 
316 306
        		{
317
          			out.println("Error transforming document:\n" 
307
          			System.err.println("Error transforming document:\n" 
318 308
          			             + e.fillInStackTrace().toString());
319
          			out.println("<p>msg: " + msg + "</p>");
309

  
320 310
        		}
321 311
      		}
322 312
      	}
323 313
      	
314
      	private String createBrowseList()
315
      	{
316
      		String query;
317
      		query = "<?xml version=\"1.0\"?>";
318
		query += "<!DOCTYPE pathquery PUBLIC \"-//NCEAS//pathquery-1.0//EN\" " + 
319
          		    "\"http://alpha.nceas.ucsb.edu/dtd/misc/pathquery.dtd\" >";
320
    		query += "<pathquery version=\"1.0\">";
321
    		query += "<meta_file_id>unspecified</meta_file_id>";
322
    		query += "<querytitle>unspecified</querytitle>";
323
    		query += "<querygroup operator=\"union\">";
324
    		query += "<queryterm casesensitive=\"false\" " + 
325
    				         "searchmode=\"contains\">";
326
    		query += "<value>";
327
    		query += "%";
328
    		query += "</value>";
329
    		query += "</queryterm>";
330
    		query += "</querygroup></pathquery>";
331
    		
332
    		return query;
333
      	}
334
      	
324 335
      	/** takes in the parameter list from the input source and 
325 336
      	    a doctype and returns a structured xml query based
326 337
      	    on the parameters.
......
359 370
    		{
360 371
    			query += "<returndoctype>" + doctype + "</returndoctype>";
361 372
    		}
362
    		query += "<querygroup operator=\"" + ((String[])params.get("operator"))[0] + "\">";
373
    		query += "<querygroup operator=\"" + 
374
    		         ((String[])params.get("operator"))[0] + "\">";
375
    		if(params.containsKey("anyfield") && 
376
    		   !((String[])params.get("anyfield"))[0].equals(""))
377
    		{
378
    			query += "<queryterm casesensitive=\"false\" " +
379
    			         "searchmode=\"contains\"><value>" +
380
    			         ((String[])params.get("anyfield"))[0] +
381
    			         "</value></queryterm>";
382
    		}
363 383
    		
364 384
    		elements = params.elements();
365 385
    		keys = params.keys();
......
373 393
    			if(!nextkey.toString().equals("doctype") && 
374 394
    			   !nextkey.toString().equals("action")  &&
375 395
    			   !nextkey.toString().equals("qformat") && 
396
    			   !nextkey.toString().equals("anyfield") &&
397
    			   !nextkey.toString().equals("operator") &&
376 398
    			   !(((String[])nextelement)[0].equals("")) )
377 399
    			{
378 400
    				query += "<queryterm casesensitive=\"false\" " + 
......
394 416
        } 
395 417
        
396 418
        /**same as createSQuery(Hashtable, String) except
397
           no doctyp is required.
419
           no doctype is required.
398 420
        **/
399 421
        private String createSQuery(Hashtable params)
400 422
        {
src/edu/ucsb/nceas/metacat/marine/marineUtil.java
26 26
public class marineUtil {
27 27

  
28 28
  private PropertyResourceBundle options = null;
29
  private static String propertiesFile = "marine";
29
  private static String propertiesFile = "edu.ucsb.nceas.metacat.marine.marine";
30 30
  private static boolean debug = false;
31 31

  
32 32
  /**

Also available in: Unified diff