/** * Set the contents * * @param contents * contents */ public void setContents(Contents contents) { this.contents = contents; if (contents != null) { tableName = contents.getTableName(); } else { tableName = null; } }
/** * Query by contents * * @param contents * contents * @return gridded tile list */ public List<GriddedTile> query(Contents contents) { return query(contents.getTableName()); }
/** * Delete by contents * * @param contents * contents * @return deleted count */ public int delete(Contents contents) { return delete(contents.getTableName()); }
/** * Get table names * * @return table names * @throws SQLException * upon query error * @since 1.2.1 */ public List<String> getTables() throws SQLException { List<Contents> contents = queryForAll(); List<String> tableNames = new ArrayList<String>(); for (Contents content : contents) { tableNames.add(content.getTableName()); } return tableNames; }
/** * Get table names by data type * * @param dataType * data type * @return table names * @throws SQLException * upon query error * @since 3.0.1 */ public List<String> getTables(String dataType) throws SQLException { List<Contents> contents = getContents(dataType); List<String> tableNames = new ArrayList<String>(); for (Contents content : contents) { tableNames.add(content.getTableName()); } return tableNames; }
/** * Delete the Contents, cascading optionally including the user table * * @param contents * contents * @param userTable * true if a user table * @return deleted count * @throws SQLException * upon deletion error */ public int deleteCascade(Contents contents, boolean userTable) throws SQLException { int count = deleteCascade(contents); if (userTable) { dropTable(contents.getTableName()); } return count; }
/** * Text output from a Contents * * @param contents * contents * @return text */ public String textOutput(Contents contents) { StringBuilder output = new StringBuilder(); output.append("\t" + Contents.COLUMN_TABLE_NAME + ": " + contents.getTableName()); output.append("\n\t" + Contents.COLUMN_DATA_TYPE + ": " + contents.getDataType()); output.append("\n\t" + Contents.COLUMN_IDENTIFIER + ": " + contents.getIdentifier()); output.append("\n\t" + Contents.COLUMN_DESCRIPTION + ": " + contents.getDescription()); output.append("\n\t" + Contents.COLUMN_LAST_CHANGE + ": " + contents.getLastChange()); output.append("\n\t" + Contents.COLUMN_MIN_X + ": " + contents.getMinX()); output.append("\n\t" + Contents.COLUMN_MIN_Y + ": " + contents.getMinY()); output.append("\n\t" + Contents.COLUMN_MAX_X + ": " + contents.getMaxX()); output.append("\n\t" + Contents.COLUMN_MAX_Y + ": " + contents.getMaxY()); output.append("\n" + textOutput(contents.getSrs())); return output.toString(); }
/** * {@inheritDoc} */ @Override public TileDao getTileDao(Contents contents) { if (contents == null) { throw new GeoPackageException("Non null " + Contents.class.getSimpleName() + " is required to create " + TileDao.class.getSimpleName()); } TileMatrixSet tileMatrixSet = null; try { tileMatrixSet = getTileMatrixSetDao().queryForId( contents.getTableName()); } catch (SQLException e) { throw new GeoPackageException("No " + TileMatrixSet.class.getSimpleName() + " could be retrieved for " + Contents.class.getSimpleName() + " " + contents.getId()); } if (tileMatrixSet == null) { throw new GeoPackageException("No " + TileMatrixSet.class.getSimpleName() + " exists for " + Contents.class.getSimpleName() + " " + contents.getId()); } return getTileDao(tileMatrixSet); }
/** * {@inheritDoc} */ @Override public FeatureDao getFeatureDao(Contents contents) { if (contents == null) { throw new GeoPackageException("Non null " + Contents.class.getSimpleName() + " is required to create " + FeatureDao.class.getSimpleName()); } GeometryColumns geometryColumns = null; try { geometryColumns = getGeometryColumnsDao().queryForTableName( contents.getTableName()); } catch (SQLException e) { throw new GeoPackageException("No " + GeometryColumns.class.getSimpleName() + " could be retrieved for " + Contents.class.getSimpleName() + " " + contents.getId()); } if (geometryColumns == null) { throw new GeoPackageException("No " + GeometryColumns.class.getSimpleName() + " exists for " + Contents.class.getSimpleName() + " " + contents.getId()); } return getFeatureDao(geometryColumns); }
/** * {@inheritDoc} */ @Override public AttributesDao getAttributesDao(Contents contents) { if (contents == null) { throw new GeoPackageException("Non null " + Contents.class.getSimpleName() + " is required to create " + AttributesDao.class.getSimpleName()); } if (contents.getDataType() != ContentsDataType.ATTRIBUTES) { throw new GeoPackageException(Contents.class.getSimpleName() + " is required to be of type " + ContentsDataType.ATTRIBUTES + ". Actual: " + contents.getDataTypeString()); } // Read the existing table and create the dao AttributesTableReader tableReader = new AttributesTableReader( contents.getTableName()); AttributesConnection userDb = new AttributesConnection(database); final AttributesTable attributesTable = tableReader.readTable(userDb); attributesTable.setContents(contents); AttributesDao dao = new AttributesDao(getName(), database, userDb, attributesTable); return dao; }
if (!db.tableExists(contents.getTableName())) { throw new GeoPackageException( "No table exists for Content Table Name: " + contents.getTableName() + ". Table must first be created.");
contents.getTableName()); final AttributesTable attributesTable = tableReader.readTable(new AttributesWrapperConnection(database)); attributesTable.setContents(contents);
/** * Validate contents * * @param mediaTable media table * @param contents contents */ private static void validateContents(MediaTable mediaTable, Contents contents) { TestCase.assertNotNull(contents); TestCase.assertNotNull(contents.getDataType()); TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(), contents .getDataType().getName()); TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(), contents.getDataTypeString()); TestCase.assertEquals(mediaTable.getTableName(), contents.getTableName()); TestCase.assertNotNull(contents.getLastChange()); }
/** * Validate contents * * @param simpleAttributesTable simple attributes table * @param contents contents */ private static void validateContents( SimpleAttributesTable simpleAttributesTable, Contents contents) { TestCase.assertNotNull(contents); TestCase.assertNotNull(contents.getDataType()); TestCase.assertEquals( SimpleAttributesTable.RELATION_TYPE.getDataType(), contents .getDataType().getName()); TestCase.assertEquals( SimpleAttributesTable.RELATION_TYPE.getDataType(), contents.getDataTypeString()); TestCase.assertEquals(simpleAttributesTable.getTableName(), contents.getTableName()); TestCase.assertNotNull(contents.getLastChange()); }
dropTable(contents.getTableName()); dropTable(contents.getTableName());
throws SQLException { FeatureTable table = buildFeatureTable(contents.getTableName(), geometryColumn, geometryType); geoPackage.createFeatureTable(table); dataColumns.setContents(contents); dataColumns.setColumnName(TEST_INTEGER_COLUMN); dataColumns.setName(contents.getTableName()); dataColumns.setTitle("TEST_TITLE"); dataColumns.setDescription("TEST_DESCRIPTION");
contents.getTableName(), "geom", GeometryType.GEOMETRY)); TestCase.assertEquals(newCount, dao.getFeatureTables().size()); TestCase.assertTrue(dao.getFeatureTables().contains( contents.getTableName()));
.getTableName())); TestCase.assertEquals(newCount, dao.getTileTables().size()); TestCase.assertTrue(dao.getTileTables().contains( contents.getTableName()));
TileTable tileTable = TestUtils.buildTileTable(contents.getTableName()); geoPackage.createTileTable(tileTable);