|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dbforms.config.Table
public class Table
This class represents a table tag in dbforms-config.xml (dbforms config xml
file).
It also defines a lot of methods for preparing and actually performing
operations (queries) on the table
| Field Summary | |
|---|---|
static int |
BLOB_CLASSIC
DOCUMENT ME! |
static int |
BLOB_INTERCEPTOR
either "classic" or "interceptor", default is "interceptor" |
protected static int |
CALC_FIELD
DOCUMENT ME! |
protected static int |
DB_FIELD
DOCUMENT ME! |
protected static int |
SEARCH_FIELD
DOCUMENT ME! |
| Constructor Summary | |
|---|---|
Table()
|
|
| Method Summary | |
|---|---|
void |
addCalcField(Field field)
adds a Field-Object to this table and puts it into othere datastructure for further references (this method gets called from DbFormsConfig) |
void |
addField(Field field)
Adds a Field-Object to this table and puts it into othere datastructure for further references (this method gets called from DbFormsConfig) |
void |
addForeignKey(ForeignKey fk)
Adds a ForeignKey-Object to this table and puts it into othere datastructure for further references (this method gets called from DbFormsConfig) |
void |
addInterceptor(Interceptor interceptor)
Add an interceptor to this table. |
protected boolean |
checkFieldId(int type,
int aid)
DOCUMENT ME! |
boolean |
containsDiskblob()
Determinates if this table contains a diskblob field. |
FieldValue[] |
createOrderFieldValues(String order,
HttpServletRequest request,
boolean includeKeys)
Column ["ASC" | "DESC"] {"," Column ["ASC" | "DESC"] } (if neither ASC nor DESC follow "Col", then ASC is choosen as default). |
protected int |
decodeFieldId(int type,
int aid)
DOCUMENT ME! |
ResultSetVector |
doConstrainedSelect(FieldValue[] fvEqual,
FieldValue[] fvOrder,
String sqlFilter,
FieldValue[] sqlFilterParams,
int compareMode,
int maxRows,
DbEventInterceptorData interceptorData)
Do a constrained select. |
ResultSetVector |
doFreeFormSelect(String whereClause,
String tableList,
int maxRows,
DbEventInterceptorData interceptorData)
perform free-form select query |
protected int |
encodeFieldId(int type,
int aid)
DOCUMENT ME! |
void |
fillWithValues(FieldValue[] orderConstraint,
String aPosition)
in version 0.9 this method moved from FieldValue.fillWithValues to Table.fillWithValues |
String |
getAlias()
DOCUMENT ME! |
String |
getBlobHandling()
for digester only, see blobHandlingStrategy |
int |
getBlobHandlingStrategy()
DOCUMENT ME! |
Vector |
getCalcFields()
DOCUMENT ME! |
protected static DbFormsConfig |
getConfig()
|
String |
getDataAccessClass()
DOCUMENT ME! |
FieldValue[] |
getDefaultOrder()
Return the datastructure containing info about the default sorting behavior of this table. |
String |
getDefaultVisibleFields()
Getter for property defaultVisibleFields. |
String |
getDefaultVisibleFieldsFormat()
Getter for property defaultVisibleFieldsFormat. |
String |
getDeleteStatement(String keyValString)
Returns SQL delete statement, used by deleteEvent. |
String |
getDisblobSelectStatement()
Generates part of a field list for a SQL SELECT clause selecting the DISKBLOB fields from a table (used by DeleteEvent to maintain data consistence). |
Vector |
getDiskblobs()
Returns a Vector of Field-Objects representing fields of type "DISKBLOB" |
ResultSet |
getDoSelectResultSet(FieldValue[] fvEqual,
FieldValue[] fvOrder,
FieldValue[] sqlFilterParams,
int compareMode,
PreparedStatement ps)
Get the SQL ResultSet from the query builded using the input data. |
IEscaper |
getEscaper()
DOCUMENT ME! |
String |
getEscaperClass()
DOCUMENT ME! |
Field |
getField(int fieldId)
Returns the Field-Objet with specified id. |
Field |
getFieldByName(String aname)
Returns the field-objects as specified by name (or null if no field with the specified name exists in this table). |
String |
getFieldName(int fieldID)
We have the field ID - we need the field name |
Vector |
getFields()
Returns the vector of fields this table constists of |
FieldValues |
getFieldValues(String position)
This method parses a position string and build a data structure representing the values of the fields decoded from the position. |
FieldValue[] |
getFilterFieldArray(String filter,
Locale locale)
Initialize the filterFieldValues array. |
Collection |
getForeignKeys()
Get all the ForeignKey objects related to this table. |
String |
getFreeFormSelectQuery(Vector fieldsToSelect,
String whereClause,
String tableList)
Prepares the Querystring for the free form select statement |
GrantedPrivileges |
getGrantedPrivileges()
returns object containing info about rights mapped to user-roles. |
int |
getId()
Returns ID of this table. |
String |
getInsertStatement(FieldValues fieldValues)
Returns SQL insert statement, used by insertEvent. |
Vector |
getInterceptors()
Get all the interceptor objects related to this table. |
Vector |
getKey()
Returns the key of this table (consisting of Field-Objects representing key-fields). |
String |
getKeyPositionString(FieldValues fvHT)
Get key position from the input hash table |
String |
getKeyPositionString(ResultSetVector rsv)
Does basically the same as getPositionString but only for key-fields. |
String |
getKeyPositionString(String[] currentRow)
Does basically the same as getPositionString but only for key-fields. |
String |
getName()
Returns name of the table |
Hashtable |
getNamesHashtable(String core)
returns the hash table. |
String |
getOrderBy()
Return default-orderBy clause from xml config or null if not specified. |
String |
getPositionString(FieldValues fvHT)
Get key position from the input hash table |
String |
getPositionString(Hashtable ht)
Used for instance by goto with prefix |
String |
getPositionString(ResultSetVector rsv)
Builds a "position- string" representing the values of the current row in the given ResultSetVector. |
String |
getPositionString(String[] currentRow)
Builds a "position- string" representing the values of the current row in the given ResultSetVector. |
String |
getQueryFrom()
Returns the FROM part of a query. |
protected String |
getQueryOrderBy(FieldValue[] fvOrder)
Returns the part of the orderby-clause represented by this FieldValue object. |
String |
getQuerySelect(Vector fieldsToSelect)
Returns the select part of a query. |
protected String |
getQueryToChange()
Returns the FROM part of a insert/delete/update query. |
protected String |
getQueryWhere(FieldValue[] fvEqual,
FieldValue[] fvOrder,
int compareMode)
Returns the WHERE part of a query. |
String |
getSelectQuery(Vector fieldsToSelect,
FieldValue[] fvEqual,
FieldValue[] fvOrder,
String sqlFilter,
int compareMode)
Prepares the Querystring for the select statement Order of parts: 1. |
String |
getSelectStatement()
Get the SQL select statement. |
TableEvents |
getTableEvents()
Get the table events object related to this table. |
String |
getUpdateStatement(FieldValues fieldValues,
String keyValStr)
Returns SQL update statement, used by updateEvent. |
String |
getWhereClause(FieldValue[] fv)
Build the WHERE clause string using the input field values. |
String |
getWhereClauseForKeyFields(String keyValuesStr)
Generates a part of the SQL where clause needed to select a distinguished row form the table. |
boolean |
hasInterceptors()
Check if this table has got interceptors. |
boolean |
hasUserPrivileg(HttpServletRequest request,
int privileg)
Checks if there exists a granted-privileges object and if so it queries if access/operation is possible |
void |
initDefaultOrder()
This method generates a datastructure holding sorting information from "orderBy" clause in XML-config. |
boolean |
isCalcField(int fieldId)
|
FieldValues |
mapChildFieldValues(Table parentTable,
String parentFieldString,
String childFieldString,
String aPosition)
maps child fields to parent fields |
void |
populateWhereClauseWithKeyFields(String keyValuesStr,
PreparedStatement ps,
int startColumn)
POPULATES a part of the SQL where clause needed to select a distinguished row form the table using values endcoded in a string. |
int |
populateWhereEqualsClause(FieldValue[] fv,
PreparedStatement ps,
int curCol)
situation: we have built a query (involving the getWhereEqualsClause() method) and now we want to prepare the statemtent - provide actual values for the the '?' |
int |
processInterceptors(int action,
DbEventInterceptorData data)
Process the interceptor objects related to this table. |
void |
setAlias(String alias)
DOCUMENT ME! |
void |
setBlobHandling(String blobHandling)
for digester only, see blobHandlingStrategy |
void |
setDataAccessClass(String dataAccessClass)
Sets the dataAccessClass. |
void |
setDefaultVisibleFields(String defaultVisibleFields)
Setter for property defaultVisibleFields. |
void |
setDefaultVisibleFieldsFormat(String defaultVisibleFieldsFormat)
Setter for property defaultVisibleFieldsFormat. |
void |
setEscaperClass(String string)
DOCUMENT ME! |
void |
setGrantedPrivileges(GrantedPrivileges grantedPrivileges)
Set GrantedPrivileges, if defined in dbforms-config-xml (this method gets called from XML-digester). |
void |
setId(int id)
Sets the ID of this table (this method gets called from DbFormsConfig). |
void |
setName(String name)
Sets the name of the table (this method gets called from XML-digester) |
void |
setOrderBy(String orderBy)
Sets a default-orderBy clause from xml config (this method gets called from XML-digester). |
void |
setTableEvents(TableEvents tableEvents)
Set the table events object related to this table. |
String |
toString()
This metod is useful for logging / debugging purposes only. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int BLOB_INTERCEPTOR
public static final int BLOB_CLASSIC
protected static final int DB_FIELD
protected static final int SEARCH_FIELD
protected static final int CALC_FIELD
| Constructor Detail |
|---|
public Table()
| Method Detail |
|---|
public void setAlias(String alias)
alias - the alias to setpublic String getAlias()
public void setBlobHandling(String blobHandling)
blobHandling - config parameterpublic String getBlobHandling()
public int getBlobHandlingStrategy()
public Vector getCalcFields()
public void setDataAccessClass(String dataAccessClass)
dataAccessClass - The dataAccessClass to setpublic String getDataAccessClass()
public FieldValue[] getDefaultOrder()
public void setDefaultVisibleFields(String defaultVisibleFields)
defaultVisibleFields - New value of property defaultVisibleFields.public String getDefaultVisibleFields()
public void setDefaultVisibleFieldsFormat(String defaultVisibleFieldsFormat)
defaultVisibleFieldsFormat - New value of property defaultVisibleFieldsFormat.public String getDefaultVisibleFieldsFormat()
public String getDeleteStatement(String keyValString)
public String getDisblobSelectStatement()
public Vector getDiskblobs()
public ResultSet getDoSelectResultSet(FieldValue[] fvEqual,
FieldValue[] fvOrder,
FieldValue[] sqlFilterParams,
int compareMode,
PreparedStatement ps)
throws SQLException
fvEqual - FieldValue array used to restrict a set in a subform where all
"childFields" in the resultset match their respective
"parentFields" in main formfvOrder - FieldValue array used to build a cumulation of rules for
ordering (sorting) and restricting fieldssqlFilterParams - DOCUMENT ME!compareMode - the value of the compare modeps - the PreparedStatement object
SQLException - if any error occurspublic IEscaper getEscaper()
public void setEscaperClass(String string)
string - public String getEscaperClass()
public Field getField(int fieldId)
fieldId - The id of the field to be returned
public boolean isCalcField(int fieldId)
public Field getFieldByName(String aname)
name - The name of the field
public String getFieldName(int fieldID)
fieldID - fieldID to get field name from
public FieldValues getFieldValues(String position)
position - the position string
public Vector getFields()
public FieldValue[] getFilterFieldArray(String filter,
Locale locale)
filter - the filter stringlocale - the table object
public Collection getForeignKeys()
public String getFreeFormSelectQuery(Vector fieldsToSelect,
String whereClause,
String tableList)
fieldsToSelect - vector of fields to be selectedwhereClause - free-form whereClause to be appended to querytableList - the list of tables involved into the query
public void setGrantedPrivileges(GrantedPrivileges grantedPrivileges)
grantedPrivileges - the grantedPrivileges objectpublic GrantedPrivileges getGrantedPrivileges()
public void setId(int id)
id - the id value to setpublic int getId()
public String getInsertStatement(FieldValues fieldValues)
fieldValues - the Hashtable containing the field values
public Vector getInterceptors()
public Vector getKey()
public String getKeyPositionString(ResultSetVector rsv)
rsv - the ResultSetVector object
public String getKeyPositionString(String[] currentRow)
currentRow - the currentRow as String[]
public String getKeyPositionString(FieldValues fvHT)
fvHT - has field as key and FieldValue as value!
IllegalArgumentException - DOCUMENT ME!public void setName(String name)
name - the name of the tablepublic String getName()
public Hashtable getNamesHashtable(String core)
core - starting tag for the fields
public void setOrderBy(String orderBy)
orderBy - the orderBy clausepublic String getOrderBy()
public String getPositionString(ResultSetVector rsv)
rsv - the ResultSetVector object
public String getPositionString(String[] currentRow)
currentRow - the currentRow as String[]
public String getPositionString(Hashtable ht)
ht - the Hashtable object containing the field names used to build
the position string ht has fieldName as key and valueStr as
value!
public String getPositionString(FieldValues fvHT)
fvHT - has field as key and FieldValue as value!
IllegalArgumentException - DOCUMENT ME!public String getQueryFrom()
public String getQuerySelect(Vector fieldsToSelect)
fieldsToSelect - the vector containing the Field objects used to build the
elect part of the query
public String getSelectQuery(Vector fieldsToSelect,
FieldValue[] fvEqual,
FieldValue[] fvOrder,
String sqlFilter,
int compareMode)
fieldsToSelect - vector of fields to be selectedfvEqual - fieldValues representing values we are looking forfvOrder - fieldValues representing needs for order clausessqlFilter - sql condition to and with the where clausecompareMode - compare mode value for generating the order clause
public String getSelectStatement()
public void setTableEvents(TableEvents tableEvents)
tableEvents - the table events object related to this tablepublic TableEvents getTableEvents()
public String getUpdateStatement(FieldValues fieldValues,
String keyValStr)
fieldValues - the Hashtable object containing the field values
public String getWhereClause(FieldValue[] fv)
fv - the array of FieldValue objects
public String getWhereClauseForKeyFields(String keyValuesStr)
public void addCalcField(Field field)
throws Exception
field - field to add
Exception - DOCUMENT ME!
public void addField(Field field)
throws Exception
field - the Field object to add
Exception - DOCUMENT ME!public void addForeignKey(ForeignKey fk)
fk - the foreign key objectpublic void addInterceptor(Interceptor interceptor)
interceptor - the interceptor to addpublic boolean containsDiskblob()
public FieldValue[] createOrderFieldValues(String order,
HttpServletRequest request,
boolean includeKeys)
order - a String from JSP provided by the user in SQL-Stylerequest - the request objectincludeKeys - true to include key fields, false otherwise
public ResultSetVector doConstrainedSelect(FieldValue[] fvEqual,
FieldValue[] fvOrder,
String sqlFilter,
FieldValue[] sqlFilterParams,
int compareMode,
int maxRows,
DbEventInterceptorData interceptorData)
throws SQLException
fvEqual - FieldValue array used to restrict a set in a subform where all
"childFields" in the resultset match their respective
"parentFields" in main formfvOrder - FieldValue array used to build a cumulation of rules for
ordering (sorting) and restricting fieldssqlFilter - sql condition to add to where clausesqlFilterParams - DOCUMENT ME!compareMode - the value of the compare modemaxRows - the max number of rows to manageinterceptorData - the connection object
SQLException - if any error occurs
public ResultSetVector doFreeFormSelect(String whereClause,
String tableList,
int maxRows,
DbEventInterceptorData interceptorData)
throws SQLException
whereClause - free-form whereClause to be appended to querytableList - the list of tables involved into the querymaxRows - how many rows should be stored in the resultSet (zero means
unlimited)interceptorData - the active db connection to use
SQLException - if any error occurs
public void fillWithValues(FieldValue[] orderConstraint,
String aPosition)
orderConstraint - FieldValue array used to build a cumulation of rules for
ordering (sorting) and restricting fieldsaPosition - resultset positionpublic boolean hasInterceptors()
public boolean hasUserPrivileg(HttpServletRequest request,
int privileg)
request - the request objectprivileg - the privilege value
public void initDefaultOrder()
public FieldValues mapChildFieldValues(Table parentTable,
String parentFieldString,
String childFieldString,
String aPosition)
parentTable - the parent tableparentFieldString - field names in parent tablechildFieldString - field names in child tableaPosition - position to map as position string
IllegalArgumentException - DOCUMENT ME!
public void populateWhereClauseWithKeyFields(String keyValuesStr,
PreparedStatement ps,
int startColumn)
throws SQLException
keyValuesStr - the position stringps - the PreparedStatement objectstartColumn - PreparedStatement start column
SQLException - if any error occurs
public int populateWhereEqualsClause(FieldValue[] fv,
PreparedStatement ps,
int curCol)
throws SQLException
fv - the array of FieldValue objectsps - the PreparedStatement objectcurCol - the current PreparedStatement column; points to a
PreparedStatement xxx value
SQLException - if any error occurs
public int processInterceptors(int action,
DbEventInterceptorData data)
throws MultipleValidationException
action - the DbEventInterceptor identifier. See the DbEventInterceptor
class for the real values. Example:
DbEventInterceptor.PRE_UPDATEdata - the DbEventInterceptorData object
DbEventInterceptor.GRANT_OPERATION,
DbEventInterceptor.DENY_OPERATION,
DbEventInterceptor.IGNORE_OPERATION
SQLException - if any error occurs
MultipleValidationExceptionpublic String toString()
toString in class Objectprotected String getQueryOrderBy(FieldValue[] fvOrder)
fvOrder - FieldValue array used to build a cumulation of rules for
ordering (sorting) and restricting fields
protected String getQueryToChange()
protected String getQueryWhere(FieldValue[] fvEqual,
FieldValue[] fvOrder,
int compareMode)
fvEqual - FieldValue array used to restrict a set in a subform where all
"childFields" in the resultset match their respective
"parentFields" in main formfvOrder - FieldValue array used to build a cumulation of rules for
ordering (sorting) and restricting fieldscompareMode - compare mode value for generating the order clause
protected boolean checkFieldId(int type,
int aid)
type - DOCUMENT ME!id - DOCUMENT ME!
protected int decodeFieldId(int type,
int aid)
type - DOCUMENT ME!id - DOCUMENT ME!
protected int encodeFieldId(int type,
int aid)
type - DOCUMENT ME!id - DOCUMENT ME!
protected static DbFormsConfig getConfig()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||