org.sandev.tools.JDBC
Class THD_QueryProcessor

java.lang.Object
  extended byorg.sandev.tools.JDBC.THD_QueryProcessor

public class THD_QueryProcessor
extends java.lang.Object

A SandQueryMessage processor for standard SQL. AUTOGENERATED FILE, DO NOT EDIT DIRECTLY.
source: declared in build
generator: org.sandev.generator.SQLQueryProcessorGenerator
time: Dec 2, 2005 6:38:59 PM


Field Summary
static java.lang.String externalPlanQueryConnector
          The static connector phrase for all ExternalPlanQuery processing
static java.lang.String externalPlanQueryPreamble
          The static preamble for all ExternalPlanQuery processing
static java.lang.String heapAttributesQueryConnector
          The static connector phrase for all HeapAttributesQuery processing
static java.lang.String heapAttributesQueryPreamble
          The static preamble for all HeapAttributesQuery processing
static java.lang.String planComponentQueryConnector
          The static connector phrase for all PlanComponentQuery processing
static java.lang.String planComponentQueryPreamble
          The static preamble for all PlanComponentQuery processing
static java.lang.String planQueryConnector
          The static connector phrase for all PlanQuery processing
static java.lang.String planQueryPreamble
          The static preamble for all PlanQuery processing
static java.lang.String readerQueryConnector
          The static connector phrase for all ReaderQuery processing
static java.lang.String readerQueryPreamble
          The static preamble for all ReaderQuery processing
static java.lang.String resourceQueryConnector
          The static connector phrase for all ResourceQuery processing
static java.lang.String resourceQueryPreamble
          The static preamble for all ResourceQuery processing
static java.lang.String taskPhaseQueryConnector
          The static connector phrase for all TaskPhaseQuery processing
static java.lang.String taskPhaseQueryPreamble
          The static preamble for all TaskPhaseQuery processing
static java.lang.String taskQueryConnector
          The static connector phrase for all TaskQuery processing
static java.lang.String taskQueryPreamble
          The static preamble for all TaskQuery processing
static java.lang.String taskTypeQueryConnector
          The static connector phrase for all TaskTypeQuery processing
static java.lang.String taskTypeQueryPreamble
          The static preamble for all TaskTypeQuery processing
 
Constructor Summary
THD_QueryProcessor()
           
 
Method Summary
static org.sandev.TaskHeap.sandmessages.ExternalPlanCollection doExternalPlanQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.ExternalPlanQuery query)
          Process a ExternalPlanQuery.
static org.sandev.TaskHeap.sandmessages.HeapAttributesCollection doHeapAttributesQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.HeapAttributesQuery query)
          Process a HeapAttributesQuery.
static org.sandev.TaskHeap.sandmessages.PlanComponentCollection doPlanComponentQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.PlanComponentQuery query)
          Process a PlanComponentQuery.
static org.sandev.TaskHeap.sandmessages.PlanCollection doPlanQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.PlanQuery query)
          Process a PlanQuery.
static org.sandev.basics.structs.SandCollectionMessage doQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.basics.structs.SandQueryMessage query)
          Process the specified query and return the result.
static org.sandev.TaskHeap.sandmessages.ReaderCollection doReaderQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.ReaderQuery query)
          Process a ReaderQuery.
static org.sandev.TaskHeap.sandmessages.ResourceCollection doResourceQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.ResourceQuery query)
          Process a ResourceQuery.
static org.sandev.TaskHeap.sandmessages.TaskPhaseCollection doTaskPhaseQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.TaskPhaseQuery query)
          Process a TaskPhaseQuery.
static org.sandev.TaskHeap.sandmessages.TaskCollection doTaskQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.TaskQuery query)
          Process a TaskQuery.
static org.sandev.TaskHeap.sandmessages.TaskTypeCollection doTaskTypeQuery(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.Connection conn, org.sandev.TaskHeap.sandmessages.TaskTypeQuery query)
          Process a TaskTypeQuery.
static java.lang.String formatNumber(double dbl)
          All numbers come out of the StreamTokenizer as a double value, which doesn't help for matching because looking for 1.0 when the field is an integer type is generally illegal.
