当前位置: 首页>>代码示例>>Java>>正文


Java BriteDatabase.Transaction方法代码示例

本文整理汇总了Java中com.squareup.sqlbrite.BriteDatabase.Transaction方法的典型用法代码示例。如果您正苦于以下问题:Java BriteDatabase.Transaction方法的具体用法?Java BriteDatabase.Transaction怎么用?Java BriteDatabase.Transaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.sqlbrite.BriteDatabase的用法示例。


在下文中一共展示了BriteDatabase.Transaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTaskBundle

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
/**
 * 更新TaskBundle
 */
public void updateTaskBundle(TaskBundle taskBundle) {

  //更新 有可能是
  if (taskBundle.getTaskList() == null || taskBundle.getTaskList().size() == 0) {
    db.update(TaskBundle.TASK_BUNDLE_TABLE_NAME, getTaskBundleValues(taskBundle),
        TaskBundle.COLUMN_KEY + "=?", taskBundle.getKey());
  } else {
    if (!isExistTaskEntity(taskBundle.getBundleId())) {
      BriteDatabase.Transaction transaction = db.newTransaction();
      db.update(TaskBundle.TASK_BUNDLE_TABLE_NAME, getTaskBundleValues(taskBundle),
          TaskBundle.COLUMN_KEY + "=?", taskBundle.getKey());
      int nextTaskId = getNextID(db, TaskEntity.TASK_TABLE_NAME, TaskEntity.COLUMN_TASK_ID);
      for (TaskEntity taskEntity : taskBundle.getTaskList()) {
        taskEntity.setTaskBundleId(taskBundle.getBundleId());
        taskEntity.setTaskId(nextTaskId);
        db.insert(TaskEntity.TASK_TABLE_NAME, getTaskEntity(taskEntity));
        nextTaskId++;
      }
      transaction.markSuccessful();
      transaction.end();
    }
    db.update(TaskBundle.TASK_BUNDLE_TABLE_NAME, getTaskBundleValues(taskBundle),
        TaskBundle.COLUMN_KEY + "=?", taskBundle.getKey());
  }
}
 
开发者ID:MaYunFei,项目名称:RxJavaDownLoadMultipleFile,代码行数:29,代码来源:DownloadDao.java

示例2: addPackages

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void addPackages(List<PackageInfo> packageInfos) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {

    for (PackageInfo packageInfo : packageInfos) {
      App app = toAppMapper.map(packageInfo.applicationInfo);
      long appId = appRepository.insertOrUpdate(db, app);

      Version version = new ToVersionMapper(clock, appId).map(packageInfo);
      versionRepository.insert(db, version);

      String thread = Thread.currentThread().getName();
      Timber.d("%s : inserted app %s, %s", thread, app.packageName(), version.versionName());
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:19,代码来源:AppService.java

示例3: insertOrUpdate

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertOrUpdate(List<Permission> permissions) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    for (Permission permission : permissions) {
      PermissionGroup group = getGroup(permission.permissionGroup());

      if (group != null) {
        insertOrUpdate(group);
      }

      int updatedRows = permissionRepository.update(db, permission);

      if (updatedRows == 0) {
        permissionRepository.insert(db, permission);
      }
    }
    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:20,代码来源:PermissionService.java

示例4: insertOrUpdateInTransaction

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public int insertOrUpdateInTransaction(final String table, final List<ContentValues> batch) {
    final BriteDatabase.Transaction transaction = briteDatabase.newTransaction();
    int updatedRows = 0;
    try {
        for (final ContentValues cv : batch) {
            updatedRows += (insertOrUpdate(table, cv) >= 0 ? 1 : 0);
        }
        transaction.markSuccessful();
    } finally {
        transaction.end();
    }
    return updatedRows;
}
 
开发者ID:dmitrikudrenko,项目名称:MDRXL,代码行数:14,代码来源:Database.java

示例5: insertTaskBundle

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
/**
 * 插入TaskBundle
 */
public void insertTaskBundle(TaskBundle taskBundle) {
  if (!isExistTaskBundle(taskBundle.getKey())) {
    BriteDatabase.Transaction transaction = db.newTransaction();
    try {
      int nextBundleId =
          getNextID(db, TaskBundle.TASK_BUNDLE_TABLE_NAME, TaskBundle.COLUMN_BUNDLE_ID);
      db.insert(TaskBundle.TASK_BUNDLE_TABLE_NAME, getTaskBundleValues(taskBundle));
      List<TaskEntity> taskList = taskBundle.getTaskList();

      taskBundle.setBundleId(nextBundleId);

      if (taskList != null && taskList.size() > 0) {
        int nextTaskId = getNextID(db, TaskEntity.TASK_TABLE_NAME, TaskEntity.COLUMN_TASK_ID);
        for (TaskEntity taskEntity : taskList) {
          taskEntity.setTaskBundleId(nextBundleId);
          taskEntity.setTaskId(nextTaskId);
          db.insert(TaskEntity.TASK_TABLE_NAME, getTaskEntity(taskEntity));
          nextTaskId++;
        }
      }
      transaction.markSuccessful();
    } finally {
      transaction.end();
    }
  } else {
    TaskBundle bundleByKey = getBundleByKey(taskBundle.getKey());
    taskBundle.init(bundleByKey);
  }
}
 
开发者ID:MaYunFei,项目名称:RxJavaDownLoadMultipleFile,代码行数:33,代码来源:DownloadDao.java

示例6: deleteBundleByKey

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
/**
 * 删除数据
 */
public void deleteBundleByKey(TaskBundle bundle) {
  BriteDatabase.Transaction transaction = db.newTransaction();
  db.delete(TaskBundle.TASK_BUNDLE_TABLE_NAME, TaskBundle.COLUMN_KEY + "=?", bundle.getKey());
  db.delete(TaskEntity.TASK_TABLE_NAME, TaskEntity.COLUMN_TASK_BUNDLE_ID + "=?",
      bundle.getBundleId() + "");
  transaction.markSuccessful();
  transaction.end();
}
 
开发者ID:MaYunFei,项目名称:RxJavaDownLoadMultipleFile,代码行数:12,代码来源:DownloadDao.java

示例7: insert

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insert(List<Library> libraries) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    for (Library library : libraries) {
      libraryRepository.insert(db, library);
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:11,代码来源:LibraryService.java

示例8: insertOrUpdate

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertOrUpdate(List<Library> libraries) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    for (Library library : libraries) {
      int updatedRows = libraryRepository.update(db, library);

      if (updatedRows == 0) {
        libraryRepository.insert(db, library);
      }
    }
    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:14,代码来源:LibraryService.java

示例9: insertForApp

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertForApp(App app, List<Library> libraries) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    for (Library library : libraries) {
      libraryAppRepository.insert(db, library.id(), app.id());
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:11,代码来源:LibraryService.java

示例10: insertOrUpdate

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertOrUpdate(App app) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    appRepository.insertOrUpdate(db, app);
    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:8,代码来源:AppService.java

示例11: addPackage

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void addPackage(PackageInfo packageInfo) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    App app = toAppMapper.map(packageInfo.applicationInfo);
    long appId = appRepository.insertOrUpdate(db, app);

    Version version = new ToVersionMapper(clock, appId).map(packageInfo);
    versionRepository.insertOrUpdate(db, version);

    String thread = Thread.currentThread().getName();
    Timber.d("%s : inserted app %s, %s", thread, app.packageName(), version.versionName());

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:16,代码来源:AppService.java

示例12: removeAllByPackageName

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void removeAllByPackageName(List<String> packageNames) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {

    for (String packageName : packageNames) {
      String where = String.format("%s = '%s'", App.PACKAGENAME, packageName);
      appRepository.delete(db, where);

      String thread = Thread.currentThread().getName();
      Timber.d("%s : delete app %s", thread, packageName);
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:16,代码来源:AppService.java

示例13: insertForApp

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertForApp(List<AppPermission> appPermissions) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {

    for (AppPermission appPermission : appPermissions) {
      appPermissionRepository.insert(db, appPermission);
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:12,代码来源:PermissionService.java

示例14: insertForAppAndLibrary

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insertForAppAndLibrary(App app, Library library, List<Permission> permissions) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {

    for (Permission permission : permissions) {
      AppLibraryPermission appLibraryPermission =
          AppLibraryPermission.create(app.id(), library.id(), permission.id());
      appLibraryPermissionRepository.insert(db, appLibraryPermission);
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:14,代码来源:PermissionService.java

示例15: insert

import com.squareup.sqlbrite.BriteDatabase; //导入方法依赖的package包/类
public void insert(List<ProtectedMethod> protectedMethods) {
  BriteDatabase db = databaseManager.get();
  try (BriteDatabase.Transaction transaction = db.newTransaction()) {
    for (ProtectedMethod protectedMethod : protectedMethods) {
      methodRepository.insert(db, protectedMethod);
    }

    transaction.markSuccessful();
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:11,代码来源:MethodService.java


注:本文中的com.squareup.sqlbrite.BriteDatabase.Transaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。