Project

General

Profile

« Previous | Next » 

Revision 1834

Added by Jing Tao about 21 years ago

Add a new method to find document from queryspecification.

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
201 201
  public Hashtable findDocuments(Reader xmlquery, String user, String[] groups,
202 202
                                 boolean useXMLIndex)
203 203
  {
204
      Hashtable result = new Hashtable();
205
      try
206
      {
207
        // Get the XML query and covert it into a SQL statment
208
        QuerySpecification qspec = new QuerySpecification(xmlquery, 
209
                                   parserName, 
210
                                   util.getOption("accNumSeparator"));
211
        result = findDocuments(qspec, user, groups, useXMLIndex);
212
      }
213
      catch (IOException ioe) 
214
      {
215
        MetaCatUtil.debugMessage("IO error in DBQuery.findDocuments:", 30);
216
        MetaCatUtil.debugMessage(ioe.getMessage(), 30);
217
      }
218
      return result;
219
  }
220
  
221
  /** 
222
   * routine to search the elements and attributes looking to match query
223
   *
224
   * @param qspec java object of the query
225
   * @param user the username of the user
226
   * @param group the group of the user
227
   * @param useXMLIndex flag whether to search using the path index
228
   */
229
  public Hashtable findDocuments(QuerySpecification qspec, String user, 
230
                                  String[] groups, boolean useXMLIndex)
231
  {
204 232
      Hashtable   docListResult = new Hashtable();
205 233
      PreparedStatement pstmt = null;
206 234
      String docid = null;
......
224 252
        dbconn=DBConnectionPool.getDBConnection("DBQuery.findDocuments");
225 253
        serialNumber=dbconn.getCheckOutSerialNumber();
226 254
      
227
        // Get the XML query and covert it into a SQL statment
228
        QuerySpecification qspec = new QuerySpecification(xmlquery, 
229
                                   parserName, 
230
                                   util.getOption("accNumSeparator"));
231
       
232 255
        String query = qspec.printSQL(useXMLIndex);
233 256
        String ownerQuery = getOwnerQuery(user);
234 257
        MetaCatUtil.debugMessage("query: "+query, 30);
......
594 617
      } catch (SQLException e) {
595 618
        System.err.println("SQL Error in DBQuery.findDocuments: " + 
596 619
                           e.getMessage());
597
      } catch (IOException ioe) {
598
        System.err.println("IO error in DBQuery.findDocuments:");
599
        System.err.println(ioe.getMessage());
600 620
      } catch (Exception ee) {
601 621
        System.err.println("Exception in DBQuery.findDocuments: " + 
602 622
                           ee.getMessage());
......
622 642
    //System.out.println(docListResult.toString());
623 643
    return docListResult;
624 644
  }
625
  
626 645
  /*
627 646
   * A method to return search result after running a query which return
628 647
   * field have attribue

Also available in: Unified diff