edu.ucsb.nceas.metacat

## Class DBQuery

- java.lang.Object
- - edu.ucsb.nceas.metacat.DBQuery

-     public class DBQuery
      extends java.lang.Object

  A Class that searches a relational DB for elements and attributes that have free text matches a query string, or structured query matches to a path specified node in the XML hierarchy. It returns a result set consisting of the document ID for each document that satisfies the query

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `XPATHQUERYOFFINFO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBQuery()` construct an instance of the DBQuery class
    `DBQuery(java.util.Vector docids)` Construct an instance of DBQuery Class BUT accept a docid Vector that will supersede the query.printSQL() method If a docid Vector is passed in, the docids will be used to create a simple IN query without the multiple subselects of the printSQL() method Using this constructor, we just check for a docidOverride Vector in the findResultDoclist() method

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearQueryResultCache()` Method to clear the query result cache.
    `static java.lang.String` | `createQuery(java.lang.String value)` format a simple free-text value query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
    `static java.lang.String` | `createQuery(java.lang.String value, java.lang.String doctype)` format a simple free-text value query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
    `java.lang.StringBuffer` | `createResultDocument(java.lang.String xmlquery, QuerySpecification qspec, java.io.Writer out, java.lang.String user, java.lang.String[] groups, boolean useXMLIndex)` Transforms a hashtable of documents to an xml or html result and sent the content to outputstream.
    `java.lang.StringBuffer` | `createResultDocument(java.lang.String xmlquery, QuerySpecification qspec, java.io.Writer out, java.lang.String user, java.lang.String[] groups, boolean useXMLIndex, int pagesize, int pagestart, java.lang.String sessionid, java.lang.String qformat, boolean includeGuid)`
    `static java.lang.String` | `createSQuery(java.util.Hashtable params)` format a structured query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
    `void` | `findDocuments(javax.servlet.http.HttpServletResponse response, java.io.Writer out, java.util.Hashtable params, java.lang.String user, java.lang.String[] groups, java.lang.String sessionid)` Method put the search result set into out printerwriter
    `java.lang.String` | `getOperator()`
    `java.lang.String` | `getQformat()`
    `java.util.zip.ZipOutputStream` | `getZippedPackage(java.lang.String docIdString, javax.servlet.ServletOutputStream out, java.lang.String user, java.lang.String[] groups, java.lang.String passWord)` put a data packadge into a zip output stream
    `static void` | `main(java.lang.String[] args)` the main routine used to test the DBQuery utility.
    `java.lang.String` | `performPathquery(java.lang.String xmlquery, java.lang.String user, java.lang.String[] groups)`
    `void` | `setOperator(java.lang.String operator)` Specifies if and how docid overrides should be included in the general query
    `static java.sql.PreparedStatement` | `setPreparedStatementValues(java.util.List<java.lang.Object> parameterValues, java.sql.PreparedStatement pstmt)` Set the parameter values in the prepared statement using instrospection of the given value objects
    `void` | `setQformat(java.lang.String qformat)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### XPATHQUERYOFFINFO

          public static final java.lang.String XPATHQUERYOFFINFO

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DBQuery

          public DBQuery()
                  throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      construct an instance of the DBQuery class

      Generally, one would call the findDocuments() routine after creating an instance to specify the search query

      Parameters:
        `parserName` - the fully qualified name of a Java class implementing the org.xml.sax.XMLReader interface
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### DBQuery

          public DBQuery(java.util.Vector docids)
                  throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      Construct an instance of DBQuery Class BUT accept a docid Vector that will supersede the query.printSQL() method If a docid Vector is passed in, the docids will be used to create a simple IN query without the multiple subselects of the printSQL() method Using this constructor, we just check for a docidOverride Vector in the findResultDoclist() method
      Parameters:
        `docids` - List of docids to display in the resultset
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

  - ### Method Detail

    - #### main

          public static void main(java.lang.String[] args)

      the main routine used to test the DBQuery utility.

      Usage: java DBQuery NOTE: encoding should be provided for best results

      Parameters:
        `xmlfile` - the filename of the xml file containing the query

    - #### findDocuments

          public void findDocuments(javax.servlet.http.HttpServletResponse response,
                                    java.io.Writer out,
                                    java.util.Hashtable params,
                                    java.lang.String user,
                                    java.lang.String[] groups,
                                    java.lang.String sessionid)
                             throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      Method put the search result set into out printerwriter
      Parameters:
        `resoponse` - the return response
        `out` - the output printer
        `params` - the paratermer hashtable
        `user` - the user name (it maybe different to the one in param)
        `groups` - the group array
        `sessionid` - the sessionid
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### createResultDocument

          public java.lang.StringBuffer createResultDocument(java.lang.String xmlquery,
                                                             QuerySpecification qspec,
                                                             java.io.Writer out,
                                                             java.lang.String user,
                                                             java.lang.String[] groups,
                                                             boolean useXMLIndex)

      Transforms a hashtable of documents to an xml or html result and sent the content to outputstream. Keep going untill hastable is empty. stop it. add the QuerySpecification as parameter is for ecogrid. But it is duplicate to xmlquery String
      Parameters:
        `xmlquery` -
        `qspec` -
        `out` -
        `user` -
        `groups` -
        `useXMLIndex` -
        `sessionid` -
      Returns:

    - #### performPathquery

          public java.lang.String performPathquery(java.lang.String xmlquery,
                                                   java.lang.String user,
                                                   java.lang.String[] groups)
                                            throws edu.ucsb.nceas.utilities.PropertyNotFoundException,
                                                   java.io.IOException

      Parameters:
        `xmlquery` -
        `user` -
        `groups` -
        `useXMLIndex` -
      Returns:
      Throws:
        `java.io.IOException`
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### createResultDocument

          public java.lang.StringBuffer createResultDocument(java.lang.String xmlquery,
                                                             QuerySpecification qspec,
                                                             java.io.Writer out,
                                                             java.lang.String user,
                                                             java.lang.String[] groups,
                                                             boolean useXMLIndex,
                                                             int pagesize,
                                                             int pagestart,
                                                             java.lang.String sessionid,
                                                             java.lang.String qformat,
                                                             boolean includeGuid)

    - #### clearQueryResultCache

          public static void clearQueryResultCache()

      Method to clear the query result cache.

    - #### setPreparedStatementValues

          public static java.sql.PreparedStatement setPreparedStatementValues(java.util.List<java.lang.Object> parameterValues,
                                                                              java.sql.PreparedStatement pstmt)
                                                                       throws java.sql.SQLException

      Set the parameter values in the prepared statement using instrospection of the given value objects
      Parameters:
        `parameterValues` -
        `pstmt` -
      Returns:
      Throws:
        `java.sql.SQLException`

    - #### createSQuery

          public static java.lang.String createSQuery(java.util.Hashtable params)
                                               throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      format a structured query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
      Parameters:
        `params` - The list of parameters that should be included in the query
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### createQuery

          public static java.lang.String createQuery(java.lang.String value,
                                                     java.lang.String doctype)

      format a simple free-text value query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
      Parameters:
        `value` - the text string to search for in the xml catalog
        `doctype` - the type of documents to include in the result set -- use "any" or "ANY" for unfiltered result sets

    - #### createQuery

          public static java.lang.String createQuery(java.lang.String value)

      format a simple free-text value query as an XML document that conforms to the pathquery.dtd and is appropriate for submission to the DBQuery structured query engine
      Parameters:
        `value` - the text string to search for in the xml catalog

    - #### getOperator

          public java.lang.String getOperator()

    - #### setOperator

          public void setOperator(java.lang.String operator)

      Specifies if and how docid overrides should be included in the general query
      Parameters:
        `operator` - null, UNION, or INTERSECT (see QueryGroup)

    - #### getQformat

          public java.lang.String getQformat()

    - #### setQformat

          public void setQformat(java.lang.String qformat)

    - #### getZippedPackage

          public java.util.zip.ZipOutputStream getZippedPackage(java.lang.String docIdString,
                                                                javax.servlet.ServletOutputStream out,
                                                                java.lang.String user,
                                                                java.lang.String[] groups,
                                                                java.lang.String passWord)
                                                         throws java.lang.ClassNotFoundException,
                                                                java.io.IOException,
                                                                java.sql.SQLException,
                                                                McdbException,
                                                                java.lang.NumberFormatException,
                                                                java.lang.Exception

      put a data packadge into a zip output stream
      Parameters:
        `docId,` - which the user want to put into zip output stream,it has version
        `out,` - a servletoutput stream which the zip output stream will be put
        `user,` - the username of the user
        `groups,` - the group of the user
      Throws:
        `java.lang.ClassNotFoundException`
        `java.io.IOException`
        `java.sql.SQLException`
        `McdbException`
        `java.lang.NumberFormatException`
        `java.lang.Exception`

Copyright © 2020 Regents of the University of California. All Rights Reserved.