Project

General

Profile

« Previous | Next » 

Revision 307

Added by berkley over 24 years ago

no message

View differences:

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());
64
      			msg += "\n" + saxparser;
65
      			msg += "\n" + queryobj;
66
      			msg += "\n" + docreader;
67
      			msg += "\n" + dbt;
68
      		*/	
62
        	
63
        		//msg += new String(conn.toString());
64
      			//msg += "\n" + saxparser;
65
      			//msg += "\n" + queryobj;
66
      			//msg += "\n" + docreader;
67
      			//msg += "\n" + dbt;
68
      			
69 69
      		}
70 70
      		catch(Exception e)
71 71
      		{
......
199 199
      		String[] doctypeArr = null;
200 200
      		String doctype = null;
201 201
      		Reader xmlquery = null;
202
      		Hashtable extendedSQL = new Hashtable();
202 203
		
203 204
      		if(action.equals("query")) 
204 205
      		{
......
256 257
        		return;
257 258
      		}
258 259
 
260
 		extendedSQL = createExtendedSQL(doclist);
261
 		
262
 
259 263
      		// Create a buffer to hold the xml result
260 264
      		StringBuffer resultset = new StringBuffer();
261 265
 
......
311 315
      		}
312 316
      	}
313 317
      	
318
      	/**
319
      	   creates the sql query for the extended information
320
      	   displayed upon successful query
321
      	**/
322
      	private Hashtable createExtendedSQL(Hashtable docs)
323
      	{
324
      		Hashtable result = new Hashtable();
325
      		ResultSet givenNameResults;
326
      		ResultSet surNameResults;
327
      		ResultSet organizationNameResults;
328
      		ResultSet dateResults;
329
      		PreparedStatement pstatement;
330
      		
331
      		Enumeration docids = docs.keys();
332
      		
333
      		//find all of the owners first names
334
		String givenNameQuery = "select docid, nodedata from xml_nodes" +
335
		   " where parentnodeid in" +
336
		   " (select nodeid from xml_index where path like 'givenName')" +
337
		   " and parentnodeid in" +
338
 		   " (select nodeid from xml_nodes where nodename like 'givenName'" +
339
  		   " and parentnodeid in" +
340
                   " (select nodeid from xml_nodes where nodename like 'individualName'" +
341
                   " and parentnodeid in" +
342
                   " (select parentnodeid from xml_nodes where nodename like 'roleCode'" +
343
                   " and nodeid in" +
344
                   " (select parentnodeid from xml_nodes where" +
345
                   " nodedata = 'Owner'" +
346
                   " and parentnodeid in" +
347
                   " (select nodeid from xml_index where path like 'roleCode')))))";
348
                
349
                //find all of the owners last names
350
		String surNameQuery = "select docid, nodedata from xml_nodes" +
351
		   " where parentnodeid in" +
352
		   " (select nodeid from xml_index where path like 'surName')" +
353
		   " and parentnodeid in" +
354
 		   " (select nodeid from xml_nodes where nodename like 'surName'" +
355
  		   " and parentnodeid in" +
356
                   " (select nodeid from xml_nodes where nodename like 'individualName'" +
357
                   " and parentnodeid in" +
358
                   " (select parentnodeid from xml_nodes where nodename like 'roleCode'" +
359
                   " and nodeid in" +
360
                   " (select parentnodeid from xml_nodes where" +
361
                   " nodedata = 'Owner'" +
362
                   " and parentnodeid in" +
363
                   " (select nodeid from xml_index where path like 'roleCode')))))";
364

  
365
		//find all of the organizations
366
		String organizationNameQuery = "select docid, nodedata from xml_nodes" +
367
		   " where parentnodeid in" +
368
		   " (select nodeid from xml_index where path like 'organizationName')";
369
                
370
                //find all of the creation and update dates
371
                String dateQuery = "select docid, date_created, date_updated" +
372
                   " from xml_documents";
373
            try{  
374
                pstatement = conn.prepareStatement(givenNameQuery);
375
                pstatement.execute();
376
                givenNameResults = pstatement.getResultSet();
377
                
378
                pstatement = conn.prepareStatement(surNameQuery);
379
                pstatement.execute();
380
                surNameResults = pstatement.getResultSet();
381
		
382
		pstatement = conn.prepareStatement(organizationNameQuery);
383
                pstatement.execute();
384
                organizationNameResults = pstatement.getResultSet();
385
      		
386
      		pstatement = conn.prepareStatement(dateQuery);
387
                pstatement.execute();
388
                dateResults = pstatement.getResultSet();
389
                }
390
             catch(SQLException s)
391
             {
392
                System.err.println("error in SQL " + s.getMessage());
393
             }
394
             
395
                return result;
396
      	}
397
      	
398
      	/**
399
      	   creates the xml query for the browse list
400
      	**/
314 401
      	private String createBrowseList()
315 402
      	{
316 403
      		String query;
317 404
      		query = "<?xml version=\"1.0\"?>";
318 405
		query += "<!DOCTYPE pathquery PUBLIC \"-//NCEAS//pathquery-1.0//EN\" " + 
319
          		    "\"http://alpha.nceas.ucsb.edu/dtd/misc/pathquery.dtd\" >";
406
          		    "\"http://alpha.nceas.ucsb.edu/xmltodb/lib/pathquery.dtd\" >";
320 407
    		query += "<pathquery version=\"1.0\">";
321 408
    		query += "<meta_file_id>unspecified</meta_file_id>";
322 409
    		query += "<querytitle>unspecified</querytitle>";
......
345 432
    		Object nextelement;
346 433
    		query = "<?xml version=\"1.0\"?>";
347 434
		query += "<!DOCTYPE pathquery PUBLIC \"-//NCEAS//pathquery-1.0//EN\" " + 
348
          		    "\"http://alpha.nceas.ucsb.edu/dtd/misc/pathquery.dtd\" >";
435
          		    "\"http://alpha.nceas.ucsb.edu/xmltodb/lib/pathquery.dtd\" >";
349 436
    		query += "<pathquery version=\"1.0\"><meta_file_id>";
350 437
    		if(params.containsKey("meta_file_id"))
351 438
    		{

Also available in: Unified diff