本文整理汇总了Java中com.raizlabs.android.dbflow.structure.ModelAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ModelAdapter类的具体用法?Java ModelAdapter怎么用?Java ModelAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelAdapter类属于com.raizlabs.android.dbflow.structure包,在下文中一共展示了ModelAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: save
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
/**
* 新增或者修改数据库的统一方法
* @param tClass 传递一个class信息
* @param models 这个class对应的实例的数组
* @param <Model> 这个实例的泛型 限定条件是BaseModel
*/
public static<Model extends BaseModel> void save(final Class<Model> tClass, final Model... models) {
if (models==null||models.length==0) return;
// 当前数据库的一个管理者
DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
// 提交一个事务
definition.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
// 执行
ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
// 保存
adapter.saveAll(Arrays.asList(models));
// 唤起通知
instance.notifySave(tClass,models);
}
}).build().execute();
}
开发者ID:FZZFVII,项目名称:pipe,代码行数:24,代码来源:DbHelper.java
示例2: delete
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
/**
* 删除数据库的的统一方法
* @param tClass 传递一个class信息
* @param models 这个class对应的实例的数组
* @param <Model> 这个实例的泛型 限定条件是BaseModel
*/
public static<Model extends BaseModel> void delete(final Class<Model> tClass, final Model... models) {
if (models==null||models.length==0) return;
// 当前数据库的一个管理者
DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
// 提交一个事务
definition.beginTransactionAsync(new ITransaction() {
@Override
public void execute(DatabaseWrapper databaseWrapper) {
// 执行
ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
// 删除
adapter.deleteAll(Arrays.asList(models));
// 唤起通知
instance.notifyDelete(tClass,models);
}
}).build().execute();
}
开发者ID:FZZFVII,项目名称:pipe,代码行数:24,代码来源:DbHelper.java
示例3: performIndividualAdapterOperations
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void performIndividualAdapterOperations() {
for (int i = 0; i < mModelList.size(); i++) {
@ModelOperation int operation = mOperationList.get(i);
Object model = mModelList.get(i);
ModelAdapter modelAdapter = FlowManager.getModelAdapter(model.getClass());
if (operation == MODEL_OPERATION_SAVE) {
modelAdapter.save(model);
} else if (operation == MODEL_OPERATION_DELETE) {
modelAdapter.delete(model);
} else if (operation == MODEL_OPERATION_INSERT) {
modelAdapter.insert(model);
} else if (operation == MODEL_OPERATION_UPDATE) {
modelAdapter.update(model);
}
}
}
开发者ID:roadhouse-dev,项目名称:RxDbflow,代码行数:19,代码来源:RxModelOperationTransaction.java
示例4: migrateSurveyTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateSurveyTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql=myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql=sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creation_date, completion_date, upload_date, schedule_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:19,代码来源:Migration9RenameTables.java
示例5: migrateProgramTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateProgramTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(Program.class);
String programTable = "Program";
String programTempTable = "Program_temp";
//Create temporal table
String sql = myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql = sql.replace(programTable, programTempTable);
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy = "INSERT INTO " + programTempTable
+ "(id_program, uid, name, stage_uid) SELECT id_program, uid, name, programStage "
+ "FROM "
+ programTable;
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS " + programTable);
database.execSQL("ALTER TABLE " + programTempTable + " RENAME TO " + programTable);
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:23,代码来源:Migration12UpdateEdsTables.java
示例6: migrateSurveyTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateSurveyTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql = myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql = sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy =
"INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, "
+ "creation_date, completion_date, upload_date, scheduled_date, status, "
+ "eventuid) SELECT id_survey, id_program, id_org_unit, id_user, "
+ "creation_date, completion_date, upload_date, schedule_date, status, "
+ "eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:24,代码来源:Migration12UpdateEdsTables.java
示例7: migrate
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@Override
public void migrate(SQLiteDatabase database) {
//The column name can't be renamed in sqlite. It is needed create a temporal table with the new column name.
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql=myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql=sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, eventDate, scheduledDate, status, eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:21,代码来源:Migration7RenameEventDate.java
示例8: migrateSurveyTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateSurveyTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql=myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql=sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy="INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, creation_date, completion_date, upload_date, scheduled_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:19,代码来源:Migration10RenameTables.java
示例9: migrate
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@Override
public void migrate(DatabaseWrapper database) {
//The column name can't be renamed in sqlite. It is needed create a temporal table with the new column name.
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql=myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql=sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, eventDate, scheduledDate, status, eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:21,代码来源:Migration7RenameEventDate.java
示例10: migrateSurveyTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateSurveyTable(DatabaseWrapper database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);
//Create temporal table
String sql=myAdapter.getCreationQuery();
Log.d("DBMIGRATION", "old table " + sql);
sql=sql.replace("Survey", "Survey_temp");
Log.d("DBMIGRATION", "create temp table " + sql);
database.execSQL(sql);
//Insert the data in temporal table
String sqlCopy="INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, creation_date, completion_date, upload_date, scheduled_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS Survey");
database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:19,代码来源:Migration10RenameTables.java
示例11: executeTableCreations
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
protected void executeTableCreations(@NonNull final DatabaseWrapper database){
try {
database.beginTransaction();
List<ModelAdapter> modelAdapters = databaseDefinition.getModelAdapters();
for (ModelAdapter modelAdapter : modelAdapters) {
if (modelAdapter.createWithDatabase()) {
try {
database.execSQL(modelAdapter.getCreationQuery());
} catch (SQLiteException e) {
FlowLog.logError(e);
}
}
}
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:19,代码来源:BaseDatabaseHelper.java
示例12: saveAll
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@Override
public synchronized void saveAll(@NonNull Collection<TModel> tableCollection,
@NonNull DatabaseWrapper wrapper) {
// skip if empty.
if (tableCollection.isEmpty()) {
return;
}
ModelSaver<TModel> modelSaver = getModelSaver();
ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter();
DatabaseStatement statement = modelAdapter.getInsertStatement(wrapper);
DatabaseStatement updateStatement = modelAdapter.getUpdateStatement(wrapper);
try {
for (TModel model : tableCollection) {
if (modelSaver.save(model, wrapper, statement, updateStatement)) {
modelAdapter.storeModelInCache(model);
}
}
} finally {
updateStatement.close();
statement.close();
}
}
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:24,代码来源:CacheableListModelSaver.java
示例13: insertAll
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@Override
public synchronized void insertAll(@NonNull Collection<TModel> tableCollection,
@NonNull DatabaseWrapper wrapper) {
// skip if empty.
if (tableCollection.isEmpty()) {
return;
}
ModelSaver<TModel> modelSaver = getModelSaver();
ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter();
DatabaseStatement statement = modelAdapter.getInsertStatement(wrapper);
try {
for (TModel model : tableCollection) {
if (modelSaver.insert(model, statement, wrapper) > 0) {
modelAdapter.storeModelInCache(model);
}
}
} finally {
statement.close();
}
}
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:22,代码来源:CacheableListModelSaver.java
示例14: updateAll
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@Override
public synchronized void updateAll(@NonNull Collection<TModel> tableCollection,
@NonNull DatabaseWrapper wrapper) {
// skip if empty.
if (tableCollection.isEmpty()) {
return;
}
ModelSaver<TModel> modelSaver = getModelSaver();
ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter();
DatabaseStatement statement = modelAdapter.getUpdateStatement(wrapper);
try {
for (TModel model : tableCollection) {
if (modelSaver.update(model, wrapper, statement)) {
modelAdapter.storeModelInCache(model);
}
}
} finally {
statement.close();
}
}
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:21,代码来源:CacheableListModelSaver.java
示例15: getTableName
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
/**
* Returns the table name for the specific model class
*
* @param table The class that implements {@link Model}
* @return The table name, which can be different than the {@link Model} class name
*/
@SuppressWarnings("unchecked")
@NonNull
public static String getTableName(Class<?> table) {
ModelAdapter modelAdapter = getModelAdapterOrNull(table);
String tableName = null;
if (modelAdapter == null) {
ModelViewAdapter modelViewAdapter = getModelViewAdapterOrNull(table);
if (modelViewAdapter != null) {
tableName = modelViewAdapter.getViewName();
} else {
throwCannotFindAdapter("ModelAdapter/ModelViewAdapter", table);
}
} else {
tableName = modelAdapter.getTableName();
}
return tableName;
}
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:24,代码来源:FlowManager.java
示例16: performBatchOperation
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void performBatchOperation(@ModelOperation int batchOperation) {
ModelAdapter adapter = FlowManager.getModelAdapter(mModelList.get(0).getClass());
if (batchOperation == MODEL_OPERATION_SAVE) {
adapter.saveAll(mModelList);
} else if (batchOperation == MODEL_OPERATION_INSERT) {
adapter.insertAll(mModelList);
} else if (batchOperation == MODEL_OPERATION_UPDATE) {
adapter.updateAll(mModelList);
}
}
开发者ID:roadhouse-dev,项目名称:RxDbflow,代码行数:12,代码来源:RxModelOperationTransaction.java
示例17: migrateServerMetadataTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateServerMetadataTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(ServerMetadata.class);
//Insert the data in new table
String sqlCopy="INSERT INTO ServerMetadata(id_control_dataelement, name, code, uid, value_type) SELECT id_control_dataelement, name, code, uid, valueType FROM ControlDataelement";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS ControlDataelement");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:11,代码来源:Migration9RenameTables.java
示例18: migrateServerMetadataTable
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
private void migrateServerMetadataTable(SQLiteDatabase database) {
ModelAdapter myAdapter = FlowManager.getModelAdapter(ServerMetadata.class);
//Insert the data in new table
String sqlCopy =
"INSERT INTO ServerMetadata(id_control_dataelement, name, code, uid, value_type) "
+ "SELECT id_control_dataelement, name, code, uid, valueType FROM "
+ "ControlDataelement";
database.execSQL(sqlCopy);
//Replace old table by new table with the new column name.
database.execSQL("DROP TABLE IF EXISTS ControlDataelement");
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:14,代码来源:Migration12UpdateEdsTables.java
示例19: recreateTables
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
public static void recreateTables(SQLiteDatabase database,Class[] tables){
for(int i=0;i<tables.length;i++){
ModelAdapter myAdapter = FlowManager.getModelAdapter(tables[i]);
database.execSQL(DROP_TABLE_IF_EXISTS + myAdapter.getTableName());
database.execSQL(myAdapter.getCreationQuery());
}
}
开发者ID:EyeSeeTea,项目名称:EDSApp,代码行数:8,代码来源:MigrationUtils.java
示例20: recreateTables
import com.raizlabs.android.dbflow.structure.ModelAdapter; //导入依赖的package包/类
public static void recreateTables(DatabaseWrapper database,Class[] tables){
for(int i=0;i<tables.length;i++){
ModelAdapter myAdapter = FlowManager.getModelAdapter(tables[i]);
database.execSQL(DROP_TABLE_IF_EXISTS + myAdapter.getTableName());
database.execSQL(myAdapter.getCreationQuery());
}
}
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:8,代码来源:MigrationUtils.java
注:本文中的com.raizlabs.android.dbflow.structure.ModelAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论