/** * Returns {@code true} if the two specified documents represents the same * element in the database. Two documents are considered same if they have * the same name and type and their parents are considered same. * * @param first the first document * @param second the second document * @return {@code true} if same, else {@code false} */ public static boolean isSame(Table first, Table second) { if (first.getId().equals(second.getId())) { final Schema firstParent = first.getParentOrThrow(); final Schema secondParent = second.getParentOrThrow(); return isSame(firstParent, secondParent); } else { return false; } }
/** * Returns the full name used in the database for the specified * {@link Table}. This is typically constructed by combining the schema and * the table name with a separator, but that might be different in different * implementations. * * @param table the table to retrieve the name of * @return the full name */ default String fullNameOf(Table table) { final Schema schema = table.getParentOrThrow(); return fullNameOf(schema.getName(), table.getName()); }
private String readFromResultSet(File file, Column c, AtomicInteger position) { final Dbms dbms = c.getParentOrThrow().getParentOrThrow().getParentOrThrow(); dbmsTypeOf(dbmsHandlerComponent, c.getParentOrThrow().getParentOrThrow().getParentOrThrow()), c.findDatabaseType() );
/** * Returns the full name used in the database for the specified * {@link Column}. This is typically constructed by combining the table and * the column name with a separator, but that might be different in * different implementations. * * @param column the column to retrieve the name of * @return the full name */ default String fullNameOf(Column column) { final Table table = column.getParentOrThrow(); final Schema schema = table.getParentOrThrow(); return fullNameOf(schema.getName(), table.getName(), column.getName()); }
private void foreignKeys(Connection conn, Table table, ProgressMeasure progress) { requireNonNulls(conn, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> conn.getMetaData().getImportedKeys(null, null, table.getId());
protected void primaryKeyColumns(Connection connection, Table table, ProgressMeasure progressListener) { requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getPrimaryKeys(jdbcCatalogLookupName(schema), jdbcSchemaLookupName(schema), metaDataTableNameForPrimaryKeys(table) ); final AbstractDbmsOperationHandler.TableChildMutator<PrimaryKeyColumn, ResultSet> mutator = (primaryKeyColumn, rs) -> { final String columnName = rs.getString("COLUMN_NAME"); primaryKeyColumn.mutator().setId(columnName); primaryKeyColumn.mutator().setName(columnName); primaryKeyColumn.mutator().setOrdinalPosition(rs.getInt("KEY_SEQ")); }; tableChilds(PrimaryKeyColumn.class, table.mutator()::addNewPrimaryKeyColumn, supplier, mutator, progressListener); if (!table.isView() && table.primaryKeyColumns().noneMatch(pk -> true)) { LOGGER.warn("Table '" + table.getId() + "' does not have any primary key."); } }
protected void foreignKeys(Connection connection, Table table, ProgressMeasure progressListener) { requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getImportedKeys(
final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getIndexInfo(
).set(Value.ofInvocation(TableIdentifier.class, "of", Stream.<HasAlias>of( table.getParentOrThrow().getParentOrThrow(), table.getParentOrThrow(), table ).map(HasName::getName)
requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow();
/** * Returns the full name used in the database for the specified * {@link Table}. This is typically constructed by combining the schema and * the table name with a separator, but that might be different in different * implementations. * * @param table the table to retrieve the name of * @return the full name */ default String fullNameOf(Table table) { final Schema schema = table.getParentOrThrow(); return fullNameOf(schema.getName(), table.getName()); }
private String readFromResultSet(File file, Column c, AtomicInteger position) { final Dbms dbms = c.getParentOrThrow().getParentOrThrow().getParentOrThrow(); dbmsTypeOf(dbmsHandlerComponent, c.getParentOrThrow().getParentOrThrow().getParentOrThrow()), c.findDatabaseType() );
/** * Returns the full name used in the database for the specified * {@link Column}. This is typically constructed by combining the table and * the column name with a separator, but that might be different in * different implementations. * * @param column the column to retrieve the name of * @return the full name */ default String fullNameOf(Column column) { final Table table = column.getParentOrThrow(); final Schema schema = table.getParentOrThrow(); return fullNameOf(schema.getName(), table.getName(), column.getName()); }
protected void primaryKeyColumns(Connection connection, Table table, ProgressMeasure progressListener) { requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getPrimaryKeys(jdbcCatalogLookupName(schema), jdbcSchemaLookupName(schema), metaDataTableNameForPrimaryKeys(table) ); final AbstractDbmsOperationHandler.TableChildMutator<PrimaryKeyColumn, ResultSet> mutator = (primaryKeyColumn, rs) -> { final String columnName = rs.getString("COLUMN_NAME"); primaryKeyColumn.mutator().setId(columnName); primaryKeyColumn.mutator().setName(columnName); primaryKeyColumn.mutator().setOrdinalPosition(rs.getInt("KEY_SEQ")); }; tableChilds(PrimaryKeyColumn.class, table.mutator()::addNewPrimaryKeyColumn, supplier, mutator, progressListener); if (!table.isView() && table.primaryKeyColumns().noneMatch(pk -> true)) { LOGGER.warn("Table '" + table.getId() + "' does not have any primary key."); } }
private void foreignKeys(Connection conn, Table table, ProgressMeasure progress) { requireNonNulls(conn, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> conn.getMetaData().getImportedKeys(null, null, table.getId());
protected void foreignKeys(Connection connection, Table table, ProgressMeasure progressListener) { requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getImportedKeys(
final Schema schema = table.getParentOrThrow(); final SqlSupplier<ResultSet> supplier = () -> connection.getMetaData().getIndexInfo(
).set(Value.ofInvocation(TableIdentifier.class, "of", Stream.<HasAlias>of( table.getParentOrThrow().getParentOrThrow(), table.getParentOrThrow(), table ).map(HasName::getName)
requireNonNulls(connection, table); final Schema schema = table.getParentOrThrow();