mil.nga.geopackage.user.custom.UserCustomTable Java Examples
The following examples show how to use
mil.nga.geopackage.user.custom.UserCustomTable.
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: RelatedTablesUtils.java From geopackage-java with MIT License | 6 votes |
/** * Validate a user row for expected Dublin Core Column * * @param userRow * user custom row * @param type * Dublin Core Type */ public static void validateDublinCoreColumn(UserCustomRow userRow, DublinCoreType type) { UserCustomTable customTable = userRow.getTable(); TestCase.assertTrue(DublinCoreMetadata.hasColumn(userRow.getTable(), type)); TestCase.assertTrue(DublinCoreMetadata.hasColumn(userRow, type)); UserCustomColumn column1 = DublinCoreMetadata.getColumn(customTable, type); UserCustomColumn column2 = DublinCoreMetadata.getColumn(userRow, type); TestCase.assertNotNull(column1); TestCase.assertNotNull(column2); TestCase.assertEquals(column1, column2); Object value = DublinCoreMetadata.getValue(userRow, type); TestCase.assertNotNull(value); }
Example #2
Source File: GeoPackageImpl.java From geopackage-android with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public UserCustomDao getUserCustomDao(UserCustomTable table) { UserCustomDao dao = new UserCustomDao(getName(), database, table); // Register the table name (with and without quotes) to wrap cursors with the user custom cursor final UserCustomTable userCustomTable = table; registerCursorWrapper(table.getTableName(), new GeoPackageCursorWrapper() { @Override public Cursor wrapCursor(Cursor cursor) { return new UserCustomCursor(userCustomTable, cursor); } }); return dao; }
Example #3
Source File: RelatedTablesUtils.java From geopackage-android with MIT License | 6 votes |
/** * Validate a user row for expected Dublin Core Column * * @param userRow user custom row * @param type Dublin Core Type */ public static void validateDublinCoreColumn(UserCustomRow userRow, DublinCoreType type) { UserCustomTable customTable = userRow.getTable(); TestCase.assertTrue(DublinCoreMetadata.hasColumn(userRow.getTable(), type)); TestCase.assertTrue(DublinCoreMetadata.hasColumn(userRow, type)); UserCustomColumn column1 = DublinCoreMetadata.getColumn(customTable, type); UserCustomColumn column2 = DublinCoreMetadata.getColumn(userRow, type); TestCase.assertNotNull(column1); TestCase.assertNotNull(column2); TestCase.assertEquals(column1, column2); Object value = DublinCoreMetadata.getValue(userRow, type); TestCase.assertNotNull(value); }
Example #4
Source File: RTreeIndexCoreExtension.java From geopackage-core-java with MIT License | 6 votes |
/** * Get the RTree Table * * @param featureTable * feature table * @return RTree table */ protected UserCustomTable getRTreeTable(FeatureTable featureTable) { List<UserCustomColumn> columns = new ArrayList<>(); columns.add(UserCustomColumn.createPrimaryKeyColumn(COLUMN_ID)); columns.add(UserCustomColumn.createColumn(COLUMN_MIN_X, GeoPackageDataType.FLOAT)); columns.add(UserCustomColumn.createColumn(COLUMN_MAX_X, GeoPackageDataType.FLOAT)); columns.add(UserCustomColumn.createColumn(COLUMN_MIN_Y, GeoPackageDataType.FLOAT)); columns.add(UserCustomColumn.createColumn(COLUMN_MAX_Y, GeoPackageDataType.FLOAT)); String rTreeTableName = getRTreeTableName(featureTable.getTableName(), featureTable.getGeometryColumnName()); UserCustomTable userCustomTable = new UserCustomTable(rTreeTableName, columns); return userCustomTable; }
Example #5
Source File: GeoPackageImpl.java From geopackage-android with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public UserCustomDao getUserCustomDao(String tableName) { UserCustomTable table = UserCustomTableReader.readTable(database, tableName); return getUserCustomDao(table); }
Example #6
Source File: GeoPackageImpl.java From geopackage-java with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public UserCustomDao getUserCustomDao(String tableName) { UserCustomTable table = UserCustomTableReader.readTable(database, tableName); return getUserCustomDao(table); }
Example #7
Source File: RTreeIndexExtension.java From geopackage-java with MIT License | 5 votes |
/** * Get a RTree Index Table DAO for the feature dao * * @param featureDao * feature DAO * @return RTree Index Table DAO * @since 3.1.0 */ public RTreeIndexTableDao getTableDao(FeatureDao featureDao) { GeoPackageConnection connection = getGeoPackage().getConnection(); UserCustomTable userCustomTable = getRTreeTable(featureDao.getTable()); UserCustomDao userCustomDao = new UserCustomDao(geoPackage.getName(), connection, userCustomTable); return new RTreeIndexTableDao(this, userCustomDao, featureDao); }
Example #8
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get the primary key of a table * * @param tableName * table name * @return the column name */ public String getPrimaryKeyColumnName(String tableName) { UserCustomTable table = UserCustomTableReader .readTable(geoPackage.getDatabase(), tableName); UserCustomColumn pkColumn = table.getPkColumn(); if (pkColumn == null) { throw new GeoPackageException( "Found no primary key for table " + tableName); } return pkColumn.getName(); }
Example #9
Source File: RTreeIndexExtension.java From geopackage-android with MIT License | 5 votes |
/** * Get a RTree Index Table DAO for the feature dao * * @param featureDao feature DAO * @return RTree Index Table DAO * @since 3.1.0 */ public RTreeIndexTableDao getTableDao(FeatureDao featureDao) { UserCustomTable userCustomTable = getRTreeTable(featureDao.getTable()); UserCustomDao userCustomDao = getGeoPackage().getUserCustomDao(userCustomTable); return new RTreeIndexTableDao(this, userCustomDao, featureDao); }
Example #10
Source File: RelatedTablesUtils.java From geopackage-java with MIT License | 4 votes |
/** * Populate the user row additional column values * * @param userTable * user custom table * @param userRow * user custom row * @param skipColumns * columns to skip populating */ public static void populateUserRow(UserCustomTable userTable, UserCustomRow userRow, List<String> skipColumns) { Set<String> skipColumnsSet = new HashSet<>(skipColumns); for (UserCustomColumn column : userTable.getColumns()) { if (!skipColumnsSet.contains(column.getName())) { // Leave nullable columns null 20% of the time if (!column.isNotNull() && DublinCoreType.fromName(column.getName()) == null) { if (Math.random() < 0.2) { continue; } } Object value = null; switch (column.getDataType()) { case TEXT: String text = UUID.randomUUID().toString(); if (column.getMax() != null && text.length() > column.getMax()) { text = text.substring(0, column.getMax().intValue()); } value = text; break; case REAL: case DOUBLE: value = Math.random() * 5000.0; break; case BOOLEAN: value = Math.random() < .5 ? false : true; break; case INTEGER: case INT: value = (int) (Math.random() * 500); break; case BLOB: byte[] blob = UUID.randomUUID().toString().getBytes(); if (column.getMax() != null && blob.length > column.getMax()) { byte[] blobLimited = new byte[column.getMax() .intValue()]; ByteBuffer.wrap(blob, 0, column.getMax().intValue()) .get(blobLimited); blob = blobLimited; } value = blob; break; case DATE: case DATETIME: DateConverter converter = DateConverter.converter(column .getDataType()); Date date = new Date(); if (Math.random() < .5) { value = date; } else { value = converter.stringValue(date); } break; default: throw new UnsupportedOperationException( "Not implemented for data type: " + column.getDataType()); } userRow.setValue(column.getName(), value); } } }
Example #11
Source File: GeoPackageImpl.java From geopackage-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public UserCustomDao getUserCustomDao(UserCustomTable table) { return new UserCustomDao(getName(), database, table); }
Example #12
Source File: RelatedTablesUtils.java From geopackage-android with MIT License | 4 votes |
/** * Populate the user row additional column values * * @param userTable user custom table * @param userRow user custom row * @param skipColumns columns to skip populating */ public static void populateUserRow(UserCustomTable userTable, UserCustomRow userRow, List<String> skipColumns) { Set<String> skipColumnsSet = new HashSet<>(skipColumns); for (UserCustomColumn column : userTable.getColumns()) { if (!skipColumnsSet.contains(column.getName())) { // Leave nullable columns null 20% of the time if (!column.isNotNull() && DublinCoreType.fromName(column.getName()) == null) { if (Math.random() < 0.2) { continue; } } Object value = null; switch (column.getDataType()) { case TEXT: String text = UUID.randomUUID().toString(); if (column.getMax() != null && text.length() > column.getMax()) { text = text.substring(0, column.getMax().intValue()); } value = text; break; case REAL: case DOUBLE: value = Math.random() * 5000.0; break; case BOOLEAN: value = Math.random() < .5 ? false : true; break; case INTEGER: case INT: value = (int) (Math.random() * 500); break; case BLOB: byte[] blob = UUID.randomUUID().toString().getBytes(); if (column.getMax() != null && blob.length > column.getMax()) { byte[] blobLimited = new byte[column.getMax() .intValue()]; ByteBuffer.wrap(blob, 0, column.getMax().intValue()) .get(blobLimited); blob = blobLimited; } value = blob; break; case DATE: case DATETIME: DateConverter converter = DateConverter.converter(column .getDataType()); Date date = new Date(); if (Math.random() < .5) { value = date; } else { value = converter.stringValue(date); } break; default: throw new UnsupportedOperationException( "Not implemented for data type: " + column.getDataType()); } userRow.setValue(column.getName(), value); } } }
Example #13
Source File: NGAExtensions.java From geopackage-core-java with MIT License | 4 votes |
/** * Copy the feature table style * * @param featureStyleExtension * feature style extension * @param mappingTablePrefix * mapping table prefix * @param table * table name * @param newTable * new table name * @param contentsId * contents id * @param newContentsId * new contents id */ private static void copyFeatureTableStyle( FeatureCoreStyleExtension featureStyleExtension, String mappingTablePrefix, String table, String newTable, long contentsId, long newContentsId) throws SQLException { GeoPackageCore geoPackage = featureStyleExtension.getGeoPackage(); String mappingTableName = featureStyleExtension .getMappingTableName(mappingTablePrefix, table); ExtensionsDao extensionsDao = featureStyleExtension.getExtensionsDao(); List<Extensions> extensions = extensionsDao.queryByExtension( RelatedTablesCoreExtension.EXTENSION_NAME, mappingTableName); if (!extensions.isEmpty()) { String newMappingTableName = featureStyleExtension .getMappingTableName(mappingTablePrefix, newTable); UserCustomTable userTable = UserCustomTableReader .readTable(geoPackage.getDatabase(), mappingTableName); AlterTable.copyTable(geoPackage.getDatabase(), userTable, newMappingTableName, false); TableMapping mappingTableTableMapping = new TableMapping(userTable, newMappingTableName); MappedColumn baseIdColumn = mappingTableTableMapping .getColumn(UserMappingTable.COLUMN_BASE_ID); baseIdColumn.setConstantValue(newContentsId); baseIdColumn.setWhereValue(contentsId); CoreSQLUtils.transferTableContent(geoPackage.getDatabase(), mappingTableTableMapping); Extensions extension = extensions.get(0); extension.setTableName(newMappingTableName); extensionsDao.create(extension); TableMapping extendedRelationTableMapping = new TableMapping( geoPackage.getDatabase(), ExtendedRelation.TABLE_NAME); extendedRelationTableMapping .removeColumn(ExtendedRelation.COLUMN_ID); MappedColumn baseTableNameColumn = extendedRelationTableMapping .getColumn(ExtendedRelation.COLUMN_BASE_TABLE_NAME); baseTableNameColumn.setWhereValue(ContentsId.TABLE_NAME); MappedColumn mappingTableNameColumn = extendedRelationTableMapping .getColumn(ExtendedRelation.COLUMN_MAPPING_TABLE_NAME); mappingTableNameColumn.setConstantValue(newMappingTableName); mappingTableNameColumn.setWhereValue(mappingTableName); CoreSQLUtils.transferTableContent(geoPackage.getDatabase(), extendedRelationTableMapping); } }
Example #14
Source File: GeoPackageExtensions.java From geopackage-core-java with MIT License | 4 votes |
/** * Copy the Related Tables extensions for the table * * @param geoPackage * GeoPackage * @param table * table name * @param newTable * new table name * @since 3.3.0 */ public static void copyRelatedTables(GeoPackageCore geoPackage, String table, String newTable) { try { RelatedTablesCoreExtension relatedTablesExtension = getRelatedTableExtension( geoPackage); if (relatedTablesExtension.has()) { ExtendedRelationsDao extendedRelationsDao = relatedTablesExtension .getExtendedRelationsDao(); ExtensionsDao extensionsDao = geoPackage.getExtensionsDao(); List<ExtendedRelation> extendedRelations = extendedRelationsDao .getBaseTableRelations(table); for (ExtendedRelation extendedRelation : extendedRelations) { String mappingTableName = extendedRelation .getMappingTableName(); List<Extensions> extensions = extensionsDao .queryByExtension( RelatedTablesCoreExtension.EXTENSION_NAME, mappingTableName); if (!extensions.isEmpty()) { String newMappingTableName = CoreSQLUtils.createName( geoPackage.getDatabase(), mappingTableName, table, newTable); UserCustomTable userTable = UserCustomTableReader .readTable(geoPackage.getDatabase(), mappingTableName); AlterTable.copyTable(geoPackage.getDatabase(), userTable, newMappingTableName); Extensions extension = extensions.get(0); extension.setTableName(newMappingTableName); extensionsDao.create(extension); TableMapping extendedRelationTableMapping = new TableMapping( geoPackage.getDatabase(), ExtendedRelation.TABLE_NAME); extendedRelationTableMapping .removeColumn(ExtendedRelation.COLUMN_ID); MappedColumn baseTableNameColumn = extendedRelationTableMapping .getColumn( ExtendedRelation.COLUMN_BASE_TABLE_NAME); baseTableNameColumn.setConstantValue(newTable); baseTableNameColumn.setWhereValue(table); MappedColumn mappingTableNameColumn = extendedRelationTableMapping .getColumn( ExtendedRelation.COLUMN_MAPPING_TABLE_NAME); mappingTableNameColumn .setConstantValue(newMappingTableName); mappingTableNameColumn.setWhereValue(mappingTableName); CoreSQLUtils.transferTableContent( geoPackage.getDatabase(), extendedRelationTableMapping); } } } } catch (Exception e) { logger.log(Level.WARNING, "Failed to create Related Tables for table: " + newTable + ", copied from table: " + table, e); } }
Example #15
Source File: GeoPackageExtensions.java From geopackage-core-java with MIT License | 4 votes |
/** * Copy the Schema extensions for the table * * @param geoPackage * GeoPackage * @param table * table name * @param newTable * new table name * @since 3.3.0 */ public static void copySchema(GeoPackageCore geoPackage, String table, String newTable) { try { if (geoPackage.isTable(DataColumns.TABLE_NAME)) { UserCustomTable dataColumnsTable = UserCustomTableReader .readTable(geoPackage.getDatabase(), DataColumns.TABLE_NAME); UserCustomColumn nameColumn = dataColumnsTable .getColumn(DataColumns.COLUMN_NAME); if (nameColumn.hasConstraints()) { nameColumn.clearConstraints(); if (dataColumnsTable.hasConstraints()) { dataColumnsTable.clearConstraints(); String constraintSql = GeoPackageTableCreator .readSQLScript( GeoPackageTableCreator.DATA_COLUMNS) .get(0); TableConstraints constraints = ConstraintParser .getConstraints(constraintSql); dataColumnsTable.addConstraints( constraints.getTableConstraints()); } AlterTable.alterColumn(geoPackage.getDatabase(), dataColumnsTable, nameColumn); } CoreSQLUtils.transferTableContent(geoPackage.getDatabase(), DataColumns.TABLE_NAME, DataColumns.COLUMN_TABLE_NAME, newTable, table); } } catch (Exception e) { logger.log(Level.WARNING, "Failed to create Schema for table: " + newTable + ", copied from table: " + table, e); } }
Example #16
Source File: AlterTable.java From geopackage-core-java with MIT License | 3 votes |
/** * Drop columns * * @param db * connection * @param tableName * table name * @param columnNames * column names */ public static void dropColumns(GeoPackageCoreConnection db, String tableName, Collection<String> columnNames) { UserCustomTable userTable = UserCustomTableReader.readTable(db, tableName); dropColumns(db, userTable, columnNames); }
Example #17
Source File: AlterTable.java From geopackage-core-java with MIT License | 3 votes |
/** * Copy the table * * @param db * connection * @param tableName * table name * @param newTableName * new table name * @param transferContent * transfer row content to the new table */ public static void copyTable(GeoPackageCoreConnection db, String tableName, String newTableName, boolean transferContent) { UserCustomTable userTable = UserCustomTableReader.readTable(db, tableName); copyTable(db, userTable, newTableName, transferContent); }
Example #18
Source File: AlterTable.java From geopackage-core-java with MIT License | 3 votes |
/** * Alter columns * * @param db * connection * @param tableName * table name * @param columns * columns * @param <T> * user column type */ public static <T extends UserColumn> void alterColumns( GeoPackageCoreConnection db, String tableName, Collection<UserCustomColumn> columns) { UserCustomTable userTable = UserCustomTableReader.readTable(db, tableName); alterColumns(db, userTable, columns); }
Example #19
Source File: UserRelatedTable.java From geopackage-core-java with MIT License | 3 votes |
/** * Constructor * * @param relationName * relation name * @param dataType * contents data type * @param userCustomTable * user custom table * @since 3.1.0 */ public UserRelatedTable(String relationName, String dataType, UserCustomTable userCustomTable) { super(userCustomTable); this.relationName = relationName; this.dataType = dataType; }
Example #20
Source File: IconTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param table * user custom table */ protected IconTable(UserCustomTable table) { super(table); }
Example #21
Source File: SimpleAttributesTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param table * user custom table */ protected SimpleAttributesTable(UserCustomTable table) { super(RELATION_TYPE.getName(), RELATION_TYPE.getDataType(), table); validateColumns(); }
Example #22
Source File: MediaTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param table * user custom table */ protected MediaTable(UserCustomTable table) { super(RELATION_TYPE.getName(), RELATION_TYPE.getDataType(), table); }
Example #23
Source File: GeoPackage.java From geopackage-android with MIT License | 2 votes |
/** * Get a User Custom DAO from a table * * @param table table * @return user custom dao * @since 3.4.0 */ public UserCustomDao getUserCustomDao(UserCustomTable table);
Example #24
Source File: StyleMappingTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param table * user custom table */ protected StyleMappingTable(UserCustomTable table) { super(table); }
Example #25
Source File: GeoPackage.java From geopackage-java with MIT License | 2 votes |
/** * Get a User Custom DAO from a table * * @param table * table * @return user custom dao * @since 3.4.0 */ public UserCustomDao getUserCustomDao(UserCustomTable table);
Example #26
Source File: UserMappingTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param table * user custom table */ protected UserMappingTable(UserCustomTable table) { super(table); }