wt.epm.util
Class PLSQLQuery

java.lang.Object
  extended bywt.epm.util.PLSQLQuery
Direct Known Subclasses:
NavigateQuery, NavigateToMasterQuery, ObjectQuery

public abstract class PLSQLQuery
extends Object

The PLSQLQuery is a server-side only class that describes a simple SQL query that is executed using PL/SQL stored procedures.

Supported API: false

Extendable: false


Nested Class Summary
static class PLSQLQuery.Operator
           
protected static class PLSQLQuery.WhereExpression
           
 
Field Summary
private  String[] aliases
           
private  int conditionCount
           
static PLSQLQuery.Operator EQUAL
           
private  StringBuffer extraConditions
           
private  boolean includeDescendants
           
static PLSQLQuery.Operator IS_FALSE
           
static PLSQLQuery.Operator IS_TRUE
           
static PLSQLQuery.Operator LIKE
           
static PLSQLQuery.Operator NOT_EQUAL
           
private  Class[] tableClasses
           
 
Constructor Summary
  PLSQLQuery(Class tableClass)
          Constructs a PLSQLQuery for the given object class.
protected PLSQLQuery(Class[] tableClasses, String[] aliases)
           
 
Method Summary
 void appendAnd()
          Appends an AND condition to the WHERE clause.
 void appendCloseParen()
          Appends a closed parenthesis to the WHERE clause.
 void appendOpenParen()
          Appends an open parenthesis to the WHERE clause.
 void appendOr()
          Appends an OR condition to the WHERE clause.
protected  void appendWhere(PLSQLQuery.WhereExpression expression, int fromIndex)
           
 void appendWhere(String attribute, PLSQLQuery.Operator op)
          Appends a search condition for a boolean attribute to the WHERE clause.
 void appendWhere(String attribute, PLSQLQuery.Operator op, EnumeratedType value)
          Appends a search condition for an enumerated type attribute to the WHERE clause.
 void appendWhere(String attribute, PLSQLQuery.Operator op, int value)
          Appends a search condition for an integer attribute to the WHERE clause.
 void appendWhere(String attribute, PLSQLQuery.Operator op, long value)
          Appends a search condition for a long attribute to the WHERE clause.
 void appendWhere(String attribute, PLSQLQuery.Operator op, String value)
          Appends a search condition for a string attribute to the WHERE clause.
protected abstract  String buildFromClause()
          Builds FROM clause.
static ObjectIdentifier buildObjectId(Object className, Object databaseId)
          Builds an ObjectIdentifier from raw data returned from a stored procedure.
protected abstract  Object buildResult(Object[] rawData)
          Builds a result using the raw data returned by the stored procedure.
 List buildResults(Object[] rawDataArray)
          Builds the results using the raw data returned by the stored procedure.
protected abstract  String buildSelectStatement()
          Builds SELECT statement.
 String buildSQLStatement()
          Builds the SQL statement to send to the stored procedure.
protected abstract  String buildWhereClause()
          Builds WHERE clause.
 String getAlias(int fromIndex)
           
protected static String getColumnName(Class linkClass, LinkProxy.Role role)
          Given a link class and a role, find the name of the database column for the role identifier.
protected static String getColumnName(Class objectClass, String attribute)
          Given an object class and the name of an attribute on that class, find the name of the database column for that attribute.
 int getConditionCount()
           
protected abstract  String getSQLFunctionName()
          Returns the name of the stored procedure to call.
protected abstract  StatementParameter[] getSQLFunctionParameters()
          Returns an array of parameters to pass to the stored procedure.
protected abstract  StatementParameter getSQLFunctionReturnType()
          Returns the type of parameter the stored procedure is expected to return.
 Class getTableClass(int fromIndex)
           
static String[] getTableNames(Class objectClass)
          Returns the names of the database tables for the given object class and its subclasses.
protected  String[] getTableNames(int fromIndex)
          Returns the names of the database tables for the object class at given index in the FROM clause and its subclasses.
 void setIncludeDescendants(boolean includeDescendants)
          Whether or not to query the database tables for all of the subclasses of the object class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUAL

public static final PLSQLQuery.Operator EQUAL

NOT_EQUAL

public static final PLSQLQuery.Operator NOT_EQUAL

IS_TRUE

public static final PLSQLQuery.Operator IS_TRUE

IS_FALSE

public static final PLSQLQuery.Operator IS_FALSE

LIKE

public static final PLSQLQuery.Operator LIKE

tableClasses

private Class[] tableClasses

aliases

private String[] aliases

extraConditions

private StringBuffer extraConditions

conditionCount

private int conditionCount

includeDescendants

private boolean includeDescendants
Constructor Detail

PLSQLQuery

public PLSQLQuery(Class tableClass)
           throws WTException
Constructs a PLSQLQuery for the given object class.


PLSQLQuery

protected PLSQLQuery(Class[] tableClasses,
                     String[] aliases)
              throws WTException
Method Detail

getTableClass

public Class getTableClass(int fromIndex)

getAlias

public String getAlias(int fromIndex)

getConditionCount

public int getConditionCount()

setIncludeDescendants

public void setIncludeDescendants(boolean includeDescendants)
Whether or not to query the database tables for all of the subclasses of the object class.


buildSQLStatement

public String buildSQLStatement()
                         throws WTException
Builds the SQL statement to send to the stored procedure.

Throws:
WTException

buildResults

public List buildResults(Object[] rawDataArray)
                  throws WTException
Builds the results using the raw data returned by the stored procedure.

Throws:
WTException

toString

public String toString()

getTableNames

protected String[] getTableNames(int fromIndex)
                          throws WTException
Returns the names of the database tables for the object class at given index in the FROM clause and its subclasses. If includeDescendants is false, only only the name of the database table for the object class is returned.

Throws:
WTException

buildSelectStatement

protected abstract String buildSelectStatement()
                                        throws WTException
Builds SELECT statement.

Throws:
WTException

buildFromClause

protected abstract String buildFromClause()
                                   throws WTException
Builds FROM clause.

Throws:
WTException

buildWhereClause

protected abstract String buildWhereClause()
                                    throws WTException
Builds WHERE clause.

Throws:
WTException

buildResult

protected abstract Object buildResult(Object[] rawData)
                               throws WTException
Builds a result using the raw data returned by the stored procedure.

Throws:
WTException

getSQLFunctionName

protected abstract String getSQLFunctionName()
Returns the name of the stored procedure to call.


getSQLFunctionParameters

protected abstract StatementParameter[] getSQLFunctionParameters()
                                                          throws WTException
Returns an array of parameters to pass to the stored procedure.

Throws:
WTException

getSQLFunctionReturnType

protected abstract StatementParameter getSQLFunctionReturnType()
                                                        throws WTException
Returns the type of parameter the stored procedure is expected to return.

Throws:
WTException

appendAnd

public void appendAnd()
Appends an AND condition to the WHERE clause.


appendOr

public void appendOr()
Appends an OR condition to the WHERE clause.


appendOpenParen

public void appendOpenParen()
Appends an open parenthesis to the WHERE clause.


appendCloseParen

public void appendCloseParen()
Appends a closed parenthesis to the WHERE clause.


appendWhere

public void appendWhere(String attribute,
                        PLSQLQuery.Operator op)
                 throws WTException
Appends a search condition for a boolean attribute to the WHERE clause.

Throws:
WTException

appendWhere

public void appendWhere(String attribute,
                        PLSQLQuery.Operator op,
                        int value)
                 throws WTException
Appends a search condition for an integer attribute to the WHERE clause.

Throws:
WTException

appendWhere

public void appendWhere(String attribute,
                        PLSQLQuery.Operator op,
                        long value)
                 throws WTException
Appends a search condition for a long attribute to the WHERE clause.

Throws:
WTException

appendWhere

public void appendWhere(String attribute,
                        PLSQLQuery.Operator op,
                        String value)
                 throws WTException
Appends a search condition for a string attribute to the WHERE clause.

Throws:
WTException

appendWhere

public void appendWhere(String attribute,
                        PLSQLQuery.Operator op,
                        EnumeratedType value)
                 throws WTException
Appends a search condition for an enumerated type attribute to the WHERE clause.

Throws:
WTException

appendWhere

protected void appendWhere(PLSQLQuery.WhereExpression expression,
                           int fromIndex)
                    throws WTException
Throws:
WTException

getTableNames

public static String[] getTableNames(Class objectClass)
                              throws WTException
Returns the names of the database tables for the given object class and its subclasses.

Throws:
WTException

buildObjectId

public static ObjectIdentifier buildObjectId(Object className,
                                             Object databaseId)
                                      throws WTException
Builds an ObjectIdentifier from raw data returned from a stored procedure.

Throws:
WTException

getColumnName

protected static String getColumnName(Class objectClass,
                                      String attribute)
                               throws WTException
Given an object class and the name of an attribute on that class, find the name of the database column for that attribute.

Throws:
WTException

getColumnName

protected static String getColumnName(Class linkClass,
                                      LinkProxy.Role role)
                               throws WTException
Given a link class and a role, find the name of the database column for the role identifier. This method accepts ObjectToObjectLink, VersionToVersionLink and ObjectToVersionLink. ForeignKeyLink is NOT supported.

Throws:
WTException