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() . These examples are extracted from open source projects. 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 Project: geopackage-android   File: TransactionTest.java    License: MIT License 4 votes vote down vote up
/**
 * 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 Project: geopackage-android   File: TransactionTest.java    License: MIT License 4 votes vote down vote up
/**
 * 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 Project: geopackage-java   File: TransactionTest.java    License: MIT License 4 votes vote down vote up
/**
 * 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 Project: geopackage-android   File: TransactionTest.java    License: MIT License 3 votes vote down vote up
/**
 * 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 Project: geopackage-java   File: TransactionTest.java    License: MIT License 3 votes vote down vote up
/**
 * 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 Project: geopackage-java   File: TransactionTest.java    License: MIT License 3 votes vote down vote up
/**
 * 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());

}