public Database execute(Connection connection) throws SQLException { Database db = new Database(); db.setName(Table.getQualifiedTablePrefix(catalog, schema)); db.addTables(readTables(connection, catalog, schema, tableTypes)); db.initialize(); return db; } }));
protected Database postprocessModelFromDatabase(Database model) { // Default values for CHAR/VARCHAR/LONGVARCHAR columns have quotation // marks around them which we'll remove now for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++) { postprocessTableFromDatabase(model.getTable(tableIdx)); } return model; }
protected Database getDatabase(Table[] tables) { Database db = new Database(); try { if (!noCreateInfo) { for (Table table : tables) { Table newTable = (Table) table.clone(); if (noIndices) { newTable.removeAllIndices(); } if (noForeignKeys) { newTable.removeAllForeignKeys(); } db.addTable(newTable); } } } catch (Exception e) { throw new RuntimeException(e); } return db; }
public Database readSymmetricSchemaFromDatabase() { return platform.readFromDatabase(readSymmetricSchemaFromXml().getTables()); }
protected Database readDatabaseFromXml(String resourceName) throws IOException { try { return platform.readDatabaseFromXml(resourceName, true); } catch (IoException ex) { return new Database(); } }
protected List<Table> getSortedTablesFor(List<TriggerHistory> histories) { List<Table> tables = new ArrayList<Table>(histories.size()); for (TriggerHistory triggerHistory : histories) { Table table = platform.getTableFromCache(triggerHistory.getSourceCatalogName(), triggerHistory.getSourceSchemaName(), triggerHistory.getSourceTableName(), false); if (table != null) { tables.add(table); } } return Database.sortByForeignKeys(tables); }
public String getCreateTableXML(TriggerHistory triggerHistory, TriggerRouter triggerRouter) { Table table = getTable(triggerHistory, true); String targetTableName = triggerRouter.getRouter().getTargetTableName(); if (StringUtils.isNotBlank(targetTableName)) { table.setName(targetTableName); } Database db = new Database(); setDatabaseName(triggerRouter, db); db.addTable(table); StringWriter buffer = new StringWriter(); DatabaseXmlUtil.write(db, buffer); // TODO: remove when these bugs are fixed in DdlUtils String xml = buffer.toString().replaceAll("'", ""); xml = xml.replaceAll("default=\"empty_blob\\(\\) *\"", ""); xml = xml.replaceAll("unique name=\"PRIMARY\"", "unique name=\"PRIMARYINDEX\""); // on postgres, this is a "text" column xml = xml.replaceAll("type=\"VARCHAR\" size=\"2147483647\"", "type=\"LONGVARCHAR\""); xml = xml.replaceAll("type=\"BINARY\" size=\"2147483647\"", "type=\"LONGVARBINARY\""); return xml; }
protected Table getDbTable(String tableName) { if (allDbTablesCache == null) { allDbTablesCache = platform.readDatabase(getCatalogToUse(), getSchemaToUse(), null).getTables(); } for (Table table : allDbTablesCache) { if (table.getName().equalsIgnoreCase(tableName)) { return table; } } return null; }
if (cascading) { tables = addFkInsertDependentTables(table); tables = Database.sortByForeignKeys(tables); } else { tables = new Table[] {table};
protected Table[] getAllDbTables() { if (allDbTablesCache == null) { allDbTablesCache = platform.readDatabase(getCatalogToUse(), getSchemaToUse(), null).getTables(); } return allDbTablesCache; }
public void exportTables(OutputStream output, Table[] tables, String sql) throws IOException { for (int i = 0; i < tables.length; i++) { // if the table definition did not come from the database, then read // the table from the database if (!tables[i].containsJdbcTypes()) { tables[i] = platform.readTableFromDatabase(getCatalogToUse(), getSchemaToUse(), tables[i].getName()); } } WriterWrapper writerWrapper = null; try { writerWrapper = new WriterWrapper(output); tables = Database.sortByForeignKeys(tables); for (Table table : tables) { writeTable(writerWrapper, table, sql); } } finally { if (writerWrapper != null) { writerWrapper.close(); } } }
public void exportTables(OutputStream output) throws IOException { Database database = platform.readDatabase(getCatalogToUse(), getSchemaToUse(), new String[] { "TABLE" }); exportTables(output, database.getTables()); }
trigger.getSourceCatalogName(), trigger.getSourceSchemaName(), new String[] { "TABLE" }); Table[] tableArray = database.getTables();