Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class QueryByForm

    java.lang.Object
      com.knowgate.dataobjs.DBPersist
          com.knowgate.hipergate.QueryByForm

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

    public class QueryByForm

extends DBPersist

Query By Form XML parser and SQL composer.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary

Fields inherited from class com.knowgate.dataobjs.DBPersist
`AllVals, sAuditCls, sAuditUsr, sTransactId`

Constructor Summary
`QueryByForm(JDCConnection oConn, java.lang.String sBaseTable, java.lang.String sTableAlias, java.lang.String sQueryGUID)` Load a query from k_queries table.
`QueryByForm(java.lang.String sQBFURI)` Create an empty query by parsing an XML definition file.
`QueryByForm(java.lang.String sQBFURI, java.lang.String sEncoding)` Create an empty query by parsing an XML definition file.

Method Summary
`java.lang.String` | `composeSQL()` Compose SQL WHERE clause by concatenating single clauses for each field <basefilter> clause is not included in returned String.
`static boolean` | `delete(JDCConnection oConn, java.lang.String sQBFGUID)` Delete QBF instance from database Dynamic Lists using this QBF will be deleted on cascade
`java.lang.String` | `getAction()`
`java.lang.String` | `getBaseFilter(HttpServletRequest oReq)` Get query base filter instantiated for given HttpServletRequest parameters.
`java.lang.String` | `getBaseObject()`
`java.util.Vector` | `getColumns()`
`dom.DOMDocument` | `getDocument()`
`java.util.Vector` | `getFields()`
`java.lang.String` | `getMethod()`
`java.util.Vector` | `getSortable()`
`java.lang.String` | `getTitle(java.lang.String sLanguage)`
`void` | `parseURI(java.lang.String sURI)` Parse query XML specification file.
`void` | `parseURI(java.lang.String sURI, java.lang.String sEncoding)` Parse query XML specification file.
`void` | `queryToStream(java.sql.Connection oConn, java.lang.String sColumnList, java.lang.String sFilter, java.io.OutputStream oOutStrm, java.lang.String sShowAs)` Execute query and print ResultSet to an OutputStream.

Methods inherited from class com.knowgate.dataobjs.DBPersist
`allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, delete, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, store, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Constructor Detail

### QueryByForm

    public QueryByForm(java.lang.String sQBFURI)
                throws java.lang.ClassNotFoundException,
                       java.lang.IllegalAccessException,
                       java.lang.Exception

  Create an empty query by parsing an XML definition file.

  Input file must be encoded as ISO-8859-1

  Parameters:
    `sQBFURI` - URI for query specification XML file (ej. file:///opt/storage/qbf/duties.xml)
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.IllegalAccessException`
    `java.lang.Exception`

### QueryByForm

    public QueryByForm(java.lang.String sQBFURI,
                       java.lang.String sEncoding)
                throws java.lang.ClassNotFoundException,
                       java.lang.IllegalAccessException,
                       java.io.UnsupportedEncodingException,
                       java.lang.Exception

  Create an empty query by parsing an XML definition file.

  Input file must be encoded as ISO-8859-1

  Parameters:
    `sQBFURI` - URI for query specification XML file (ej. file:///opt/storage/qbf/duties.xml)
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.IllegalAccessException`
    `java.io.UnsupportedEncodingException`
    `java.lang.Exception`
  Since:
    3.0

### QueryByForm

    public QueryByForm(JDCConnection oConn,
                       java.lang.String sBaseTable,
                       java.lang.String sTableAlias,
                       java.lang.String sQueryGUID)
                throws java.sql.SQLException

  Load a query from k_queries table.

  Parameters:
    `oConn` - Database Connection
    `sBaseTable` - Query base table or view <baseobject> tag from XML query specification.
    `sTableAlias` - A base table alias for SQL fields
    `sQueryGUID` - Query GUID at k_queries table
  Throws:
    `java.sql.SQLException`

Method Detail

### parseURI

    public void parseURI(java.lang.String sURI,
                         java.lang.String sEncoding)
                  throws java.lang.ClassNotFoundException,
                         java.lang.IllegalAccessException,
                         java.lang.Exception

  Parse query XML specification file.

  Parameters:
    `sURI` - URI for query specification XML file
    `sEncoding` - Character encoding used by XML input file
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.IllegalAccessException`
    `java.io.UnsupportedEncodingException`
    `java.lang.Exception`
  Since:
    3.0

### parseURI

    public void parseURI(java.lang.String sURI)
                  throws java.lang.ClassNotFoundException,
                         java.lang.IllegalAccessException,
                         java.lang.Exception

  Parse query XML specification file.

  Parameters:
    `sURI` - URI for query specification XML file
  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.IllegalAccessException`
    `java.lang.Exception`

### getDocument

    public dom.DOMDocument getDocument()

  Returns:
    DOMDocument object for parsed XML file.

### getAction

    public java.lang.String getAction()

  Returns:
    <action> tag from XML query specification. If tag <action> is not found then null is returned.

### getBaseObject

    public java.lang.String getBaseObject()

  Returns:
    <baseobject> node contents.
    If tag <baseobject> is not found then null is returned.

### getBaseFilter

    public java.lang.String getBaseFilter(HttpServletRequest oReq)

  Get query base filter instantiated for given HttpServletRequest parameters.

  Base filters are neccesary for separating data belonging to an specific workarea for data belonging to other workareas.
  Typically every query specification have a base filter.
  The base filter may contain to types of wildcards ${cookie.name} and ${param.name}
  When one of this wildcards in encountered at base filter specification it is substituded at runtime by the matching HttpServletRequest Cookie or Parameter value.

  Parameters:
    `oReq` - HttpServletRequest containing Cookies and Parameters to be substituted at base filter.
  Returns:
    <basefilter> tag from XML query specification with ${cookie.name} and ${param.name} wildcards substituded by HttpServletRequest getCookies and getParameters values.

### getMethod

    public java.lang.String getMethod()

  Returns:
    <method> tag from XML query specification.
    If tag <method> is not found then null is returned.
  Throws:
    `java.lang.NullPointerException` - if XML document was not previously set on the constructor or by calling parseURI()

### getTitle

    public java.lang.String getTitle(java.lang.String sLanguage)
                              throws java.lang.NullPointerException

  Returns:
    <title_xx> tag from XML query specification, where xx==sLanguage
    If not title is found for given language then "Query" text is returned.
  Throws:
    `java.lang.NullPointerException` - if XML document was not previously set on the constructor or by calling parseURI()

### getFields

    public java.util.Vector getFields()

  Returns:
    Vector of org.w3c.dom.Element objects, one for each <field> tag

### getSortable

    public java.util.Vector getSortable()

  Returns:
    Vector of org.w3c.dom.Element objects, one for each <sortable> tag if <sortable> tag is not found an empty vector is returned and no exception is thrown.

### getColumns

    public java.util.Vector getColumns()
                                throws java.lang.NullPointerException

  Returns:
    Vector of org.w3c.dom.Element objects, one for each <column> tag
  Throws:
    `java.lang.NullPointerException` - If tag <columns> is not found

### composeSQL

    public java.lang.String composeSQL()
                                throws java.lang.NullPointerException

  Compose SQL WHERE clause by concatenating single clauses for each field

  <basefilter> clause is not included in returned String.

  Returns:
    getClause("field1",...) [+ getClause("field2", ...) + [+ getClause("field3", ...)]]
  Throws:
    `java.lang.NullPointerException`

### queryToStream

    public void queryToStream(java.sql.Connection oConn,
                              java.lang.String sColumnList,
                              java.lang.String sFilter,
                              java.io.OutputStream oOutStrm,
                              java.lang.String sShowAs)
                       throws java.sql.SQLException

  Execute query and print ResultSet to an OutputStream.

  Rows are directly fetched from database and printed to OutputStream one by one.

  Parameters:
    `oConn` - Database Connection
    `sColumnList` - Columns to SELECT
    `sFilter` - Full SQL filter clause, including <>
    `oOutStrm` - OutputStream for printing results.
    `sShowAs` - Output Type

    TSV | Tab separated values | Columns are delimited by tabs and rows are delimited by line feeds
    XLS | Excel Default | Columns are delimited by ';' and rows are delimited by line feeds
    CSV | Comma separated values | Columns are delimited by ',' and rows are delimited by line feeds, text is qualified with double quoutes.

  Throws:
    `java.sql.SQLException`

### delete

    public static boolean delete(JDCConnection oConn,
                                 java.lang.String sQBFGUID)
                          throws java.sql.SQLException

  Delete QBF instance from database

  Dynamic Lists using this QBF will be deleted on cascade

  Parameters:
    `oConn` - Database Connection
    `sQBFGUID` - GUID of QBF instance to be deleted.
  Throws:
    `java.sql.SQLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD