Java Code Examples for mil.nga.geopackage.features.user.FeatureDao#endTransaction()
The following examples show how to use
mil.nga.geopackage.features.user.FeatureDao#endTransaction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionTest.java From geopackage-android with MIT License | 4 votes |
/** * Test a transaction using shortcut methods * * @param featureDao feature dao * @param rows rows to insert * @param successful true for a successful transaction */ private void testUserDaoShortcuts2(FeatureDao featureDao, int rows, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { insertRows(featureDao, rows); } catch (Exception e) { featureDao.endTransaction(false); TestCase.fail(e.getMessage()); } finally { featureDao.endTransaction(successful); } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }
Example 2
Source File: TransactionTest.java From geopackage-android with MIT License | 4 votes |
/** * Test a transaction with chunked inserts * * @param featureDao feature dao * @param rows rows to insert * @param chunkSize chunk size * @param successful true for a successful transaction */ private void testUserDaoChunks(FeatureDao featureDao, int rows, int chunkSize, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { for (int count = 1; count <= rows; count++) { insertRow(featureDao); if (count % chunkSize == 0) { if (successful) { featureDao.commit(); } else { featureDao.failTransaction(); featureDao.beginTransaction(); } } } } catch (Exception e) { featureDao.failTransaction(); TestCase.fail(e.getMessage()); } finally { if (successful) { featureDao.endTransaction(); } else { featureDao.failTransaction(); } } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }
Example 3
Source File: TransactionTest.java From geopackage-java with MIT License | 4 votes |
/** * Test a transaction with chunked inserts * * @param featureDao * feature dao * @param rows * rows to insert * @param chunkSize * chunk size * @param successful * true for a successful transaction */ private void testUserDaoChunks(FeatureDao featureDao, int rows, int chunkSize, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { for (int count = 1; count <= rows; count++) { insertRow(featureDao); if (count % chunkSize == 0) { if (successful) { featureDao.commit(); } else { featureDao.failTransaction(); featureDao.beginTransaction(); } } } } catch (Exception e) { featureDao.failTransaction(); TestCase.fail(e.getMessage()); } finally { if (successful) { featureDao.endTransaction(); } else { featureDao.failTransaction(); } } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }
Example 4
Source File: TransactionTest.java From geopackage-android with MIT License | 3 votes |
/** * Test a transaction using shortcut methods * * @param featureDao feature dao * @param rows rows to insert * @param successful true for a successful transaction */ private void testUserDaoShortcuts(FeatureDao featureDao, int rows, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { insertRows(featureDao, rows); } catch (Exception e) { featureDao.failTransaction(); TestCase.fail(e.getMessage()); } finally { if (successful) { featureDao.endTransaction(); } else { featureDao.failTransaction(); } } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }
Example 5
Source File: TransactionTest.java From geopackage-java with MIT License | 3 votes |
/** * Test a transaction using shortcut methods * * @param featureDao * feature dao * @param rows * rows to insert * @param successful * true for a successful transaction */ private void testUserDaoShortcuts(FeatureDao featureDao, int rows, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { insertRows(featureDao, rows); } catch (Exception e) { featureDao.failTransaction(); TestCase.fail(e.getMessage()); } finally { if (successful) { featureDao.endTransaction(); } else { featureDao.failTransaction(); } } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }
Example 6
Source File: TransactionTest.java From geopackage-java with MIT License | 3 votes |
/** * Test a transaction using shortcut methods * * @param featureDao * feature dao * @param rows * rows to insert * @param successful * true for a successful transaction */ private void testUserDaoShortcuts2(FeatureDao featureDao, int rows, boolean successful) { int countBefore = featureDao.count(); featureDao.beginTransaction(); try { insertRows(featureDao, rows); } catch (Exception e) { featureDao.endTransaction(false); TestCase.fail(e.getMessage()); } finally { featureDao.endTransaction(successful); } TestCase.assertEquals(successful ? countBefore + rows : countBefore, featureDao.count()); }