protected static java.lang.String getAggregateFunctionSQL(org.sandev.basics.structs.SandQueryMessage query)
          Return the select clause of the aggregate query, or null if anything is wrong.
static org.sandev.TaskHeap.sandmessages.ExternalPlanCollection getExternalPlanCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a ExternalPlanCollection for it.
static java.lang.String getExternalPlanPrefixedAttr(java.lang.String attr)
          Prefix a ExternalPlan attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getExternalPlanSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getExternalPlanSQL method and subselect processing
static void getExternalPlanSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a ExternalPlanQuery, return the SQL for it.
static org.sandev.TaskHeap.sandmessages.HeapAttributesCollection getHeapAttributesCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a HeapAttributesCollection for it.
static java.lang.String getHeapAttributesPrefixedAttr(java.lang.String attr)
          Prefix a HeapAttributes attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getHeapAttributesSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getHeapAttributesSQL method and subselect processing
static void getHeapAttributesSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a HeapAttributesQuery, return the SQL for it.
static org.sandev.TaskHeap.sandmessages.PlanCollection getPlanCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a PlanCollection for it.
static org.sandev.TaskHeap.sandmessages.PlanComponentCollection getPlanComponentCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a PlanComponentCollection for it.
static java.lang.String getPlanComponentPrefixedAttr(java.lang.String attr)
          Prefix a PlanComponent attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getPlanComponentSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getPlanComponentSQL method and subselect processing
static void getPlanComponentSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a PlanComponentQuery, return the SQL for it.
static java.lang.String getPlanPrefixedAttr(java.lang.String attr)
          Prefix a Plan attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getPlanSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getPlanSQL method and subselect processing
static void getPlanSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a PlanQuery, return the SQL for it.
static org.sandev.TaskHeap.sandmessages.ReaderCollection getReaderCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a ReaderCollection for it.
static java.lang.String getReaderPrefixedAttr(java.lang.String attr)
          Prefix a Reader attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getReaderSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getReaderSQL method and subselect processing
static void getReaderSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a ReaderQuery, return the SQL for it.
static org.sandev.TaskHeap.sandmessages.ResourceCollection getResourceCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a ResourceCollection for it.
static java.lang.String getResourcePrefixedAttr(java.lang.String attr)
          Prefix a Resource attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getResourceSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getResourceSQL method and subselect processing
static void getResourceSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a ResourceQuery, return the SQL for it.
protected static java.io.StreamTokenizer getStreamToker(java.io.BufferedReader in)
          Factored method to return a new StreamTokenizer
static org.sandev.TaskHeap.sandmessages.TaskCollection getTaskCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a TaskCollection for it.
static org.sandev.TaskHeap.sandmessages.TaskPhaseCollection getTaskPhaseCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a TaskPhaseCollection for it.
static java.lang.String getTaskPhasePrefixedAttr(java.lang.String attr)
          Prefix a TaskPhase attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getTaskPhaseSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getTaskPhaseSQL method and subselect processing
static void getTaskPhaseSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a TaskPhaseQuery, return the SQL for it.
static java.lang.String getTaskPrefixedAttr(java.lang.String attr)
          Prefix a Task attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getTaskSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getTaskSQL method and subselect processing
static void getTaskSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a TaskQuery, return the SQL for it.
static org.sandev.TaskHeap.sandmessages.TaskTypeCollection getTaskTypeCollection(org.sandev.basics.DataManager.DataManagerNode dm, java.sql.ResultSet rs)
          Given a result set, return a TaskTypeCollection for it.
static java.lang.String getTaskTypePrefixedAttr(java.lang.String attr)
          Prefix a TaskType attribute appropriately so that the resulting WHERE clause is unambiguous.
static void getTaskTypeSQL(java.lang.StringBuffer buf, java.util.SortedMap smap)
          Workhorse method for the general getTaskTypeSQL method and subselect processing
static void getTaskTypeSQL(java.lang.StringBuffer buf, java.util.SortedMap smap, long uidAfter)
          Given a TaskTypeQuery, return the SQL for it.
protected static boolean handleClassSubselect(java.lang.String fieldspec, java.lang.StringBuffer buf, java.util.SortedMap clauses)
          For each entry in the clauses that specifies a class, create an appropriate subselect clause.
protected static long[] loadRefArray(java.lang.String tableName, java.lang.String parentField, java.lang.String childField, java.lang.String indexField, long parentID, java.sql.Connection conn)
          Given the name of the array relation, retrieve the child references.
static java.lang.String matchExprToSQL(java.lang.String attr, java.lang.String val)
          Setup for work
static java.lang.String matchExprToSQLWork(java.lang.String attr, java.io.StreamTokenizer st)
          Convert the specified expression into a SQL statement.
protected static void securityCheckValue(java.lang.String value)
          Make sure the given value isn't some kind of embedded SQL call trying to hack around in the db.
protected static void setFunctionResult(org.sandev.basics.structs.SandCollectionMessage coll, org.sandev.basics.structs.SandQueryMessage query, java.sql.ResultSet rs)
          Set the result field in the collection based on the fields from the query and the result we got back.
static java.lang.String wordquote(java.lang.String word)
          This method would still be necessary if we were using the parameter substitution in a prepared statement.
protected static boolean writeClassSubselect(java.lang.String fieldspec, java.lang.StringBuffer buf, java.lang.String classname, java.util.SortedMap subclause)
          Write a subselect for the given class, matching on the attribute and value specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

externalPlanQueryPreamble

public static final java.lang.String externalPlanQueryPreamble
The static preamble for all ExternalPlanQuery processing

See Also:
Constant Field Values

externalPlanQueryConnector

public static final java.lang.String externalPlanQueryConnector
The static connector phrase for all ExternalPlanQuery processing

See Also:
Constant Field Values

heapAttributesQueryPreamble

public static final java.lang.String heapAttributesQueryPreamble
The static preamble for all HeapAttributesQuery processing

See Also:
Constant Field Values

heapAttributesQueryConnector

public static final java.lang.String heapAttributesQueryConnector
The static connector phrase for all HeapAttributesQuery processing

See Also:
Constant Field Values

planComponentQueryPreamble

public static final java.lang.String planComponentQueryPreamble
The static preamble for all PlanComponentQuery processing

See Also:
Constant Field Values

planComponentQueryConnector

public static final java.lang.String planComponentQueryConnector
The static connector phrase for all PlanComponentQuery processing

See Also:
Constant Field Values

planQueryPreamble

public static final java.lang.String planQueryPreamble
The static preamble for all PlanQuery processing

See Also:
Constant Field Values

planQueryConnector

public static final java.lang.String planQueryConnector
The static connector phrase for all PlanQuery processing

See Also:
Constant Field Values

readerQueryPreamble

public static final java.lang.String readerQueryPreamble
The static preamble for all ReaderQuery processing

See Also:
Constant Field Values

readerQueryConnector

public static final java.lang.String readerQueryConnector
The static connector phrase for all ReaderQuery processing

See Also:
Constant Field Values

resourceQueryPreamble

public static final java.lang.String resourceQueryPreamble
The static preamble for all ResourceQuery processing

See Also:
Constant Field Values

resourceQueryConnector

public static final java.lang.String resourceQueryConnector
The static connector phrase for all ResourceQuery processing

See Also:
Constant Field Values

taskPhaseQueryPreamble

public static final java.lang.String taskPhaseQueryPreamble
The static preamble for all TaskPhaseQuery processing

See Also:
Constant Field Values

taskPhaseQueryConnector

public static final java.lang.String taskPhaseQueryConnector
The static connector phrase for all TaskPhaseQuery processing

See Also:
Constant Field Values

taskQueryPreamble

public static final java.lang.String taskQueryPreamble
The static preamble for all TaskQuery processing

See Also:
Constant Field Values

taskQueryConnector

public static final java.lang.String taskQueryConnector
The static connector phrase for all TaskQuery processing

See Also:
Constant Field Values

taskTypeQueryPreamble

public static final java.lang.String taskTypeQueryPreamble
The static preamble for all TaskTypeQuery processing

See Also:
Constant Field Values

taskTypeQueryConnector

public static final java.lang.String taskTypeQueryConnector
The static connector phrase for all TaskTypeQuery processing

See Also:
Constant Field Values
Constructor Detail

THD_QueryProcessor

public THD_QueryProcessor()
Method Detail

doQuery

public static org.sandev.basics.structs.SandCollectionMessage doQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                      java.sql.Connection conn,
                                                                      org.sandev.basics.structs.SandQueryMessage query)
                                                               throws java.sql.SQLException
Process the specified query and return the result.

Throws:
java.sql.SQLException

doExternalPlanQuery

public static org.sandev.TaskHeap.sandmessages.ExternalPlanCollection doExternalPlanQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                          java.sql.Connection conn,
                                                                                          org.sandev.TaskHeap.sandmessages.ExternalPlanQuery query)
                                                                                   throws java.sql.SQLException
Process a ExternalPlanQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getExternalPlanSQL

public static void getExternalPlanSQL(java.lang.StringBuffer buf,
                                      java.util.SortedMap smap,
                                      long uidAfter)
                               throws java.sql.SQLException
Given a ExternalPlanQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getExternalPlanSQL

public static void getExternalPlanSQL(java.lang.StringBuffer buf,
                                      java.util.SortedMap smap)
                               throws java.sql.SQLException
Workhorse method for the general getExternalPlanSQL method and subselect processing

Throws:
java.sql.SQLException

getExternalPlanPrefixedAttr

public static java.lang.String getExternalPlanPrefixedAttr(java.lang.String attr)
Prefix a ExternalPlan attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: PlanComponentStruct ExternalPlanStruct


getExternalPlanCollection

public static org.sandev.TaskHeap.sandmessages.ExternalPlanCollection getExternalPlanCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                                java.sql.ResultSet rs)
                                                                                         throws java.sql.SQLException
Given a result set, return a ExternalPlanCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doHeapAttributesQuery

public static org.sandev.TaskHeap.sandmessages.HeapAttributesCollection doHeapAttributesQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                              java.sql.Connection conn,
                                                                                              org.sandev.TaskHeap.sandmessages.HeapAttributesQuery query)
                                                                                       throws java.sql.SQLException
Process a HeapAttributesQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getHeapAttributesSQL

public static void getHeapAttributesSQL(java.lang.StringBuffer buf,
                                        java.util.SortedMap smap,
                                        long uidAfter)
                                 throws java.sql.SQLException
Given a HeapAttributesQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getHeapAttributesSQL

public static void getHeapAttributesSQL(java.lang.StringBuffer buf,
                                        java.util.SortedMap smap)
                                 throws java.sql.SQLException
Workhorse method for the general getHeapAttributesSQL method and subselect processing

Throws:
java.sql.SQLException

getHeapAttributesPrefixedAttr

public static java.lang.String getHeapAttributesPrefixedAttr(java.lang.String attr)
Prefix a HeapAttributes attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: HeapAttributesStruct


getHeapAttributesCollection

public static org.sandev.TaskHeap.sandmessages.HeapAttributesCollection getHeapAttributesCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                                    java.sql.ResultSet rs)
                                                                                             throws java.sql.SQLException
Given a result set, return a HeapAttributesCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doPlanComponentQuery

public static org.sandev.TaskHeap.sandmessages.PlanComponentCollection doPlanComponentQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                            java.sql.Connection conn,
                                                                                            org.sandev.TaskHeap.sandmessages.PlanComponentQuery query)
                                                                                     throws java.sql.SQLException
Process a PlanComponentQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getPlanComponentSQL

public static void getPlanComponentSQL(java.lang.StringBuffer buf,
                                       java.util.SortedMap smap,
                                       long uidAfter)
                                throws java.sql.SQLException
Given a PlanComponentQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getPlanComponentSQL

public static void getPlanComponentSQL(java.lang.StringBuffer buf,
                                       java.util.SortedMap smap)
                                throws java.sql.SQLException
Workhorse method for the general getPlanComponentSQL method and subselect processing

Throws:
java.sql.SQLException

getPlanComponentPrefixedAttr

public static java.lang.String getPlanComponentPrefixedAttr(java.lang.String attr)
Prefix a PlanComponent attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: PlanComponentStruct


getPlanComponentCollection

public static org.sandev.TaskHeap.sandmessages.PlanComponentCollection getPlanComponentCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                                  java.sql.ResultSet rs)
                                                                                           throws java.sql.SQLException
Given a result set, return a PlanComponentCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doPlanQuery

public static org.sandev.TaskHeap.sandmessages.PlanCollection doPlanQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                          java.sql.Connection conn,
                                                                          org.sandev.TaskHeap.sandmessages.PlanQuery query)
                                                                   throws java.sql.SQLException
Process a PlanQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getPlanSQL

public static void getPlanSQL(java.lang.StringBuffer buf,
                              java.util.SortedMap smap,
                              long uidAfter)
                       throws java.sql.SQLException
Given a PlanQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getPlanSQL

public static void getPlanSQL(java.lang.StringBuffer buf,
                              java.util.SortedMap smap)
                       throws java.sql.SQLException
Workhorse method for the general getPlanSQL method and subselect processing

Throws:
java.sql.SQLException

getPlanPrefixedAttr

public static java.lang.String getPlanPrefixedAttr(java.lang.String attr)
Prefix a Plan attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: PlanComponentStruct PlanStruct


getPlanCollection

public static org.sandev.TaskHeap.sandmessages.PlanCollection getPlanCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                java.sql.ResultSet rs)
                                                                         throws java.sql.SQLException
Given a result set, return a PlanCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doReaderQuery

public static org.sandev.TaskHeap.sandmessages.ReaderCollection doReaderQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                              java.sql.Connection conn,
                                                                              org.sandev.TaskHeap.sandmessages.ReaderQuery query)
                                                                       throws java.sql.SQLException
Process a ReaderQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getReaderSQL

public static void getReaderSQL(java.lang.StringBuffer buf,
                                java.util.SortedMap smap,
                                long uidAfter)
                         throws java.sql.SQLException
Given a ReaderQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getReaderSQL

public static void getReaderSQL(java.lang.StringBuffer buf,
                                java.util.SortedMap smap)
                         throws java.sql.SQLException
Workhorse method for the general getReaderSQL method and subselect processing

Throws:
java.sql.SQLException

getReaderPrefixedAttr

public static java.lang.String getReaderPrefixedAttr(java.lang.String attr)
Prefix a Reader attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: ReaderStruct


getReaderCollection

public static org.sandev.TaskHeap.sandmessages.ReaderCollection getReaderCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                    java.sql.ResultSet rs)
                                                                             throws java.sql.SQLException
Given a result set, return a ReaderCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doResourceQuery

public static org.sandev.TaskHeap.sandmessages.ResourceCollection doResourceQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                  java.sql.Connection conn,
                                                                                  org.sandev.TaskHeap.sandmessages.ResourceQuery query)
                                                                           throws java.sql.SQLException
Process a ResourceQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getResourceSQL

public static void getResourceSQL(java.lang.StringBuffer buf,
                                  java.util.SortedMap smap,
                                  long uidAfter)
                           throws java.sql.SQLException
Given a ResourceQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getResourceSQL

public static void getResourceSQL(java.lang.StringBuffer buf,
                                  java.util.SortedMap smap)
                           throws java.sql.SQLException
Workhorse method for the general getResourceSQL method and subselect processing

Throws:
java.sql.SQLException

getResourcePrefixedAttr

public static java.lang.String getResourcePrefixedAttr(java.lang.String attr)
Prefix a Resource attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: ReaderStruct ResourceStruct


getResourceCollection

public static org.sandev.TaskHeap.sandmessages.ResourceCollection getResourceCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                        java.sql.ResultSet rs)
                                                                                 throws java.sql.SQLException
Given a result set, return a ResourceCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doTaskPhaseQuery

public static org.sandev.TaskHeap.sandmessages.TaskPhaseCollection doTaskPhaseQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                    java.sql.Connection conn,
                                                                                    org.sandev.TaskHeap.sandmessages.TaskPhaseQuery query)
                                                                             throws java.sql.SQLException
Process a TaskPhaseQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getTaskPhaseSQL

public static void getTaskPhaseSQL(java.lang.StringBuffer buf,
                                   java.util.SortedMap smap,
                                   long uidAfter)
                            throws java.sql.SQLException
Given a TaskPhaseQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getTaskPhaseSQL

public static void getTaskPhaseSQL(java.lang.StringBuffer buf,
                                   java.util.SortedMap smap)
                            throws java.sql.SQLException
Workhorse method for the general getTaskPhaseSQL method and subselect processing

Throws:
java.sql.SQLException

getTaskPhasePrefixedAttr

public static java.lang.String getTaskPhasePrefixedAttr(java.lang.String attr)
Prefix a TaskPhase attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: TaskPhaseStruct


getTaskPhaseCollection

public static org.sandev.TaskHeap.sandmessages.TaskPhaseCollection getTaskPhaseCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                          java.sql.ResultSet rs)
                                                                                   throws java.sql.SQLException
Given a result set, return a TaskPhaseCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doTaskQuery

public static org.sandev.TaskHeap.sandmessages.TaskCollection doTaskQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                          java.sql.Connection conn,
                                                                          org.sandev.TaskHeap.sandmessages.TaskQuery query)
                                                                   throws java.sql.SQLException
Process a TaskQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getTaskSQL

public static void getTaskSQL(java.lang.StringBuffer buf,
                              java.util.SortedMap smap,
                              long uidAfter)
                       throws java.sql.SQLException
Given a TaskQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getTaskSQL

public static void getTaskSQL(java.lang.StringBuffer buf,
                              java.util.SortedMap smap)
                       throws java.sql.SQLException
Workhorse method for the general getTaskSQL method and subselect processing

Throws:
java.sql.SQLException

getTaskPrefixedAttr

public static java.lang.String getTaskPrefixedAttr(java.lang.String attr)
Prefix a Task attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: PlanComponentStruct TaskStruct


getTaskCollection

public static org.sandev.TaskHeap.sandmessages.TaskCollection getTaskCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                java.sql.ResultSet rs)
                                                                         throws java.sql.SQLException
Given a result set, return a TaskCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

doTaskTypeQuery

public static org.sandev.TaskHeap.sandmessages.TaskTypeCollection doTaskTypeQuery(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                  java.sql.Connection conn,
                                                                                  org.sandev.TaskHeap.sandmessages.TaskTypeQuery query)
                                                                           throws java.sql.SQLException
Process a TaskTypeQuery. If ORDER BY is not specified, then the default ordering is by uniqueID. Each query contains two tests for the uniqueID key: the first checks it is greater than zero, which serves as an anchor test for subsequent join restrictions. The second test implements the uniqueIDAfter restriction as specified in the query. For dataset pagination to work, we need to return one more row than what was asked for in getMaxReturn for the query. Otherwise the pagination code won't know there is more data available. Support for query limiting varies, so we set the max both in the statement object parameter, and in the SQL itself. Just setting this in the statement object is not generally reliable. SQL query limitation is accomplished via SELECT TOP N.

Throws:
java.sql.SQLException

getTaskTypeSQL

public static void getTaskTypeSQL(java.lang.StringBuffer buf,
                                  java.util.SortedMap smap,
                                  long uidAfter)
                           throws java.sql.SQLException
Given a TaskTypeQuery, return the SQL for it. The generated SQL is appended to the provided StringBuffer, the input match expressions for processing are contained in the sorted map. The attribute comparisons are case sensitive, the assumption is that these are generated from forms, so they should be consistent.

Throws:
java.sql.SQLException

getTaskTypeSQL

public static void getTaskTypeSQL(java.lang.StringBuffer buf,
                                  java.util.SortedMap smap)
                           throws java.sql.SQLException
Workhorse method for the general getTaskTypeSQL method and subselect processing

Throws:
java.sql.SQLException

getTaskTypePrefixedAttr

public static java.lang.String getTaskTypePrefixedAttr(java.lang.String attr)
Prefix a TaskType attribute appropriately so that the resulting WHERE clause is unambiguous. Inheritance hierarchy: TaskTypeStruct


getTaskTypeCollection

public static org.sandev.TaskHeap.sandmessages.TaskTypeCollection getTaskTypeCollection(org.sandev.basics.DataManager.DataManagerNode dm,
                                                                                        java.sql.ResultSet rs)
                                                                                 throws java.sql.SQLException
Given a result set, return a TaskTypeCollection for it. Note that reference arrays are NOT filled in here.

Throws:
java.sql.SQLException

handleClassSubselect

protected static boolean handleClassSubselect(java.lang.String fieldspec,
                                              java.lang.StringBuffer buf,
                                              java.util.SortedMap clauses)
                                       throws java.sql.SQLException
For each entry in the clauses that specifies a class, create an appropriate subselect clause. This method might want to combine multiple clauses with the same prefix, but for now it does each one individually. That may be less efficient, but it is at least multiple level traversal should be safe. The specified class clauses are removed from the sorted map, so anything remaining in the map is processed normally.

If FooStruct has-a BarStruct reference mybar, and BazStruct extends BarStruct adding an int field called age, then you can query for Foos having a Baz with age > 18 with FooQuery matchInfo like:

This will probably become a standard part of the match expression, and we'll update the SandQueryMessage description to mention it. For now we want to give this some time before that to make sure it is the right solution. There are security implications here also which should be mentioned in the AuthFilter.messageInstanceAccess description. What classes can be specified explicitely under what circumstances should be authorized.

This method returns true if a subselect was written, false otherwise. This is to allow the caller to handle AND conjunctions in the total SQL being produced.

Throws:
java.sql.SQLException

writeClassSubselect

protected static boolean writeClassSubselect(java.lang.String fieldspec,
                                             java.lang.StringBuffer buf,
                                             java.lang.String classname,
                                             java.util.SortedMap subclause)
                                      throws java.sql.SQLException
Write a subselect for the given class, matching on the attribute and value specified. Return true if any SQL was written, false otherwise.

Throws:
java.sql.SQLException

loadRefArray

protected static long[] loadRefArray(java.lang.String tableName,
                                     java.lang.String parentField,
                                     java.lang.String childField,
                                     java.lang.String indexField,
                                     long parentID,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Given the name of the array relation, retrieve the child references.

Throws:
java.sql.SQLException

getStreamToker

protected static java.io.StreamTokenizer getStreamToker(java.io.BufferedReader in)
Factored method to return a new StreamTokenizer


matchExprToSQL

public static java.lang.String matchExprToSQL(java.lang.String attr,
                                              java.lang.String val)
                                       throws java.sql.SQLException
Setup for work

Throws:
java.sql.SQLException

wordquote

public static java.lang.String wordquote(java.lang.String word)
This method would still be necessary if we were using the parameter substitution in a prepared statement. The problem is that when a user fills out the match expression in a form, they may or may not quote the string values. We are supposed to get expressions that are appropriately quoted, but some minimal defensive triage here is a good thing.


formatNumber

public static java.lang.String formatNumber(double dbl)
All numbers come out of the StreamTokenizer as a double value, which doesn't help for matching because looking for 1.0 when the field is an integer type is generally illegal. So we have to strip the trailing ".0" in this case.


matchExprToSQLWork

public static java.lang.String matchExprToSQLWork(java.lang.String attr,
                                                  java.io.StreamTokenizer st)
                                           throws java.io.IOException
Convert the specified expression into a SQL statement. The idea here is to perform the conversion using only basic syntactic manipulation (and not writing a whole interpretive cross compiler). Essentially we go through the value String and prepend the attr to each of the base operators. So for example:
     >= 0 AND <= 12
 
turns into
     attr >= 0 AND attr <= 12
 

The operators we pick up on are <, <=, >, >=, =, !=

That means that '<', '>', are potential prefixes, '!' is always a prefix, '=' is always a terminal, and a word is always a terminal. If only a value is given, then operator = is assumed. This only has to support cases where only a value is given.

Throws:
java.io.IOException

securityCheckValue

protected static void securityCheckValue(java.lang.String value)
                                  throws java.sql.SQLException
Make sure the given value isn't some kind of embedded SQL call trying to hack around in the db. The account used to access the database must also be appropriately restricted.

Throws:
java.sql.SQLException

getAggregateFunctionSQL

protected static java.lang.String getAggregateFunctionSQL(org.sandev.basics.structs.SandQueryMessage query)
Return the select clause of the aggregate query, or null if anything is wrong.


setFunctionResult

protected static void setFunctionResult(org.sandev.basics.structs.SandCollectionMessage coll,
                                        org.sandev.basics.structs.SandQueryMessage query,
                                        java.sql.ResultSet rs)
                                 throws java.sql.SQLException
Set the result field in the collection based on the fields from the query and the result we got back.

Throws:
java.sql.SQLException