public abstract class AssociationUpdater extends AssociationCreator
AssociationUpdater. So this class just deal with the simple job of
removing foreign key columns and dropping dump intermediate join tables.| 限定符和类型 | 字段和说明 |
|---|---|
protected android.database.sqlite.SQLiteDatabase |
mDb
Instance of SQLiteDatabase.
|
static java.lang.String |
TAG |
| 构造器和说明 |
|---|
AssociationUpdater() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addOrUpdateAssociation(android.database.sqlite.SQLiteDatabase db,
boolean force)
AssociationUpdater does two jobs. |
protected void |
clearCopyInTableSchema(java.util.List<java.lang.String> tableNames)
The values in table_schame should be synchronized with the model tables
in the database.
|
protected abstract void |
createOrUpgradeTable(android.database.sqlite.SQLiteDatabase db,
boolean force)
Analysis the
TableModel by the purpose of subclasses, and
generate a SQL to do the intention job. |
protected void |
createOrUpgradeTable(TableModel tableModel,
android.database.sqlite.SQLiteDatabase db,
boolean force) |
protected void |
dropTables(java.util.List<java.lang.String> dropTableNames,
android.database.sqlite.SQLiteDatabase db)
Drop the tables by the passing table name.
|
protected java.lang.String |
generateAlterToTempTableSQL(java.lang.String tableName)
Generate a SQL for renaming the table into a temporary table.
|
protected java.lang.String |
generateDataMigrationSQL(TableModel tableModel)
Generate a SQL to do the data migration job to avoid losing data.
|
protected java.lang.String |
generateDropTempTableSQL(java.lang.String tableName)
Generate a SQL to drop the temporary table.
|
protected java.util.List<java.lang.String> |
getCreateTableSQLs(TableModel tableModel,
android.database.sqlite.SQLiteDatabase db,
boolean force)
When creating a new table, it should always try to drop the same name
table if exists.
|
protected java.util.List<java.lang.String> |
getForeignKeyColumns(TableModel tableModel)
This method looks around all the columns in the table, and judge which of
them are foreign key columns.
|
protected TableModel |
getTableModelFromDB(java.lang.String tableName)
Look from the database to find a table named same as the table name in
table model.
|
protected java.lang.String |
getTempTableName(java.lang.String tableName)
Removing or resizing columns from tables must need a temporary table to
store data, and here's the table name.
|
protected boolean |
isForeignKeyColumn(TableModel tableModel,
java.lang.String columnName)
Judge the passed in column is a foreign key column or not.
|
protected void |
removeColumns(java.util.Collection<java.lang.String> removeColumnNames,
java.lang.String tableName)
When some fields are removed from class, the table should synchronize the
changes by removing the corresponding columns.
|
addForeignKeyColumn, generateAddColumnSQL, generateCreateIndexSQL, generateCreateIndexSQLs, generateCreateTableSQL, generateDropTableSQL, giveTableSchemaACopy, isForeignKeyColumnFormatexecute, getAllAssociations, getAllTableModelspublic static final java.lang.String TAG
protected android.database.sqlite.SQLiteDatabase mDb
protected abstract void createOrUpgradeTable(android.database.sqlite.SQLiteDatabase db,
boolean force)
TableModel by the purpose of subclasses, and
generate a SQL to do the intention job. The implementation of this method
is totally delegated to the subclasses.db - Instance of SQLiteDatabase.force - Drop the table first if it already exists.protected void addOrUpdateAssociation(android.database.sqlite.SQLiteDatabase db,
boolean force)
AssociationUpdater does two jobs. Removing foreign key columns
when two models are not associated anymore, and remove the intermediate
join tables when two models are not associated anymore.addOrUpdateAssociation 在类中 AssociationCreatordb - Instance of SQLiteDatabase.force - Drop the table first if it already exists.protected java.util.List<java.lang.String> getForeignKeyColumns(TableModel tableModel)
tableModel - Use the TableModel to get table name and columns name to
generate SQL.protected boolean isForeignKeyColumn(TableModel tableModel, java.lang.String columnName)
tableModel - Use the TableModel to get table name and columns name to
generate SQL.columnName - The column to judge.protected TableModel getTableModelFromDB(java.lang.String tableName)
tableName - The table name use to get table model from database.protected void dropTables(java.util.List<java.lang.String> dropTableNames,
android.database.sqlite.SQLiteDatabase db)
dropTableNames - The names of the tables that need to drop.db - Instance of SQLiteDatabase.protected void removeColumns(java.util.Collection<java.lang.String> removeColumnNames,
java.lang.String tableName)
removeColumnNames - The column names that need to remove.tableName - The table name to remove columns from.protected void clearCopyInTableSchema(java.util.List<java.lang.String> tableNames)
tableNames - The table names need to remove from table_schema.protected java.lang.String generateAlterToTempTableSQL(java.lang.String tableName)
tableName - The table name use to alter to temporary table.protected java.lang.String generateDataMigrationSQL(TableModel tableModel)
tableModel - Which contains table name use to migrate data.protected java.lang.String generateDropTempTableSQL(java.lang.String tableName)
tableName - The table name use to drop temporary table.protected java.lang.String getTempTableName(java.lang.String tableName)
tableName - The table name use to generate temporary table name.protected void createOrUpgradeTable(TableModel tableModel, android.database.sqlite.SQLiteDatabase db, boolean force)
protected java.util.List<java.lang.String> getCreateTableSQLs(TableModel tableModel, android.database.sqlite.SQLiteDatabase db, boolean force)
tableModel - The table model.db - Instance of SQLiteDatabase.force - Drop the table first if it already exists.