mil.nga.geopackage.db.table.UniqueConstraint Java Examples

The following examples show how to use mil.nga.geopackage.db.table.UniqueConstraint. 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: PropertiesCoreExtension.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Get or create the extension
 * 
 * @return extension
 */
public Extensions getOrCreate() {

	// Create the attributes table
	if (!geoPackage.isTable(TABLE_NAME)) {

		AttributesColumn propertyColumn = AttributesColumn.createColumn(
				COLUMN_PROPERTY, GeoPackageDataType.TEXT, true, null);
		AttributesColumn valueColumn = AttributesColumn
				.createColumn(COLUMN_VALUE, GeoPackageDataType.TEXT);

		List<AttributesColumn> additionalColumns = new ArrayList<>();
		additionalColumns.add(propertyColumn);
		additionalColumns.add(valueColumn);

		List<Constraint> constraints = new ArrayList<>();
		constraints.add(new UniqueConstraint(propertyColumn, valueColumn));

		geoPackage.createAttributesTableWithId(TABLE_NAME,
				additionalColumns, constraints);
	}

	Extensions extension = getOrCreate(EXTENSION_NAME, TABLE_NAME, null,
			EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE);

	return extension;
}
 
Example #2
Source File: TileTable.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param tableName
 *            table name
 * @param columns
 *            columns
 */
public TileTable(String tableName, List<TileColumn> columns) {
	super(new TileColumns(tableName, columns));

	// Build a unique constraint on zoom level, tile column, and tile data
	UniqueConstraint uniqueConstraint = new UniqueConstraint();
	uniqueConstraint.add(getUserColumns().getZoomLevelColumn());
	uniqueConstraint.add(getUserColumns().getTileColumnColumn());
	uniqueConstraint.add(getUserColumns().getTileRowColumn());

	// Add the unique constraint
	addConstraint(uniqueConstraint);

}