Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/MetaDataConstants.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/MetaDataConstants.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/MetaDataConstants.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/MetaDataConstants.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -14,51 +14,67 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.sis.internal.sql.reverse; + /** * Constants defined by JDBC to retrieve a database meta-model. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -public final class MetaDataConstants { +final class MetaDataConstants { - public static final class Schema{ - /** schema name */ + static final class Schema { + /** schema name. */ public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** catalog name (may be null) */ + + /** catalog name (values in this column may be null). */ public static final String TABLE_CATALOG = "TABLE_CATALOG"; - private Schema(){} + private Schema() { + } } - public static final class Table{ - /** table catalog (may be null) */ + static final class Table { + /** Table catalog (values in this column may be null). */ public static final String TABLE_CAT = "TABLE_CAT"; - /** table schema (may be null) */ + + /** Table schema (values in this column may be null). */ + public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** table name */ + + /** Table name. */ public static final String TABLE_NAME = "TABLE_NAME"; - /** table type. Typical types are : <br> + + /** + * Table type. Typical types are: * "TABLE", "VIEW", "SYSTEM TABLE", - * "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". */ + * "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". + */ public static final String TABLE_TYPE = "TABLE_TYPE"; - /** explanatory comment on the table */ + + /** Explanatory comment on the table. */ public static final String REMARKS = "REMARKS"; - /** the types catalog (may be null) */ + + /** The types catalog (values in this column may be null). */ public static final String TYPE_CAT = "TYPE_CAT"; - /** the types schema (may be null) */ + + /** The types schema (values in this column may be null). */ public static final String TYPE_SCHEM = "TYPE_SCHEM"; - /** type name (may be null) */ + + /** Type name (values in this column may be null). */ public static final String TYPE_NAME = "TYPE_NAME"; - /** name of the designated "identifier" column of a typed table (may be null) */ + + /** Name of the designated "identifier" column of a typed table (values in this column may be null). */ public static final String SELF_REFERENCING_COL_NAME = "SELF_REFERENCING_COL_NAME"; - /** specifies how values in SELF_REFERENCING_COL_NAME are created.<br> - * Values are "SYSTEM", "USER", "DERIVED". (may be null) */ + + /** + * Specifies how values in SELF_REFERENCING_COL_NAME are created. + * Values are "SYSTEM", "USER", "DERIVED". values in this column may be null. + */ public static final String REF_GENERATION = "REF_GENERATION"; public static final String VALUE_TYPE_TABLE = "TABLE"; @@ -73,285 +89,427 @@ public final class MetaDataConstants { public static final String VALUE_REFGEN_USER = "USER"; public static final String VALUE_REFGEN_DERIVED = "DERIVED"; - private Table(){} + private Table() { + } } - public static final class SuperTable{ - /** the type's catalog (may be null) */ + public static final class SuperTable { + /** The type's catalog (values in this column may be null). */ public static final String TABLE_CAT = "TABLE_CAT"; - /** type's schema (may be null) */ + + /** Type's schema (values in this column may be null). */ public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** type name */ + + /** Type name. */ public static final String TABLE_NAME = "TABLE_NAME"; - /** the direct super type's name */ + + /** The direct super type's name. */ public static final String SUPERTABLE_NAME = "SUPERTABLE_NAME"; - private SuperTable(){} + private SuperTable() { + } } - public static final class Column{ - - /** table catalog (may be null) */ + public static final class Column { + /** Table catalog (values in this column may be null). */ public static final String TABLE_CAT = "TABLE_CAT"; - /** table schema (may be null) */ + + /** Table schema (values in this column may be null). */ public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** table name */ + + /** Table name. */ public static final String TABLE_NAME = "TABLE_NAME"; - /** column name */ + + /** Column name. */ public static final String COLUMN_NAME = "COLUMN_NAME"; - /** int : SQL type from java.sql.Types */ + + /** SQL type from {@link java.sql.Types}. */ public static final String DATA_TYPE = "DATA_TYPE"; - /** Data source dependent type name, for a UDT the type name is fully qualified */ + + /** Data source dependent type name, for a UDT the type name is fully qualified. */ public static final String TYPE_NAME = "TYPE_NAME"; - /** int : column size. */ + + /** Column size ({@code int} values). */ public static final String COLUMN_SIZE = "COLUMN_SIZE"; - /** not used. */ + + /** Not used. */ public static final String BUFFER_LENGTH = "BUFFER_LENGTH"; - /** int : the number of fractional digits. Null is returned for - * data types where DECIMAL_DIGITS is not applicable. */ + + /** + * The number of fractional digits as {@code int} values. + * Null is returned for data types where DECIMAL_DIGITS is not applicable. + */ public static final String DECIMAL_DIGITS = "DECIMAL_DIGITS"; - /** int : Radix (typically either 10 or 2) */ + + /** Radix (typically either 10 or 2) as {@code int} values. */ public static final String NUM_PREC_RADIX = "NUM_PREC_RADIX"; - /** int : is NULL allowed. <br> - * columnNoNulls - might not allow NULL values <br> - * columnNullable - definitely allows NULL values<br> - * columnNullableUnknown - nullability unknown */ + + /** + * Whether NULL allowed as a {@code int} code. + * <ul> + * <li>{@code columnNoNulls} - might not allow NULL values</li> + * <li>{@code columnNullable} - definitely allows NULL values</li> + * <li>{@code columnNullableUnknown} - nullability unknown</li> + * </ul> + */ public static final String NULLABLE = "NULLABLE"; - /** comment describing column (may be null) */ + + /** Comment describing column (values in this column may be null). */ public static final String REMARKS = "REMARKS"; - /** default value for the column, which should be interpreted as a - * string when the value is enclosed in single quotes (may be null) */ + + /** + * Default value for the column, which should be interpreted as a + * string when the value is enclosed in single quotes (values in this column may be null) + */ public static final String COLUMN_DEF = "COLUMN_DEF"; - /** int : unused */ + + /** Unused {@code int} values. */ public static final String SQL_DATA_TYPE = "SQL_DATA_TYPE"; - /** int : unused */ + + /** Unused {@code int} values. */ public static final String SQL_DATETIME_SUB = "SQL_DATETIME_SUB"; - /** int : for char types the maximum number of bytes in the column */ + + /** Maximum number (as a {@code int}) of bytes in the column of type {@code char}. */ public static final String CHAR_OCTET_LENGTH = "CHAR_OCTET_LENGTH"; - /** int : index of column in table (starting at 1) */ + + /** Index of column in table (starting at 1). */ public static final String ORDINAL_POSITION = "ORDINAL_POSITION"; - /** ISO rules are used to determine the nullability for a column.<br> - * YES --- if the parameter can include NULLs<br> - * NO --- if the parameter cannot include NULLs<br> - * empty string --- if the nullability for the parameter is unknown */ + + /** + * ISO rules are used to determine the nullability for a column. + * YES if the parameter can include NULLs, + * NO if the parameter cannot include NULLs, + * empty string if the nullability for the parameter is unknown. + */ public static final String IS_NULLABLE = "IS_NULLABLE"; - /** catalog of table that is the scope of a reference attribute - * (null if DATA_TYPE isn't REF) */ + + /** + * Catalog of table that is the scope of a reference attribute + * (null if DATA_TYPE isn't REF). + */ public static final String SCOPE_CATLOG = "SCOPE_CATLOG"; - /** schema of table that is the scope of a reference attribute - * (null if the DATA_TYPE isn't REF) */ + + /** + * Schema of table that is the scope of a reference attribute + * (null if the DATA_TYPE isn't REF). + */ public static final String SCOPE_SCHEMA = "SCOPE_SCHEMA"; - /** table name that this the scope of a reference attribute - * (null if the DATA_TYPE isn't REF) */ + + /** + * Table name that this the scope of a reference attribute + * (null if the DATA_TYPE isn't REF). + */ public static final String SCOPE_TABLE = "SCOPE_TABLE"; - /** short : source type of a distinct type or user-generated Ref type, SQL type - * from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF) */ + + /** + * Source type of a distinct type or user-generated Ref type. + * This is a SQL type from {@link java.sql.Types} + * (null if DATA_TYPE isn't DISTINCT or user-generated REF). + */ public static final String SOURCE_DATA_TYPE = "SOURCE_DATA_TYPE"; - /** Indicates whether this column is auto incremented<br> - * YES --- if the column is auto incremented<br> - * NO --- if the column is not auto incremented<br> - * empty string --- if it cannot be determined whether<br> - * the column is auto incremented parameter is unknown + + /** + * Indicates whether this column is auto incremented. + * YES if the column is auto incremented, + * NO if the column is not auto incremented, + * empty string if whether the column is auto incremented is unknown. */ public static final String IS_AUTOINCREMENT = "IS_AUTOINCREMENT"; public static final String VALUE_YES = "YES"; public static final String VALUE_NO = "NO"; - private Column(){} + private Column() { + } } public static final class PrimaryKey{ - /** table catalog (may be null) */ + /** Table catalog (values in this column may be null). */ public static final String TABLE_CAT = "TABLE_CAT"; - /** table schema (may be null) */ + + /** Table schema (values in this column may be null). */ public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** table name */ + + /** Table name. */ public static final String TABLE_NAME = "TABLE_NAME"; - /** column name */ + + /** Column name. */ public static final String COLUMN_NAME = "COLUMN_NAME"; - /** short : sequence number within primary key.<br> - * - a value of 1 represents the first column of the primary key<br> - * - a value of 2 would represent the second column within the primary key */ + + /** + * Sequence number within primary key as a {@code short} code. + * A value of 1 represents the first column of the primary key; + * a value of 2 would represent the second column within the primary key. + */ public static final String KEY_SEQ = "KEY_SEQ"; - /** primary key name (may be null) */ + + /** Primary key name (values in this column may be null). */ public static final String PK_NAME = "PK_NAME"; - private PrimaryKey(){} + private PrimaryKey() { + } } public static final class ImportedKey{ - /** primary key table catalog being imported (may be null) */ + /** Primary key table catalog being imported (values in this column may be null). */ public static final String PKTABLE_CAT = "PKTABLE_CAT"; - /** primary key table schema being imported (may be null) */ + + /** Primary key table schema being imported (values in this column may be null). */ public static final String PKTABLE_SCHEM = "PKTABLE_SCHEM"; - /** primary key table name being imported */ + + /** Primary key table name being imported. */ public static final String PKTABLE_NAME = "PKTABLE_NAME"; - /** primary key column name being imported */ + + /** Primary key column name being imported. */ public static final String PKCOLUMN_NAME = "PKCOLUMN_NAME"; - /** foreign key table catalog (may be null) */ + + /** Foreign key table catalog (may be null). */ public static final String FKTABLE_CAT = "FKTABLE_CAT"; - /** foreign key table schema (may be null) */ + + /** Foreign key table schema (may be null). */ public static final String FKTABLE_SCHEM = "FKTABLE_SCHEM"; - /** foreign key table name */ + + /** Foreign key table name. */ public static final String FKTABLE_NAME = "FKTABLE_NAME"; - /** foreign key column name */ + + /** Foreign key column name. */ public static final String FKCOLUMN_NAME = "FKCOLUMN_NAME"; - /** short : sequence number within a foreign key <br> - * - a value of 1 represents the first column of the foreign key<br> - * - a value of 2 would represent the second column within the foreign key */ + + /** + * Sequence number within a foreign key as a {@code short} code. + * A value of 1 represents the first column of the foreign key; + * a value of 2 would represent the second column within the foreign key. + */ public static final String KEY_SEQ = "KEY_SEQ"; - /** short : What happens to a foreign key when the primary key is updated:<br> - * importedNoAction - do not allow update of primary key if it has been imported<br> - * importedKeyCascade - change imported key to agree with primary key update<br> - * importedKeySetNull - change imported key to NULL if its primary key has been updated<br> - * importedKeySetDefault - change imported key to default values if its primary key has been updated<br> - * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) */ + + /** + * What happens to a foreign key when the primary key is updated, as a {@code short} code. + * <ul> + * <li>{@code importedNoAction} - do not allow update of primary key if it has been imported</li> + * <li>{@code importedKeyCascade} - change imported key to agree with primary key update</li> + * <li>{@code importedKeySetNull} - change imported key to NULL if its primary key has been updated</li> + * <li>{@code importedKeySetDefault} - change imported key to default values if its primary key has been updated</li> + * <li>{@code importedKeyRestrict} - same as importedKeyNoAction (for ODBC 2.x compatibility).</li> + * </ul> + */ public static final String UPDATE_RULE = "UPDATE_RULE"; - /** short : What happens to the foreign key when primary is deleted.<br> - * importedKeyNoAction - do not allow delete of primary key if it has been imported<br> - * importedKeyCascade - delete rows that import a deleted key<br> - * importedKeySetNull - change imported key to NULL if its primary key has been deleted<br> - * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)<br> - * importedKeySetDefault - change imported key to default if its primary key has been deleted */ + + /** + * What happens to the foreign key when primary is deleted, as a {@code short} code. + * <ul> + * <li>{@code importedKeyNoAction} - do not allow delete of primary key if it has been imported</li> + * <li>{@code importedKeyCascade} - delete rows that import a deleted key</li> + * <li>{@code importedKeySetNull} - change imported key to NULL if its primary key has been deleted</li> + * <li>{@code importedKeyRestrict} - same as importedKeyNoAction (for ODBC 2.x compatibility)</li> + * <li>{@code importedKeySetDefault} - change imported key to default if its primary key has been deleted.</li> + * </ul> + */ public static final String DELETE_RULE = "DELETE_RULE"; - /** foreign key name (may be null) */ + + /** Foreign key name (values in this column may be null). */ public static final String FK_NAME = "FK_NAME"; - /** primary key name (may be null) */ + + /** Primary key name (values in this column may be null). */ public static final String PK_NAME = "PK_NAME"; - /** short : can the evaluation of foreign key constraints be deferred until commit<br> - * importedKeyInitiallyDeferred - see SQL92 for definition<br> - * importedKeyInitiallyImmediate - see SQL92 for definition<br> - * importedKeyNotDeferrable - see SQL92 for definition */ + + /** + * Whether the evaluation of foreign key constraints can be deferred until commit (as a {@code short} code). + * <ul> + * <li>{@code importedKeyInitiallyDeferred} - see SQL92 for definition</li> + * <li>{@code importedKeyInitiallyImmediate} - see SQL92 for definition</li> + * <li>{@code importedKeyNotDeferrable} - see SQL92 for definition</li> + * </ul> + */ public static final String DEFERRABILITY = "DEFERRABILITY"; - private ImportedKey(){} + private ImportedKey() { + } } public static final class ExportedKey{ - /** primary key table catalog (may be null) */ + /** Primary key table catalog (values in this column may be null). */ public static final String PKTABLE_CAT = "PKTABLE_CAT"; - /** primary key table schema (may be null) */ + + /** Primary key table schema (values in this column may be null). */ public static final String PKTABLE_SCHEM = "PKTABLE_SCHEM"; - /** primary key table name */ + + /** Primary key table name. */ public static final String PKTABLE_NAME = "PKTABLE_NAME"; - /** primary key column name */ + + /** Primary key column name. */ public static final String PKCOLUMN_NAME = "PKCOLUMN_NAME"; - /** foreign key table catalog (may be null) being exported (may be null) */ + + /** Foreign key table catalog (may be null) being exported (values in this column may be null). */ public static final String FKTABLE_CAT = "FKTABLE_CAT"; - /** foreign key table schema (may be null) being exported (may be null) */ + + /** Foreign key table schema (may be null) being exported (values in this column may be null). */ public static final String FKTABLE_SCHEM = "FKTABLE_SCHEM"; - /** foreign key table name being exported */ + + /** Foreign key table name being exported. */ public static final String FKTABLE_NAME = "FKTABLE_NAME"; - /** foreign key column name being exported */ + + /** Foreign key column name being exported. */ public static final String FKCOLUMN_NAME = "FKCOLUMN_NAME"; - /** short : sequence number within foreign key :<br> - * a value of 1 represents the first column of the foreign key<br> - * a value of 2 would represent the second column within the foreign key */ + + /** + * Sequence number within foreign key as a {@code short} code. + * a value of 1 represents the first column of the foreign key; + * a value of 2 would represent the second column within the foreign key. + */ public static final String KEY_SEQ = "KEY_SEQ"; - /** short : What happens to foreign key when primary is updated:<br> - * importedNoAction - do not allow update of primary key if it has been imported<br> - * importedKeyCascade - change imported key to agree with primary key update<br> - * importedKeySetNull - change imported key to NULL if its primary key has been updated<br> - * importedKeySetDefault - change imported key to default values if its primary key has been updated<br> - * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility) */ + + /** + * What happens to foreign key when primary is updated, as a {@code short} code. + * <ul> + * <li>{@code importedNoAction} - do not allow update of primary key if it has been imported</li> + * <li>{@code importedKeyCascade} - change imported key to agree with primary key update</li> + * <li>{@code importedKeySetNull} - change imported key to NULL if its primary key has been updated</li> + * <li>{@code importedKeySetDefault} - change imported key to default values if its primary key has been updated</li> + * <li>{@code importedKeyRestrict} - same as importedKeyNoAction (for ODBC 2.x compatibility)</li> + * </ul> + */ public static final String UPDATE_RULE = "UPDATE_RULE"; - /** short : What happens to the foreign key when primary is deleted. <br> - * importedKeyNoAction - do not allow delete of primary key if it has been imported<br> - * importedKeyCascade - delete rows that import a deleted key<br> - * importedKeySetNull - change imported key to NULL if its primary key has been deleted<br> - * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)<br> - * importedKeySetDefault - change imported key to default if its primary key has been deleted */ + + /** + * What happens to the foreign key when primary is deleted, as a {@code short} code. + * <ul> + * <li>{@code importedKeyNoAction} - do not allow delete of primary key if it has been imported</li> + * <li>{@code importedKeyCascade} - delete rows that import a deleted key</li> + * <li>{@code importedKeySetNull} - change imported key to NULL if its primary key has been deleted</li> + * <li>{@code importedKeyRestrict} - same as importedKeyNoAction (for ODBC 2.x compatibility)</li> + * <li>{@code importedKeySetDefault} - change imported key to default if its primary key has been deleted</li> + * </ul> + */ public static final String DELETE_RULE = "DELETE_RULE"; - /** foreign key name (may be null) */ + + /** Foreign key name (values in this column may be null). */ public static final String FK_NAME = "FK_NAME"; - /** primary key name (may be null) */ + + /** Primary key name (values in this column may be null). */ public static final String PK_NAME = "PK_NAME"; - /** short : can the evaluation of foreign key constraints be deferred until commit<br> - * importedKeyInitiallyDeferred - see SQL92 for definition<br> - * importedKeyInitiallyImmediate - see SQL92 for definition<br> - * importedKeyNotDeferrable - see SQL92 for definition */ + + /** + * Whether the evaluation of foreign key constraints can be deferred until commit, as a {@code short} code. + * <ul> + * <li>{@code importedKeyInitiallyDeferred} - see SQL92 for definition</li> + * <li>{@code importedKeyInitiallyImmediate} - see SQL92 for definition</li> + * <li>{@code importedKeyNotDeferrable} - see SQL92 for definition</li> + * </ul> + */ public static final String DEFERRABILITY = "DEFERRABILITY"; - private ExportedKey(){} + private ExportedKey() { + } } public static final class BestRow{ - - /** short => actual scope of result + /** + * Actual scope of result as a {@code short} code. * bestRowTemporary - very temporary, while using row * bestRowTransaction - valid for remainder of current transaction - * bestRowSession - valid for remainder of current session */ + * bestRowSession - valid for remainder of current session. + */ public static final String SCOPE = "SCOPE"; - /** String => column name */ + + /** Column name. */ public static final String COLUMN_NAME = "COLUMN_NAME"; - /** int => SQL data type from java.sql.Types */ + + /** SQL data type from {@link java.sql.Types}. */ public static final String DATA_TYPE = "DATA_TYPE"; - /** String => Data source dependent type name, - * for a UDT the type name is fully qualified */ + + /** Data source dependent type name. For a UDT the type name is fully qualified. */ public static final String TYPE_NAME = "TYPE_NAME"; - /** int => precision */ + + /** Precision as an {@code int}. */ public static final String COLUMN_SIZE = "COLUMN_SIZE"; - /** int => not used */ + + /** Not used. */ public static final String BUFFER_LENGTH = "BUFFER_LENGTH"; - /** short => scale - Null is returned for data types where DECIMAL_DIGITS is not applicable. */ + + /** Scale - Null is returned for data types where DECIMAL_DIGITS is not applicable. */ public static final String DECIMAL_DIGITS = "DECIMAL_DIGITS"; - /** short => is this a pseudo column like an Oracle ROWID - bestRowUnknown - may or may not be pseudo column - bestRowNotPseudo - is NOT a pseudo column - bestRowPseudo - is a pseudo column */ + + /** + * Whether this a pseudo column like an Oracle ROWID, as a {@code short} code. + * bestRowUnknown - may or may not be pseudo column + * bestRowNotPseudo - is NOT a pseudo column + * bestRowPseudo - is a pseudo column. + */ public static final String PSEUDO_COLUMN = "PSEUDO_COLUMN"; - private BestRow(){} + private BestRow() { + } } - public static final class Index{ - - /** String => table catalog (may be null) */ + public static final class Index { + /** Table catalog (values in this column may be null). */ public static final String TABLE_CAT = "TABLE_CAT"; - /** String => table schema (may be null) */ + + /** Table schema (values in this column may be null). */ public static final String TABLE_SCHEM = "TABLE_SCHEM"; - /** String => table name */ + + /** Table name. */ public static final String TABLE_NAME = "TABLE_NAME"; - /** boolean => Can index values be non-unique. + + /** Whether index values can be non-unique. * false when TYPE is tableIndexStatistic */ public static final String NON_UNIQUE = "NON_UNIQUE"; - /** String => index catalog (may be null); - * null when TYPE is tableIndexStatistic */ + + /** + * Index catalog (values in this column may be null). + * Values are null when TYPE is tableIndexStatistic. + */ public static final String INDEX_QUALIFIER = "INDEX_QUALIFIER"; - /** String => index name; - * null when TYPE is tableIndexStatistic */ + + /** Index name; null when TYPE is tableIndexStatistic. */ public static final String INDEX_NAME = "INDEX_NAME"; - /** short => index type: + + /** + * Index type as a {@code short} code. * tableIndexStatistic - this identifies table statistics that are * returned in conjuction with a table's index descriptions * tableIndexClustered - this is a clustered index * tableIndexHashed - this is a hashed index - * tableIndexOther - this is some other style of index */ + * tableIndexOther - this is some other style of index. + */ public static final String TYPE = "TYPE"; - /** short => column sequence number within index; - * zero when TYPE is tableIndexStatistic */ + + /** + * Column sequence number within index as a {@code short}. + * Zero when TYPE is tableIndexStatistic. + */ public static final String ORDINAL_POSITION = "ORDINAL_POSITION"; - /** String => column name; - * null when TYPE is tableIndexStatistic */ + + /** Column name. Values are null when TYPE is tableIndexStatistic. */ public static final String COLUMN_NAME = "COLUMN_NAME"; - /** String => column sort sequence, - * "A" => ascending, - * "D" => descending, may be null if sort sequence is not supported; - * null when TYPE is tableIndexStatistic */ + + /** + * Column sort sequence. + * "A" for ascending, + * "D" for descending, may be null if sort sequence is not supported; + * null when TYPE is tableIndexStatistic. + */ public static final String ASC_OR_DESC = "ASC_OR_DESC"; - /** int => When TYPE is tableIndexStatistic, then this is the number of rows in the table; - * otherwise, it is the number of unique values in the index. */ + + /** + * When TYPE is tableIndexStatistic, then this is the number of rows in the table as an {@code int}. + * Otherwise, it is the number of unique values in the index. + */ public static final String CARDINALITY = "CARDINALITY"; - /** int => When TYPE is tableIndexStatisic then this is the number of pages used for the table, - * otherwise it is the number of pages used for the current index. */ + + /** + * When TYPE is tableIndexStatisic then this is the number of pages used for the table as an {@code int}. + * Otherwise it is the number of pages used for the current index. + */ public static final String PAGES = "PAGES"; - /** String => Filter condition, if any. (may be null) */ + + /** Filter condition, if any. Values in this column may be null. */ public static final String FILTER_CONDITION = "FILTER_CONDITION"; - private Index(){} + private Index() { + } } - private MetaDataConstants(){} - + private MetaDataConstants() { + } }
Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/PrimaryKey.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/PrimaryKey.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/PrimaryKey.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/PrimaryKey.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -22,73 +22,61 @@ import java.sql.SQLException; import java.util.Collections; import java.util.List; import java.util.UUID; -import java.util.logging.Logger; -import org.apache.sis.sql.dialect.SQLDialect; +import org.apache.sis.internal.sql.Dialect; import org.apache.sis.storage.DataStoreException; + /** - * Describe a table primary key. + * Description of a table primary key. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -public class PrimaryKey { - - private final String tableName; - private final List<ColumnMetaModel> columns; +final class PrimaryKey { - public PrimaryKey(String tableName) { - this(tableName,null); - } + final String table; + final List<ColumnMetaModel> columns; - public PrimaryKey(String tableName, List<ColumnMetaModel> columns) { - this.tableName = tableName; - if (columns == null) columns = Collections.emptyList(); + PrimaryKey(final String table, List<ColumnMetaModel> columns) { + this.table = table; + if (columns == null) { + columns = Collections.emptyList(); + } this.columns = columns; } - public String getTableName() { - return tableName; - } - - public List<ColumnMetaModel> getColumns() { - return columns; - } - - public boolean isNull(){ - return columns.isEmpty(); - } - /** - * Create a feature identifier from primary key column values. + * Creates a feature identifier from primary key column values. + * This method uses only the current row of the given result set. * - * @param rs ResultSet on a row - * @return feature identifier - * @throws SQLException + * @param rs the result set positioned on a row. + * @return the feature identifier for current row of the given result set. */ - public String buildIdentifier(final ResultSet rs) throws SQLException { - + String buildIdentifier(final ResultSet rs) throws SQLException { final int size = columns.size(); - - if (size == 0) { - // no primary key columns, generate a random id - return UUID.randomUUID().toString(); - } else if (size == 1) { - // unique column value - return rs.getString(columns.get(0).getName()); - } else { - // aggregate column values - final Object[] values = new Object[size]; - for (int i=0; i<size; i++) { - values[i] = rs.getString(columns.get(i).getName()); + switch (size) { + case 0: { + // No primary key columns, generate a random id + return UUID.randomUUID().toString(); + } + case 1: { + // Unique column value + return rs.getString(columns.get(0).name); + } + default: { + // Aggregate column values + final Object[] values = new Object[size]; + for (int i=0; i<size; i++) { + values[i] = rs.getString(columns.get(i).name); + } + return buildIdentifier(values); } - return buildIdentifier(values); } } - public static String buildIdentifier(final Object[] values) { + private static String buildIdentifier(final Object[] values) { final StringBuilder sb = new StringBuilder(); for (int i=0; i<values.length; i++) { if (i > 0) sb.append('.'); @@ -98,22 +86,19 @@ public class PrimaryKey { } /** - * Create primary key column field values. + * Creates the field values for all columns of a the primary key. * - * @param dialect database dialect - * @param logger database logger - * @param cx database connection - * @return primary key values - * @throws SQLException - * @throws DataStoreException + * @param dialect handler for syntax elements specific to the database. + * @param cx connection to the database. + * @return primary key values. + * @throws SQLException if a JDBC error occurred while executing a statement. + * @throws DataStoreException if another error occurred while fetching the next value. */ - public Object[] nextValues(final SQLDialect dialect, Logger logger, final Connection cx) - throws SQLException, DataStoreException { + Object[] nextValues(final Dialect dialect, final Connection cx) throws SQLException, DataStoreException { final Object[] parts = new Object[columns.size()]; for (int i=0; i<parts.length; i++) { - parts[i] = columns.get(i).nextValue(dialect, logger, cx); + parts[i] = columns.get(i).nextValue(dialect, cx); } return parts; } - } Copied: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/QueryFeatureSet.java (from r1829659, sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQueryFeatureSet.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/QueryFeatureSet.java?p2=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/QueryFeatureSet.java&p1=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQueryFeatureSet.java&r1=1829659&r2=1829660&rev=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQueryFeatureSet.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/QueryFeatureSet.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -14,13 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.sql; +package org.apache.sis.internal.sql.reverse; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.stream.Stream; +import org.apache.sis.sql.SQLQuery; +import org.apache.sis.sql.SQLStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.event.ChangeEvent; @@ -30,22 +32,25 @@ import org.opengis.feature.FeatureType; import org.opengis.geometry.Envelope; import org.opengis.metadata.Metadata; + /** * A FeatureSet above a custom SQL query. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -final class SQLQueryFeatureSet implements FeatureSet { +public final class QueryFeatureSet implements FeatureSet { - private final AbstractSQLStore store; + private final DataBaseModel model; + private final SQLStore store; private final SQLQuery query; private FeatureType type; - public SQLQueryFeatureSet(AbstractSQLStore store, SQLQuery query) { + public QueryFeatureSet(final SQLStore store, final DataBaseModel model, final SQLQuery query) { this.store = store; + this.model = model; this.query = query; } @@ -56,7 +61,7 @@ final class SQLQueryFeatureSet implement try (Connection cnx = store.getDataSource().getConnection(); Statement stmt = cnx.createStatement(); ResultSet rs = stmt.executeQuery(sql)) { - type = store.getDatabaseModel().analyzeResult(rs, query.getName()); + type = model.analyzeResult(rs, query.getName()); } catch (SQLException ex) { throw new DataStoreException(ex); } @@ -86,5 +91,4 @@ final class SQLQueryFeatureSet implement @Override public <T extends ChangeEvent> void removeListener(ChangeListener<? super T> listener, Class<T> eventType) { } - } Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/RelationMetaModel.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/RelationMetaModel.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/RelationMetaModel.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/RelationMetaModel.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -18,6 +18,7 @@ package org.apache.sis.internal.sql.reve import org.apache.sis.util.ArgumentChecks; + /** * Description of a relation between two tables. * @@ -26,73 +27,39 @@ import org.apache.sis.util.ArgumentCheck * @since 1.0 * @module */ -public class RelationMetaModel { +final class RelationMetaModel { - private final String relationName; - private final String currentColumn; - private final String foreignSchema; - private final String foreignTable; - private final String foreignColumn; - private final boolean imported; - private final boolean deleteCascade; + final String relationName; + final String currentColumn; + final String foreignSchema; + final String foreignTable; + final String foreignColumn; + final boolean isImported; + final boolean cascadeOnDelete; - public RelationMetaModel(final String relationName,final String currentColumn, final String foreignSchema, + RelationMetaModel(final String relationName, final String currentColumn, final String foreignSchema, final String foreignTable, final String foreignColumn, - boolean imported, boolean deleteCascade) { - ArgumentChecks.ensureNonNull("relation name", relationName); - ArgumentChecks.ensureNonNull("current column", currentColumn); - ArgumentChecks.ensureNonNull("foreign table", foreignTable); - ArgumentChecks.ensureNonNull("foreign column", foreignColumn); - this.relationName = relationName; - this.currentColumn = currentColumn; - this.foreignSchema = foreignSchema; - this.foreignTable = foreignTable; - this.foreignColumn = foreignColumn; - this.imported = imported; - this.deleteCascade = deleteCascade; - } - - public String getRelationName() { - return relationName; - } - - public String getCurrentColumn() { - return currentColumn; - } - - public String getForeignColumn() { - return foreignColumn; - } - - public String getForeignSchema() { - return foreignSchema; - } - - public String getForeignTable() { - return foreignTable; - } - - /** - * Indicate if this key is imported. - * @return - */ - public boolean isImported() { - return imported; - } - - /** - * @return true if relation implies a delete on cascade. - */ - public boolean isDeleteCascade(){ - return deleteCascade; + final boolean isImported, final boolean cascadeOnDelete) + { + ArgumentChecks.ensureNonNull("relationName", relationName); + ArgumentChecks.ensureNonNull("currentColumn", currentColumn); + ArgumentChecks.ensureNonNull("foreignTable", foreignTable); + ArgumentChecks.ensureNonNull("foreignColumn", foreignColumn); + this.relationName = relationName; + this.currentColumn = currentColumn; + this.foreignSchema = foreignSchema; + this.foreignTable = foreignTable; + this.foreignColumn = foreignColumn; + this.isImported = isImported; + this.cascadeOnDelete = cascadeOnDelete; } @Override public String toString() { - final StringBuilder sb = new StringBuilder(currentColumn); - sb.append((imported) ? " → " : " ← "); - sb.append(foreignSchema).append('.'); - sb.append(foreignTable).append('.').append(foreignColumn); - return sb.toString(); + return new StringBuilder(currentColumn) + .append((isImported) ? " → " : " ← ") + .append(foreignSchema).append('.') + .append(foreignTable).append('.').append(foreignColumn) + .toString(); } } Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/SchemaMetaModel.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/SchemaMetaModel.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/SchemaMetaModel.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/SchemaMetaModel.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.sis.internal.sql.SQLUtilities; + /** * Description of a database schema. * @@ -29,29 +30,27 @@ import org.apache.sis.internal.sql.SQLUt * @since 1.0 * @module */ -public class SchemaMetaModel { +final class SchemaMetaModel { final String name; - final Map<String, TableMetaModel> tables = new HashMap<String, TableMetaModel>(); - public SchemaMetaModel(final String name) { - this.name = name; - } + final Map<String,TableMetaModel> tables; - public String getName() { - return name; + SchemaMetaModel(final String name) { + this.name = name; + tables = new HashMap<>(); } - public Collection<TableMetaModel> getTables() { + Collection<TableMetaModel> getTables() { return tables.values(); } - public TableMetaModel getTable(final String name){ + TableMetaModel getTable(final String name){ return tables.get(name); } @Override public String toString() { - return SQLUtilities.toStringTree(name, tables.values()); + return SQLUtilities.toTreeString(name, getTables()); } } Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/TableMetaModel.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/TableMetaModel.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/TableMetaModel.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/TableMetaModel.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -18,10 +18,10 @@ package org.apache.sis.internal.sql.reve import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import org.apache.sis.feature.builder.FeatureTypeBuilder; import org.apache.sis.internal.sql.SQLUtilities; + /** * Description of a database table. * @@ -30,13 +30,13 @@ import org.apache.sis.internal.sql.SQLUt * @since 1.0 * @module */ -public class TableMetaModel { +final class TableMetaModel { - public enum View { + enum View { TABLE, SIMPLE_FEATURE_TYPE, COMPLEX_FEATURE_TYPE, - ALLCOMPLEX + ALL_COMPLEX } String name; @@ -45,53 +45,44 @@ public class TableMetaModel { FeatureTypeBuilder tableType; FeatureTypeBuilder simpleFeatureType; FeatureTypeBuilder complexFeatureType; - FeatureTypeBuilder allType; + FeatureTypeBuilder allTypes; PrimaryKey key; + /** * those are 0:1 relations */ final Collection<RelationMetaModel> importedKeys = new ArrayList<>(); + /** * those are 0:N relations */ final Collection<RelationMetaModel> exportedKeys = new ArrayList<>(); + /** * inherited tables */ final Collection<String> parents = new ArrayList<>(); - public TableMetaModel(final String name, String type) { + TableMetaModel(final String name, String type) { this.name = name; this.type = type; } - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public Collection<RelationMetaModel> getExportedKeys() { - return Collections.unmodifiableCollection(exportedKeys); - } - - public Collection<RelationMetaModel> getImportedKeys() { - return Collections.unmodifiableCollection(importedKeys); - } - /** - * Detect if given type is a subtype. Conditions are : - * - having a relation toward another type - * - relation must be cascading + * Determines if given type is a subtype. Conditions are: + * <ul> + * <li>having a relation toward another type</li> + * <li>relation must be cascading.</li> + * </ul> + * + * @return true is type is a subtype. * - * @return true is type is a subtype + * @todo a subtype of what? */ - public boolean isSubType(){ - for (RelationMetaModel relation : getImportedKeys()) { - if (relation.isDeleteCascade()) { + boolean isSubType() { + for (RelationMetaModel relation : importedKeys) { + if (relation.cascadeOnDelete) { return true; } } @@ -102,22 +93,22 @@ public class TableMetaModel { public String toString() { final StringBuilder sb = new StringBuilder(name); if (!importedKeys.isEmpty()) { - sb.append(SQLUtilities.toStringTree("\n Imported Keys", importedKeys)).append('\n'); + // TODO: use system line separator. + sb.append(SQLUtilities.toTreeString("\n Imported Keys", importedKeys)).append('\n'); } if (!exportedKeys.isEmpty()) { - sb.append(SQLUtilities.toStringTree("\n Exported Keys", exportedKeys)).append('\n'); + sb.append(SQLUtilities.toTreeString("\n Exported Keys", exportedKeys)).append('\n'); } return sb.toString(); } - public FeatureTypeBuilder getType(View view) { + FeatureTypeBuilder getType(final View view) { switch (view) { case TABLE: return tableType; case SIMPLE_FEATURE_TYPE: return simpleFeatureType; case COMPLEX_FEATURE_TYPE: return complexFeatureType; - case ALLCOMPLEX: return allType; - default: throw new IllegalArgumentException("Unknowned view type : "+view); + case ALL_COMPLEX: return allTypes; + default: throw new IllegalArgumentException("Unknown view type: " + view); } } - } Added: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java?rev=1829660&view=auto ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java (added) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * Inspect a database schema. + * + * <STRONG>Do not use!</STRONG> + * + * This package is for internal use by SIS only. Classes in this package + * may change in incompatible ways in any future version without notice. + * + * @author Johann Sorel (Geomatys) + * @version 1.0 + * @since 1.0 + * @module + */ +package org.apache.sis.internal.sql.reverse; Propchange: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/internal/sql/reverse/package-info.java ------------------------------------------------------------------------------ svn:mime-type = text/plain;charset=UTF-8 Copied: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStore.java (from r1829659, sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLStore.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStore.java?p2=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStore.java&p1=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLStore.java&r1=1829659&r2=1829660&rev=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLStore.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStore.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -17,40 +17,54 @@ package org.apache.sis.sql; import javax.sql.DataSource; -import org.apache.sis.internal.sql.reverse.DataBaseModel; -import org.apache.sis.sql.dialect.SQLDialect; import org.apache.sis.storage.DataStore; +import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.FeatureSet; +import org.apache.sis.storage.StorageConnector; + /** - * Parent store class for DataStore implementation using java JDBC backend. + * Parent store class for {@code DataStore} implementations using JDBC backend. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -public abstract class AbstractSQLStore extends DataStore { +public abstract class SQLStore extends DataStore { + /** + * The data source to use for obtaining connections to the database. + */ + private final DataSource source; /** - * Returns the dialect configuration used by this store. + * Creates a new instance for the given storage. + * The {@code provider} argument is an optional information. + * The {@code connector} argument is mandatory. * - * @return dialect used by the store, never null + * @param provider the factory that created this {@code DataStore} instance, or {@code null} if unspecified. + * @param connector information about the storage (JDBC data source, <i>etc</i>). + * @throws DataStoreException if an error occurred while creating the data store for the given storage. */ - public abstract SQLDialect getDialect(); - - public abstract DataSource getDataSource(); - - public abstract DataBaseModel getDatabaseModel(); + protected SQLStore(final SQLStoreProvider provider, final StorageConnector connector) throws DataStoreException { + super(provider, connector); + source = connector.getStorageAs(DataSource.class); + } /** - * Execute a query directly on the database. + * Returns the data source used for obtaining connections to the database. * - * @param query , not null - * @return resulting features from given query. + * @return the data source for obtaining connections to the database. */ - public FeatureSet query(SQLQuery query) { - return new SQLQueryFeatureSet(this, query); + public DataSource getDataSource() { + return source; } + /** + * Executes a query directly on the database. + * + * @param query the query to execute (can not be null). + * @return the features obtained by the given given query. + */ + public abstract FeatureSet query(SQLQuery query); } Copied: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStoreProvider.java (from r1829659, sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLProvider.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStoreProvider.java?p2=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStoreProvider.java&p1=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLProvider.java&r1=1829659&r2=1829660&rev=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/AbstractSQLProvider.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLStoreProvider.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -16,13 +16,21 @@ */ package org.apache.sis.sql; +import org.apache.sis.storage.DataStoreProvider; + + /** + * Provider of {@code SQLStore} instances. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -public interface AbstractSQLProvider { - +public abstract class SQLStoreProvider extends DataStoreProvider { + /** + * Creates a new provider. + */ + protected SQLStoreProvider() { + } } Added: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java?rev=1829660&view=auto ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java (added) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * Data stores that create features from a JDBC connection to a database. + * + * @author Johann Sorel (Geomatys) + * @version 1.0 + * @since 1.0 + * @module + */ +package org.apache.sis.sql; Propchange: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/package-info.java ------------------------------------------------------------------------------ svn:mime-type = text/plain;charset=UTF-8 Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresDialect.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresDialect.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresDialect.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresDialect.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -22,86 +22,86 @@ import java.sql.SQLException; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.internal.sql.SingleAttributeTypeBuilder; import org.apache.sis.internal.sql.reverse.ColumnMetaModel; -import org.apache.sis.sql.dialect.SQLDialect; import org.apache.sis.storage.DataStoreException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.apache.sis.internal.sql.Dialect; + /** + * Implements PostgreSQL-specific functionalities. * * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -class PostgresDialect implements SQLDialect { +final class PostgresDialect extends Dialect { - private static final Set<String> IGNORE_TABLES = new HashSet<>(); + private static final Set<String> IGNORE_TABLES = new HashSet<>(8); static { - //postgis 1+ geometry and referencing + // Postgis 1+ geometry and referencing IGNORE_TABLES.add("spatial_ref_sys"); IGNORE_TABLES.add("geometry_columns"); IGNORE_TABLES.add("geography_columns"); - //postgis 2 raster + // Postgis 2 raster IGNORE_TABLES.add("raster_columns"); IGNORE_TABLES.add("raster_overviews"); } - @Override public boolean supportGlobalMetadata() { return true; } @Override - public boolean ignoreTable(String name) { + public boolean isTableIgnored(String name) { return IGNORE_TABLES.contains(name.toLowerCase()); } @Override public Class<?> getJavaType(int sqlType, String sqlTypeName) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public void encodeColumnName(StringBuilder sql, String name) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public void encodeSchemaAndTableName(StringBuilder sql, String databaseSchema, String tableName) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public Object nextValue(ColumnMetaModel column, Connection cx) throws SQLException, DataStoreException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getColumnSequence(Connection cx, String schemaName, String tableName, String columnName) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public void decodeColumnType(SingleAttributeTypeBuilder atb, Connection cx, String typeName, int datatype, String schemaName, String tableName, String columnName) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public void decodeGeometryColumnType(SingleAttributeTypeBuilder atb, Connection cx, ResultSet rs, int columnIndex, boolean customquery) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public Integer getGeometrySRID(String schemaName, String tableName, String columnName, Map<String, Object> metas, Connection cx) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public CoordinateReferenceSystem createCRS(int srid, Connection cx) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } - } Modified: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStore.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStore.java?rev=1829660&r1=1829659&r2=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStore.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStore.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -16,57 +16,42 @@ */ package org.apache.sis.sql.postgres; -import java.util.logging.Logger; -import javax.sql.DataSource; -import org.apache.sis.internal.sql.reverse.DataBaseModel; -import org.apache.sis.sql.AbstractSQLStore; -import org.apache.sis.sql.dialect.SQLDialect; +import org.opengis.metadata.Metadata; +import org.opengis.parameter.ParameterValueGroup; +import org.apache.sis.sql.SQLStore; +import org.apache.sis.sql.SQLQuery; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.event.ChangeEvent; import org.apache.sis.storage.event.ChangeListener; -import org.apache.sis.util.logging.Logging; -import org.opengis.metadata.Metadata; -import org.opengis.parameter.ParameterValueGroup; +import org.apache.sis.internal.sql.reverse.DataBaseModel; +import org.apache.sis.internal.sql.reverse.QueryFeatureSet; +import org.apache.sis.storage.FeatureSet; +import org.apache.sis.storage.StorageConnector; + /** + * A data store backed by a PostgreSQL database. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -class PostgresStore extends AbstractSQLStore { - - private static final Logger LOGGER = Logging.getLogger("org.apache.sis.sql"); - +final class PostgresStore extends SQLStore { private final PostgresDialect dialect = new PostgresDialect(); - private final DataSource source; private final String schema; private final String table; private final DataBaseModel model; - public PostgresStore(DataSource source, String schema, String table) { - this.source = source; + public PostgresStore(final PostgresStoreProvider provider, final StorageConnector connector, + final String schema, final String table) throws DataStoreException + { + super(provider, connector); this.schema = schema; - this.table = table; - this.model = new DataBaseModel(this, LOGGER, schema, table); - } - - @Override - public SQLDialect getDialect() { - return dialect; - } - - @Override - public DataSource getDataSource() { - return source; - } - - @Override - public DataBaseModel getDatabaseModel() { - return model; + this.table = table; + this.model = new DataBaseModel(this, dialect, schema, table, listeners); } @Override @@ -79,6 +64,16 @@ class PostgresStore extends AbstractSQLS throw new UnsupportedOperationException("Not supported yet."); } + /** + * Executes a query directly on the database. + * + * @param query the query to execute (can not be null). + * @return the features obtained by the given given query. + */ + public FeatureSet query(SQLQuery query) { + return new QueryFeatureSet(this, model, query); + } + @Override public void close() throws DataStoreException { } @@ -90,5 +85,4 @@ class PostgresStore extends AbstractSQLS @Override public <T extends ChangeEvent> void removeListener(ChangeListener<? super T> listener, Class<T> eventType) { } - } Copied: sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStoreProvider.java (from r1829659, sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresProvider.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStoreProvider.java?p2=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStoreProvider.java&p1=sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresProvider.java&r1=1829659&r2=1829660&rev=1829660&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresProvider.java [UTF-8] (original) +++ sis/branches/JDK8/storage/sis-sql/src/main/java/org/apache/sis/sql/postgres/PostgresStoreProvider.java [UTF-8] Fri Apr 20 14:50:37 2018 @@ -16,24 +16,42 @@ */ package org.apache.sis.sql.postgres; +import org.apache.sis.sql.SQLStoreProvider; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; -import org.apache.sis.storage.DataStoreProvider; import org.apache.sis.storage.ProbeResult; import org.apache.sis.storage.StorageConnector; import org.opengis.parameter.ParameterDescriptorGroup; + /** + * The provider of {@link PostgresStore}. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module + * + * @todo We should not have specialized data store provider for PostgreSQL. + * Instead we should detect from the data source or the connection. */ -public class PostgresProvider extends DataStoreProvider { - - public static final String NAME = "postgres"; +final class PostgresStoreProvider extends SQLStoreProvider { + /** + * Name of the data store. + */ + private static final String NAME = "PostgreSQL"; + + /** + * Creates a new provider. + */ + public PostgresStoreProvider() { + } + /** + * Returns a short name for the data store, which is {@value #NAME}. + * + * @return {@value #NAME}. + */ @Override public String getShortName() { return NAME; @@ -41,17 +59,16 @@ public class PostgresProvider extends Da @Override public ParameterDescriptorGroup getOpenParameters() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public ProbeResult probeContent(StorageConnector connector) throws DataStoreException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } @Override public DataStore open(StorageConnector connector) throws DataStoreException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } - }
