@Override public Collection<Table> getTables(final Schema schema) { return catalog.getTables(schema); }
@Override public Collection<Schema> getSchemas() { return catalog.getSchemas(); }
@Override public Collection<Routine> getRoutines(final Schema schema) { return catalog.getRoutines(schema); }
.getColumnDataTypes(); final Collection<Table> tables = catalog.getTables(); final Collection<Routine> routines = catalog.getRoutines(); final Collection<Synonym> synonyms = catalog.getSynonyms(); final Collection<Sequence> sequences = catalog.getSequences(); handler.handle(catalog.getCrawlInfo()); handler.handleHeaderEnd(); handler.handle(catalog.getSchemaCrawlerInfo()); handler.handle(catalog.getDatabaseInfo()); handler.handle(catalog.getJdbcDriverInfo()); handler.handleInfoEnd();
options); for (final Schema schema: catalog.getSchemas()) for (final Table table: catalog.getTables(schema))
@Test public void catalogSerialization(final Connection connection) throws Exception { final SchemaCrawlerOptions schemaCrawlerOptions = DatabaseTestUtility.schemaCrawlerOptionsWithMaximumSchemaInfoLevel; final Catalog catalog = getCatalog(connection, schemaCrawlerOptions); assertThat("Could not obtain catalog", catalog, notNullValue()); assertThat("Could not find any schemas", catalog.getSchemas(), is(not(empty()))); final Schema schema = catalog.lookupSchema("PUBLIC.BOOKS").orElse(null); assertThat("Could not obtain schema", schema, notNullValue()); assertThat("Unexpected number of tables in the schema", catalog.getTables(schema), hasSize(10)); final Catalog clonedCatalog = SerializationUtils.clone(catalog); assertThat(catalog, equalTo(clonedCatalog)); assertThat("Could not obtain catalog", clonedCatalog, notNullValue()); assertThat("Could not find any schemas", clonedCatalog.getSchemas(), is(not(empty()))); final Schema clonedSchema = clonedCatalog.lookupSchema("PUBLIC.BOOKS") .orElse(null); assertThat("Could not obtain schema", clonedSchema, notNullValue()); assertThat("Unexpected number of tables in the schema", clonedCatalog.getTables(clonedSchema), hasSize(10)); }
@Test public void grepColumnsAndIncludeChildTables(final Connection connection) throws Exception { SchemaCrawlerOptions schemaCrawlerOptions = SchemaCrawlerOptionsBuilder .builder() .includeGreppedColumns(new RegularExpressionInclusionRule(".*\\.BOOKAUTHORS\\..*")) .toOptions(); Catalog catalog; Schema schema; Table table; catalog = getCatalog(connection, schemaCrawlerOptions); schema = catalog.lookupSchema("PUBLIC.BOOKS").get(); assertThat("Schema PUBLIC.BOOKS not found", schema, notNullValue()); assertThat(catalog.getTables(schema), hasSize(1)); table = catalog.lookupTable(schema, "BOOKAUTHORS").get(); assertThat("Table BOOKAUTHORS not found", table, notNullValue()); schemaCrawlerOptions = SchemaCrawlerOptionsBuilder.builder() .fromOptions(schemaCrawlerOptions).parentTableFilterDepth(1).toOptions(); catalog = getCatalog(connection, schemaCrawlerOptions); schema = catalog.lookupSchema("PUBLIC.BOOKS").get(); assertThat("Schema PUBLIC.BOOKS not found", schema, notNullValue()); assertThat(catalog.getTables(schema).size(), is(3)); table = catalog.lookupTable(schema, "BOOKAUTHORS").get(); assertThat("Table BOOKAUTHORS not found", table, notNullValue()); table = catalog.lookupTable(schema, "BOOKS").get(); assertThat("Table BOOKS not found", table, notNullValue()); table = catalog.lookupTable(schema, "AUTHORS").get(); assertThat("Table AUTHORS not found", table, notNullValue()); }
final Schema schema1 = new SchemaReference("PUBLIC", "BOOKS"); assertThat("Could not find any tables", catalog.getTables(schema1), not(empty())); assertThat("Wrong number of routines", catalog.getRoutines(schema1), hasSize(4)); catalog.getTables(schema1), equalTo(catalog.getTables(schema2))); assertThat("Routines do not match", catalog.getRoutines(schema1), equalTo(catalog.getRoutines(schema2))); final Table table1 = catalog.getTables(schema1).toArray(new Table[0])[0]; final Table table2 = catalog.getTables(schema1).toArray(new Table[0])[1]; assertThat("Tables should not be equal", table1, not(equalTo(table2)));
handler.handle(catalog.getSchemaCrawlerInfo()); handler.handle(catalog.getDatabaseInfo()); handler.handle(catalog.getJdbcDriverInfo()); handler.handleInfoEnd();
@Override public Collection<Synonym> getSynonyms(final Schema schema) { return catalog.getSynonyms(schema); }
/** * {@inheritDoc} */ @Override public Collection<Sequence> getSequences() { return catalog.getSequences(); }
final Schema[] schemas = catalog.getSchemas().toArray(new Schema[0]); assertThat("Schema count does not match", schemas, arrayWithSize(6)); for (final Schema schema: schemas) final Routine[] routines = catalog.getRoutines(schema) .toArray(new Routine[0]); for (final Routine routine: routines)
@Override public Collection<ColumnDataType> getColumnDataTypes(final Schema schema) { return catalog.getColumnDataTypes(schema); }
schemaRetrievalOptions, schemaCrawlerOptions); final Schema schema = catalog.lookupSchema("PUBLIC.BOOKS").get(); assertThat("BOOKS Schema not found", schema, notNullValue()); final Synonym[] synonyms = catalog.getSynonyms(schema) .toArray(new Synonym[0]); assertThat("Synonym count does not match", synonyms, arrayWithSize(1));
schemaRetrievalOptions, schemaCrawlerOptions); final Schema schema = catalog.lookupSchema("PUBLIC.BOOKS").get(); assertThat("BOOKS Schema not found", schema, notNullValue()); final Sequence[] sequences = catalog.getSequences(schema) .toArray(new Sequence[0]); assertThat("Sequence count does not match", sequences, arrayWithSize(1));
schemaRetrievalOptions, schemaCrawlerOptions); final DatabaseInfo databaseInfo = catalog.getDatabaseInfo(); final Collection<DatabaseProperty> dbProperties = databaseInfo .getProperties(); out.println(String.format("product version=%s", databaseInfo.getProductVersion())); out.println(String.format("catalog=%s", catalog.getName())); for (final Property serverInfoProperty: serverInfo)
@Override public DatabaseInfo getDatabaseInfo() { return catalog.getDatabaseInfo(); }
@Override public JdbcDriverInfo getJdbcDriverInfo() { return catalog.getJdbcDriverInfo(); }
@Override public String getName() { return catalog.getName(); }
@Override public CrawlInfo getCrawlInfo() { return catalog.getCrawlInfo(); }