|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.makumba.db.makumba.Table org.makumba.db.makumba.sql.TableManager
public class TableManager
Nested Class Summary | |
---|---|
(package private) class |
TableManager.CatalogChecker
|
protected static interface |
TableManager.CheckingStrategy
|
Fields inherited from class org.makumba.db.makumba.Table |
---|
dd |
Constructor Summary | |
---|---|
TableManager()
|
Method Summary | |
---|---|
(package private) boolean |
alter(SQLDBConnection dbc,
String fieldName,
String op)
|
protected void |
alter(SQLDBConnection dbc,
TableManager.CheckingStrategy cs,
boolean alter)
checks if an alteration is needed, and calls doAlter if so |
Object |
base_getValue(String fieldName,
ResultSet rs,
int i)
|
String |
base_inCreate(String fieldName,
Database d)
|
void |
base_setInsertArgument(String fieldName,
PreparedStatement ps,
int n,
Dictionary<String,Object> d)
|
Object |
base_toSQLObject(String fieldName,
Object o)
|
protected boolean |
base_unmodified(String fieldName,
int type,
int size,
Vector<Hashtable<String,Object>> columns,
int index)
|
String |
base_writeConstant(String fieldName,
Object o)
|
boolean |
canAdmin()
does the table exist in the database ? |
protected boolean |
check_char_Width(String fieldName,
int width)
check the char width |
protected boolean |
check_char_Width(String fieldName,
ResultSetMetaData rsm,
int index)
check the char width |
Object |
check_timeStamp_ValueImpl(String fieldName,
Object value)
|
protected void |
checkCopy(String fieldName,
String s)
|
boolean |
checkDuplicate(String[] fields,
Object[] values,
DBConnection dbc)
return whether there was a duplicate entry for this multi-field combination when inserting the given data |
boolean |
checkDuplicate(String fieldName,
DBConnection dbc,
Dictionary<String,Object> data)
return whether there was a duplicate for this field when inserting the given data |
void |
checkInsert(Dictionary<String,Object> fieldsToCheck,
Dictionary<String,DataHolder> fieldsToIgnore,
Dictionary<String,Object> allFields)
Checks if a set of values can be inserted in the database |
protected void |
checkStructure(SQLDBConnection dbc,
Properties config)
|
void |
checkUpdate(Pointer pointer,
Dictionary<String,Object> allFields)
Checks if a set of values can be updated in the database |
void |
close()
|
protected void |
create(SQLDBConnection dbc,
String tblname,
boolean really)
a table creation, from this table's RecordInfo |
protected String |
createDbSpecific(String command)
for mysql |
int |
deleteFrom(DBConnection here,
DBConnection source,
boolean ignoreDbsv)
delete all the records created within the indicated database and return their number |
void |
deleteRecord(DBConnection dbc,
Pointer uid)
|
protected void |
doAlter(SQLDBConnection dbc,
Vector<String> drop,
Vector<String> present,
Vector<String> add,
Vector<String> modify)
do the needed alterations after examining the data definition of the existing table. a temporary copy table is created, and the fields are copied from it to the re-CREATEd table. |
boolean |
exists()
does the table exist in the database ? |
boolean |
exists(String s)
does the field exist in the database ? |
protected void |
fieldList(StringBuffer command,
Enumeration<String> e)
list the given fields in a command field1, field2 ... |
protected void |
fillResult(ResultSet rs,
Dictionary<String,Object> p)
|
protected void |
fillResult(ResultSet rs,
Object[] data)
|
void |
findDuplicates(DBConnection dbc,
Dictionary<String,Object> d)
finds duplicates in the database, given a dictionary of data to insert/update |
boolean |
findMultiFieldMultiTableDuplicates(Pointer pointer,
DataDefinition.MultipleUniqueKeyDefinition definition,
Object[] values,
SQLDBConnection dbc)
Checks for potential duplicates for multi-field unique keys that span over more than one data definition. |
String |
foreignKeyCreateSyntax(String fieldName,
String fkTableName,
String fkFieldName)
Syntax for unique index creation. |
protected String |
get_binary_FieldDBType(String fieldName)
returns text |
protected int |
get_binary_SQLType(String fieldName)
|
Object |
get_binary_Value(String fieldName,
ResultSet rs,
int i)
get the java value of the recordSet column corresponding to this field. |
protected String |
get_boolean_FieldDBType(String fieldName)
|
protected int |
get_boolean_SQLType(String fieldName)
|
Object |
get_boolean_Value(String fieldName,
ResultSet rs,
int i)
|
protected String |
get_char_FieldDBType(String fieldName)
returns char |
protected int |
get_char_SQLType(String fieldName)
|
Object |
get_char_Value(String fieldName,
ResultSet rs,
int i)
get the java value of the recordSet column corresponding to this field. |
protected String |
get_dateTime_FieldDBType(String fieldName)
returns datetime |
int |
get_dateTime_SQLType(String fieldName)
|
Object |
get_dateTime_Value(String fieldName,
ResultSet rs,
int i)
get the java value of the recordSet column corresponding to this field. |
protected String |
get_int_FieldDBType(String fieldName)
Use standard SQL name, unless defined otherwise in sqlEngines.properties. |
protected int |
get_int_SQLType(String fieldName)
|
Object |
get_int_Value(String fieldName,
ResultSet rs,
int i)
|
Object |
get_nil_Value(String fieldName,
ResultSet rs,
int i)
|
protected String |
get_ptrDB_FieldDBType(String fieldName)
returns INT |
int |
get_ptrDB_SQLType(String fieldName)
|
Object |
get_ptrDB_Value(String fieldName,
ResultSet rs,
int i)
return the value as a Pointer |
protected String |
get_real_FieldDBType(String fieldName)
Use standard SQL name, unless defined otherwise in sqlEngines.properties. |
protected int |
get_real_SQLType(String fieldName)
|
protected String |
get_text_FieldDBType(String fieldName)
returns text |
Object |
get_text_Value(String fieldName,
ResultSet rs,
int i)
get the java value of the recordSet column corresponding to this field. |
protected String |
get_timeStamp_FieldDBType(String fieldName)
returns timestamp |
int |
get_timeStamp_SQLType(String fieldName)
|
Object |
get_timeStamp_Value(String fieldName,
ResultSet rs,
int i)
|
protected String |
getColumnAlterKeyword()
|
protected String |
getCreateAutoIncrementSyntax()
|
String |
getDBName()
|
protected String |
getEngineProperty(String fieldName,
String s)
what is the property of the current engine? |
String |
getFieldDBIndexName(String fieldName)
Ask this field how to name the index on this field. |
String |
getFieldDBName(String fieldName)
the database-level name of the field |
protected String |
getFieldDBType(String fieldName)
what is the database level type of this field? |
protected String |
getFieldDBType(String fieldName,
Database d)
what is the database level type of this field? |
protected String |
getQueryAutoIncrementSyntax()
|
protected Database |
getSQLDatabase()
|
protected int |
getSQLType(String fieldName)
what is the SQL type of this field? |
protected String |
getTableMissingStateName(SQLDBConnection dbc)
mysql needs to have it adjustable |
Object |
getValue(ResultSet rs,
String fieldName,
int i)
|
Object |
getValue(String fieldName,
ResultSet rs,
int i)
get the java value of the recordSet column corresponding to this field. |
boolean |
hasForeignKey(String fieldName)
|
String |
in_boolean_Create(String fieldName,
Database d)
write in CREATE, in the form name BIT(1) |
String |
in_char_Create(String fieldName,
Database d)
write in CREATE, in the form name char[size] |
String |
inCondition(String fieldName,
Dictionary<String,Object> d,
String cond)
ask this field to write its contribution in a SQL UPDATE statement should return "" if this field doesn't want to take part in the update |
String |
inCreate(String fieldName,
Database d)
ask this field to write its contribution in a SQL CREATE statement |
protected void |
indexCreated(SQLDBConnection dbc)
for odbc |
String |
indexCreateSyntax(String fieldName)
Syntax for index creation. |
String |
indexCreateUniqueSyntax(String fieldName)
Syntax for unique index creation. |
String |
indexCreateUniqueSyntax(String[] fieldNames)
Syntax for multi-field index |
String |
indexDropSyntax(String fieldName)
Syntax for dropping index. |
protected void |
initFields(SQLDBConnection dbc,
Properties config)
|
String |
inPreparedInsert(String fieldName)
ask this field to write write its argument placeholder ('?') |
String |
inPreparedUpdate(String fieldName)
ask this field to write its argument placeholder in a prepared UPDATE SQL statement |
Pointer |
insertRecordImpl(DBConnection dbc,
Dictionary<String,Object> d)
|
boolean |
isIndexOk(String fieldName)
Examine DB indexes. |
boolean |
isIndexOk(String[] fieldNames)
|
(package private) void |
makeKeyIndex()
|
void |
manageForeignKeys(String fieldName,
SQLDBConnection dbc,
String brief)
|
void |
manageIndexes(String fieldName,
SQLDBConnection dbc)
Ask this field to add/remove indexes as needed, normally called from onStartup(). |
protected long |
nextId_ptrIndex()
determines the unique index by incrementing a counter |
SQLPointer |
nxt_ptrIndex(String fieldName,
Dictionary<String,Object> d)
|
(package private) void |
nxt(String fieldName,
Dictionary<String,Object> d)
|
void |
onStartup(String fieldName,
Properties config,
SQLDBConnection dbc)
ask this field to perform actions when the table is open |
protected void |
open(Properties config,
NameResolver nr)
the SQL table opening. might call create() or alter() |
protected String |
prepareDelete()
|
protected String |
prepareInsert(boolean autoIncrement)
|
protected void |
resetPrimaryKey()
|
void |
set_binary_Argument(String fieldName,
PreparedStatement ps,
int n,
Object o)
|
void |
set_text_Argument(String fieldName,
PreparedStatement ps,
int n,
Object o)
|
void |
set_timeStamp_InsertArgument(String fieldName,
PreparedStatement ps,
int n,
Dictionary<String,Object> d)
|
void |
setArgument(String fieldName,
PreparedStatement ps,
int n,
Object o)
set a non-null argument of this type in a prepared SQL statement |
void |
setCopyArgument(String fieldName,
PreparedStatement ps,
int n,
Dictionary<String,Object> d)
ask this field to write write its argument value in a prepared SQL statement for copying |
void |
setInsertArgument(String fieldName,
PreparedStatement ps,
int n,
Dictionary<String,Object> d)
ask this field to write write its argumment value in a prepared INSERT SQL statement |
void |
setNullArgument(String fieldName,
PreparedStatement ps,
int n)
set a null argument of this type in a prepared SQL statement |
protected void |
setTableAndFieldNames(NameResolver nr)
the SQL table opening. might call create() or alter() |
void |
setUpdateArgument(String fieldName,
PreparedStatement ps,
int n,
Dictionary<String,Object> d)
ask this field to write write its argumment value in a prepared UPDATE SQL statement |
void |
setUpdateArgument(String fieldName,
PreparedStatement ps,
int n,
Object o)
ask this field to write write its argument value in a prepared UPDATE SQL statement |
void |
setValue(String fieldName,
Dictionary<String,Object> d,
ResultSet rs,
int i)
set the java value in a data chunk. |
void |
setValue(String fieldName,
Object[] data,
ResultSet rs,
int i)
set the java value in a data chunk. |
boolean |
should_text_Index(String fieldName)
|
boolean |
shouldIndex(String fieldName)
Tell whether this type of field should be indexed. |
Object |
toSQL_dateTime_Object(String fieldName,
Object o)
|
Object |
toSQL_ptrDB_Object(String fieldName,
Object o)
ask this field to write a value of its type in a SQL statement |
Object |
toSQLObject(String fieldName,
Object o)
transform the object for a SQL insert or update |
protected boolean |
unmodified_char(String fieldName,
int type,
int size,
Vector<Hashtable<String,Object>> columns,
int index)
Checks if the type is java.sql.Types.CHAR. |
protected boolean |
unmodified_wrapper(String fieldName,
int type,
int size,
Vector<Hashtable<String,Object>> v,
int index)
check if the column from the SQL database still coresponds with the abstract definition of this field |
protected boolean |
unmodified(String fieldName,
int type,
int size,
Vector<Hashtable<String,Object>> columns,
int index)
check if the column from the SQL database (read from the catalog) still corresponds with the abstract definition of this field |
void |
updateRecord(DBConnection dbc,
Pointer uid,
Dictionary<String,Object> d)
Deprecated. |
protected boolean |
usesHidden()
|
String |
write_binary_Constant(String fieldName,
Object o)
does apostrophe escape |
String |
write_boolean_Constant(String fieldName,
Object o)
|
String |
write_char_Constant(String fieldName,
Object o)
does apostrophe escape |
String |
write_dateTime_Constant(String fieldName,
Object o)
writes the date between apostrophes |
String |
write_text_Constant(String fieldName,
Object o)
does apostrophe escape |
String |
write_timeStamp_Constant(String fieldName,
Object o)
writes the date between apostrophes |
String |
writeConstant(String fieldName,
Object o)
ask this field to write a value of its type in a SQL statement |
Methods inherited from class org.makumba.db.makumba.Table |
---|
getDatabase, getDataDefinition, getFieldDefinition, getRelatedTable, insertRecord, setDataDefinition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String tbname
protected String handlerList
protected String handlerListAutoIncrement
protected String indexDBField
protected String indexField
protected String modTable
protected long primaryKeyCurrentIndex
protected int dbsv
boolean alter
boolean exists_
Hashtable<String,Object> handlerExist
Dictionary<String,Integer> keyIndex
String preparedInsertString
String preparedInsertAutoIncrementString
String preparedDeleteString
String preparedDeleteFromString
String preparedDeleteFromIgnoreDbsvString
Hashtable<String,String> checkDuplicate
Hashtable<String,String> checkNullDuplicate
boolean admin
Hashtable<String,Boolean> indexes
Boolean parsedForeignKeys
Hashtable<String,String[]> foreignKeys
Hashtable<String,String[]> extraIndexes
static SimpleDateFormat sqlDateFormat
Constructor Detail |
---|
public TableManager()
Method Detail |
---|
public boolean exists()
Table
exists
in class Table
public boolean exists(String s)
Table
exists
in class Table
public String getDBName()
protected Database getSQLDatabase()
protected boolean usesHidden()
void makeKeyIndex()
protected void open(Properties config, NameResolver nr)
open
in class Table
public void close()
close
in class Table
protected void setTableAndFieldNames(NameResolver nr)
public boolean canAdmin()
Table
canAdmin
in class Table
protected void checkStructure(SQLDBConnection dbc, Properties config)
protected void initFields(SQLDBConnection dbc, Properties config) throws SQLException
SQLException
public int deleteFrom(DBConnection here, DBConnection source, boolean ignoreDbsv)
Table
deleteFrom
in class Table
protected void alter(SQLDBConnection dbc, TableManager.CheckingStrategy cs, boolean alter) throws SQLException
alter
- TODO
SQLException
protected String getColumnAlterKeyword()
boolean alter(SQLDBConnection dbc, String fieldName, String op) throws SQLException
SQLException
protected void doAlter(SQLDBConnection dbc, Vector<String> drop, Vector<String> present, Vector<String> add, Vector<String> modify) throws SQLException
drop
- the names of the db fields that should be dropped (they might not be)present
- the abstract fields that exist in the DB, in DB orderadd
- the abstract fields that are not present in the db and need to be addedmodify
- the abstract fields that exist in the db but need to be modified to the new abstract definition
SQLException
protected void create(SQLDBConnection dbc, String tblname, boolean really) throws SQLException
SQLException
protected void fieldList(StringBuffer command, Enumeration<String> e)
protected String prepareInsert(boolean autoIncrement)
public Pointer insertRecordImpl(DBConnection dbc, Dictionary<String,Object> d)
insertRecordImpl
in class Table
public void findDuplicates(DBConnection dbc, Dictionary<String,Object> d)
Table
findDuplicates
in class Table
protected String prepareDelete()
public void deleteRecord(DBConnection dbc, Pointer uid)
@Deprecated public void updateRecord(DBConnection dbc, Pointer uid, Dictionary<String,Object> d)
protected void fillResult(ResultSet rs, Dictionary<String,Object> p) throws SQLException
SQLException
protected void fillResult(ResultSet rs, Object[] data) throws SQLException
SQLException
public Object getValue(ResultSet rs, String fieldName, int i)
public Object getValue(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object base_getValue(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_ptrDB_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_int_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_char_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_text_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_binary_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_boolean_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_dateTime_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public Object get_nil_Value(String fieldName, ResultSet rs, int i)
public Object get_timeStamp_Value(String fieldName, ResultSet rs, int i) throws SQLException
SQLException
public void setUpdateArgument(String fieldName, PreparedStatement ps, int n, Object o) throws SQLException
SQLException
public void setUpdateArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d) throws SQLException
SQLException
public void setNullArgument(String fieldName, PreparedStatement ps, int n) throws SQLException
SQLException
public void setArgument(String fieldName, PreparedStatement ps, int n, Object o) throws SQLException
SQLException
public void set_binary_Argument(String fieldName, PreparedStatement ps, int n, Object o) throws SQLException
SQLException
public void set_text_Argument(String fieldName, PreparedStatement ps, int n, Object o) throws SQLException
SQLException
protected int getSQLType(String fieldName)
public int get_ptrDB_SQLType(String fieldName)
protected int get_int_SQLType(String fieldName)
protected int get_char_SQLType(String fieldName)
protected int get_binary_SQLType(String fieldName)
protected int get_boolean_SQLType(String fieldName)
public int get_dateTime_SQLType(String fieldName)
protected int get_real_SQLType(String fieldName)
public int get_timeStamp_SQLType(String fieldName)
public Object toSQLObject(String fieldName, Object o)
public Object base_toSQLObject(String fieldName, Object o)
public Object toSQL_ptrDB_Object(String fieldName, Object o)
public Object toSQL_dateTime_Object(String fieldName, Object o)
public String getFieldDBName(String fieldName)
public String inCreate(String fieldName, Database d)
public String base_inCreate(String fieldName, Database d)
public String in_char_Create(String fieldName, Database d)
public String in_boolean_Create(String fieldName, Database d)
public String inPreparedUpdate(String fieldName)
protected String getFieldDBType(String fieldName)
protected String get_ptrDB_FieldDBType(String fieldName)
protected String get_int_FieldDBType(String fieldName)
protected String get_char_FieldDBType(String fieldName)
protected String get_text_FieldDBType(String fieldName)
protected String get_binary_FieldDBType(String fieldName)
protected String get_boolean_FieldDBType(String fieldName)
protected String get_dateTime_FieldDBType(String fieldName)
protected String get_real_FieldDBType(String fieldName)
protected String get_timeStamp_FieldDBType(String fieldName)
protected String getFieldDBType(String fieldName, Database d)
public String getFieldDBIndexName(String fieldName)
public String inPreparedInsert(String fieldName)
public void setInsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d) throws SQLException
SQLException
public void base_setInsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d) throws SQLException
SQLException
public void set_timeStamp_InsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d) throws SQLException
SQLException
public void setCopyArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d) throws SQLException
SQLException
public String inCondition(String fieldName, Dictionary<String,Object> d, String cond)
public String writeConstant(String fieldName, Object o)
public String base_writeConstant(String fieldName, Object o)
public String write_char_Constant(String fieldName, Object o)
public String write_text_Constant(String fieldName, Object o)
public String write_binary_Constant(String fieldName, Object o)
public String write_boolean_Constant(String fieldName, Object o)
public String write_dateTime_Constant(String fieldName, Object o)
public String write_timeStamp_Constant(String fieldName, Object o)
protected String getEngineProperty(String fieldName, String s)
public void onStartup(String fieldName, Properties config, SQLDBConnection dbc) throws SQLException
SQLException
public boolean shouldIndex(String fieldName)
public boolean should_text_Index(String fieldName)
public boolean isIndexOk(String fieldName)
public boolean hasForeignKey(String fieldName)
public boolean isIndexOk(String[] fieldNames)
public void manageIndexes(String fieldName, SQLDBConnection dbc) throws SQLException
SQLException
public void manageForeignKeys(String fieldName, SQLDBConnection dbc, String brief) throws DBError
DBError
public String indexCreateSyntax(String fieldName)
public String indexCreateUniqueSyntax(String fieldName)
public String foreignKeyCreateSyntax(String fieldName, String fkTableName, String fkFieldName)
public String indexCreateUniqueSyntax(String[] fieldNames)
public String indexDropSyntax(String fieldName)
public void setValue(String fieldName, Dictionary<String,Object> d, ResultSet rs, int i) throws SQLException
SQLException
public void setValue(String fieldName, Object[] data, ResultSet rs, int i) throws SQLException
SQLException
protected void checkCopy(String fieldName, String s)
public boolean checkDuplicate(String fieldName, DBConnection dbc, Dictionary<String,Object> data)
public boolean checkDuplicate(String[] fields, Object[] values, DBConnection dbc)
public boolean findMultiFieldMultiTableDuplicates(Pointer pointer, DataDefinition.MultipleUniqueKeyDefinition definition, Object[] values, SQLDBConnection dbc)
checkInsert(Dictionary, Dictionary, Dictionary)
.
protected boolean unmodified(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index) throws SQLException
SQLException
protected boolean base_unmodified(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index) throws SQLException
SQLException
protected boolean unmodified_char(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index) throws SQLException
SQLException
protected boolean unmodified_wrapper(String fieldName, int type, int size, Vector<Hashtable<String,Object>> v, int index) throws SQLException
SQLException
protected boolean check_char_Width(String fieldName, ResultSetMetaData rsm, int index) throws SQLException
SQLException
protected boolean check_char_Width(String fieldName, int width) throws SQLException
SQLException
protected void resetPrimaryKey()
void nxt(String fieldName, Dictionary<String,Object> d)
public SQLPointer nxt_ptrIndex(String fieldName, Dictionary<String,Object> d)
protected long nextId_ptrIndex()
public void checkInsert(Dictionary<String,Object> fieldsToCheck, Dictionary<String,DataHolder> fieldsToIgnore, Dictionary<String,Object> allFields)
checkInsert
in class Table
fieldsToCheck
- the values to be checkedfieldsToIgnore
- the values of toCheck not to be checkedallFields
- the entire data to be insertedpublic void checkUpdate(Pointer pointer, Dictionary<String,Object> allFields)
checkUpdate
in class Table
pointer
- the pointer to the record to be updatedfieldsToCheck
- the values to be checkedfieldsToIgnore
- the values of toCheck not to be checkedallFields
- the entire data to be insertedpublic Object check_timeStamp_ValueImpl(String fieldName, Object value)
protected void indexCreated(SQLDBConnection dbc)
protected String createDbSpecific(String command)
protected String getTableMissingStateName(SQLDBConnection dbc)
protected String getQueryAutoIncrementSyntax()
protected String getCreateAutoIncrementSyntax()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |