本文整理汇总了Java中mil.nga.geopackage.GeoPackage.getDataColumnConstraintsDao方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.getDataColumnConstraintsDao方法的具体用法?Java GeoPackage.getDataColumnConstraintsDao怎么用?Java GeoPackage.getDataColumnConstraintsDao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.GeoPackage
的用法示例。
在下文中一共展示了GeoPackage.getDataColumnConstraintsDao方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConstraints
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Create Data Column Constraints
*
* @param geoPackage
* @throws SQLException
*/
public static void createConstraints(GeoPackage geoPackage)
throws SQLException {
geoPackage.createDataColumnConstraintsTable();
DataColumnConstraintsDao dao = geoPackage.getDataColumnConstraintsDao();
DataColumnConstraints sampleRange = new DataColumnConstraints();
sampleRange.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
sampleRange.setConstraintType(DataColumnConstraintType.RANGE);
sampleRange.setMin(BigDecimal.ONE);
sampleRange.setMinIsInclusive(true);
sampleRange.setMax(BigDecimal.TEN);
sampleRange.setMaxIsInclusive(true);
dao.create(sampleRange);
DataColumnConstraints sampleEnum1 = new DataColumnConstraints();
sampleEnum1.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum1.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum1.setValue("1");
dao.create(sampleEnum1);
DataColumnConstraints sampleEnum3 = new DataColumnConstraints();
sampleEnum3.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum3.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum3.setValue("3");
dao.create(sampleEnum3);
DataColumnConstraints sampleEnum5 = new DataColumnConstraints();
sampleEnum5.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum5.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum5.setValue("5");
dao.create(sampleEnum5);
DataColumnConstraints sampleEnum7 = new DataColumnConstraints();
sampleEnum7.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum7.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum7.setValue("7");
dao.create(sampleEnum7);
DataColumnConstraints sampleEnum9 = new DataColumnConstraints();
sampleEnum9.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum9.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum9.setValue("9");
dao.create(sampleEnum9);
DataColumnConstraints sampleGlob = new DataColumnConstraints();
sampleGlob.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
sampleGlob.setConstraintType(DataColumnConstraintType.GLOB);
sampleGlob.setValue("[1-2][0-9][0-9][0-9]");
dao.create(sampleGlob);
}
示例2: createConstraints
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Create Data Column Constraints
*
* @param geoPackage
* @throws SQLException
*/
public static void createConstraints(GeoPackage geoPackage)
throws SQLException {
geoPackage.createDataColumnConstraintsTable();
DataColumnConstraintsDao dao = geoPackage.getDataColumnConstraintsDao();
DataColumnConstraints sampleRange = new DataColumnConstraints();
sampleRange.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
sampleRange.setConstraintType(DataColumnConstraintType.RANGE);
sampleRange.setMin(BigDecimal.ONE);
sampleRange.setMinIsInclusive(true);
sampleRange.setMax(BigDecimal.TEN);
sampleRange.setMaxIsInclusive(true);
dao.create(sampleRange);
DataColumnConstraints sampleEnum1 = new DataColumnConstraints();
sampleEnum1.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum1.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum1.setValue("1");
dao.create(sampleEnum1);
DataColumnConstraints sampleEnum3 = new DataColumnConstraints();
sampleEnum3.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum3.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum3.setValue("3");
dao.create(sampleEnum3);
DataColumnConstraints sampleEnum5 = new DataColumnConstraints();
sampleEnum5.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum5.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum5.setValue("5");
dao.create(sampleEnum5);
DataColumnConstraints sampleEnum7 = new DataColumnConstraints();
sampleEnum7.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum7.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum7.setValue("7");
dao.create(sampleEnum7);
DataColumnConstraints sampleEnum9 = new DataColumnConstraints();
sampleEnum9.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum9.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum9.setValue("9");
dao.create(sampleEnum9);
DataColumnConstraints sampleGlob = new DataColumnConstraints();
sampleGlob.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
sampleGlob.setConstraintType(DataColumnConstraintType.GLOB);
sampleGlob.setValue("[1-2][0-9][0-9][0-9]");
dao.create(sampleGlob);
}
示例3: testCreate
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test create
*
* @param geoPackage
* @throws SQLException
*/
public static void testCreate(GeoPackage geoPackage) throws SQLException {
DataColumnConstraintsDao dao = geoPackage.getDataColumnConstraintsDao();
if (dao.isTableExists()) {
// Get current count
long count = dao.countOf();
// Create new data column constraints
String name = "test_create_constraint";
DataColumnConstraintType type = DataColumnConstraintType.RANGE;
BigDecimal min = new BigDecimal(50);
boolean minInclusive = false;
BigDecimal max = new BigDecimal(50000000);
boolean maxInclusive = true;
String description = "test create description";
DataColumnConstraints dataColumnConstraints = new DataColumnConstraints();
dataColumnConstraints.setConstraintName(name);
dataColumnConstraints.setConstraintType(type);
dataColumnConstraints.setMin(min);
dataColumnConstraints.setMinIsInclusive(minInclusive);
dataColumnConstraints.setMax(max);
dataColumnConstraints.setMaxIsInclusive(maxInclusive);
dataColumnConstraints.setDescription(description);
dao.create(dataColumnConstraints);
// Verify count
long newCount = dao.countOf();
TestCase.assertEquals(count + 1, newCount);
// Verify saved data column constraints
DataColumnConstraints queryDataColumnConstraints = dao
.queryByUnique(name, type, null);
TestCase.assertEquals(name,
queryDataColumnConstraints.getConstraintName());
TestCase.assertEquals(type,
queryDataColumnConstraints.getConstraintType());
TestCase.assertNull(queryDataColumnConstraints.getValue());
TestCase.assertEquals(min, queryDataColumnConstraints.getMin());
TestCase.assertEquals(minInclusive, queryDataColumnConstraints
.getMinIsInclusive().booleanValue());
TestCase.assertEquals(max, queryDataColumnConstraints.getMax());
TestCase.assertEquals(maxInclusive, queryDataColumnConstraints
.getMaxIsInclusive().booleanValue());
TestCase.assertEquals(description,
queryDataColumnConstraints.getDescription());
}
}
示例4: testDelete
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test delete
*
* @param geoPackage
* @throws SQLException
*/
public static void testDelete(GeoPackage geoPackage) throws SQLException {
DataColumnConstraintsDao dao = geoPackage.getDataColumnConstraintsDao();
DataColumnsDao dataColumnsDao = geoPackage.getDataColumnsDao();
if (dao.isTableExists()) {
List<DataColumnConstraints> results = dao.queryForAll();
if (!results.isEmpty()) {
// Choose random data column constraints
int random = (int) (Math.random() * results.size());
DataColumnConstraints dataColumnConstraints = results
.get(random);
int remainingConstraints = dao.queryByConstraintName(
dataColumnConstraints.getConstraintName()).size();
int dataColumns = dataColumnsDao.queryByConstraintName(
dataColumnConstraints.getConstraintName()).size();
// Delete the data column constraints
dao.deleteCascade(dataColumnConstraints);
// Verify deleted
DataColumnConstraints queryDataColumns = dao.queryByUnique(
dataColumnConstraints.getConstraintName(),
dataColumnConstraints.getConstraintType(),
dataColumnConstraints.getValue());
TestCase.assertNull(queryDataColumns);
// Verify cascade delete
int afterRemainingConstraints = dao.queryByConstraintName(
dataColumnConstraints.getConstraintName()).size();
int afterDataColumns = dataColumnsDao.queryByConstraintName(
dataColumnConstraints.getConstraintName()).size();
TestCase.assertEquals(remainingConstraints - 1,
afterRemainingConstraints);
if (remainingConstraints == 1) {
TestCase.assertEquals(0, afterDataColumns);
} else {
TestCase.assertEquals(dataColumns, afterDataColumns);
}
// Prepared deleted
results = dao.queryForAll();
if (!results.isEmpty()) {
// Choose random data column constraints
random = (int) (Math.random() * results.size());
dataColumnConstraints = results.get(random);
// Find which data column constraints to delete
QueryBuilder<DataColumnConstraints, Void> qb = dao
.queryBuilder();
qb.where().eq(DataColumnConstraints.COLUMN_CONSTRAINT_NAME,
dataColumnConstraints.getConstraintName());
PreparedQuery<DataColumnConstraints> query = qb.prepare();
List<DataColumnConstraints> queryResults = dao.query(query);
int count = queryResults.size();
// Delete
DeleteBuilder<DataColumnConstraints, Void> db = dao
.deleteBuilder();
db.where().eq(DataColumnConstraints.COLUMN_CONSTRAINT_NAME,
dataColumnConstraints.getConstraintName());
PreparedDelete<DataColumnConstraints> deleteQuery = db
.prepare();
int deleted = dao.delete(deleteQuery);
TestCase.assertEquals(count, deleted);
}
}
}
}
示例5: createConstraints
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Create Data Column Constraints
*
* @param geoPackage
* @throws SQLException
*/
public static void createConstraints(GeoPackage geoPackage)
throws SQLException {
geoPackage.createDataColumnConstraintsTable();
DataColumnConstraintsDao dao = geoPackage.getDataColumnConstraintsDao();
DataColumnConstraints sampleRange = new DataColumnConstraints();
sampleRange.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
sampleRange.setConstraintType(DataColumnConstraintType.RANGE);
sampleRange.setMin(BigDecimal.ONE);
sampleRange.setMinIsInclusive(true);
sampleRange.setMax(BigDecimal.TEN);
sampleRange.setMaxIsInclusive(true);
dao.create(sampleRange);
DataColumnConstraints sampleEnum1 = new DataColumnConstraints();
sampleEnum1.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum1.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum1.setValue("1");
dao.create(sampleEnum1);
DataColumnConstraints sampleEnum3 = new DataColumnConstraints();
sampleEnum3.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum3.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum3.setValue("3");
dao.create(sampleEnum3);
DataColumnConstraints sampleEnum5 = new DataColumnConstraints();
sampleEnum5.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum5.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum5.setValue("5");
dao.create(sampleEnum5);
DataColumnConstraints sampleEnum7 = new DataColumnConstraints();
sampleEnum7.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum7.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum7.setValue("7");
dao.create(sampleEnum7);
DataColumnConstraints sampleEnum9 = new DataColumnConstraints();
sampleEnum9.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
sampleEnum9.setConstraintType(DataColumnConstraintType.ENUM);
sampleEnum9.setValue("9");
dao.create(sampleEnum9);
DataColumnConstraints sampleGlob = new DataColumnConstraints();
sampleGlob.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
sampleGlob.setConstraintType(DataColumnConstraintType.GLOB);
sampleGlob.setValue("[1-2][0-9][0-9][0-9]");
dao.create(sampleGlob);
}