Search in sources :

Example 21 with Database

use of org.jumpmind.db.model.Database in project symmetric-ds by JumpMind.

the class AbstractDatabasePlatform method readDatabaseFromXml.

public Database readDatabaseFromXml(InputStream is, boolean alterCaseToMatchDatabaseDefaultCase) {
    InputStreamReader reader = new InputStreamReader(is);
    Database database = DatabaseXmlUtil.read(reader);
    if (alterCaseToMatchDatabaseDefaultCase) {
        alterCaseToMatchDatabaseDefaultCase(database);
    }
    return database;
}
Also used : InputStreamReader(java.io.InputStreamReader) Database(org.jumpmind.db.model.Database)

Example 22 with Database

use of org.jumpmind.db.model.Database in project symmetric-ds by JumpMind.

the class AbstractDatabasePlatform method readFromDatabase.

public Database readFromDatabase(Table... tables) {
    Database fromDb = new Database();
    for (Table tableFromXml : tables) {
        Table tableFromDatabase = getTableFromCache(tableFromXml.getCatalog(), tableFromXml.getSchema(), tableFromXml.getName(), true);
        if (tableFromDatabase != null) {
            fromDb.addTable(tableFromDatabase);
        }
    }
    fromDb.initialize();
    return fromDb;
}
Also used : Table(org.jumpmind.db.model.Table) Database(org.jumpmind.db.model.Database)

Example 23 with Database

use of org.jumpmind.db.model.Database in project symmetric-ds by JumpMind.

the class TestSetupUtil method dropDatabaseTables.

public static IDatabasePlatform dropDatabaseTables(String databaseType, ISymmetricEngine engine) {
    ISymmetricDialect dialect = engine.getSymmetricDialect();
    AbstractJdbcDatabasePlatform platform = (AbstractJdbcDatabasePlatform) dialect.getPlatform();
    engine.uninstall();
    platform.resetDataSource();
    IDdlBuilder builder = platform.getDdlBuilder();
    Database db2drop = platform.readDatabase(platform.getDefaultCatalog(), platform.getDefaultSchema(), new String[] { "TABLE" });
    platform.resetDataSource();
    String sql = builder.dropTables(db2drop);
    SqlScript dropScript = new SqlScript(sql, platform.getSqlTemplate(), false, platform.getSqlScriptReplacementTokens());
    dropScript.execute(true);
    platform.resetDataSource();
    dialect.cleanDatabase();
    platform.resetCachedTableModel();
    return platform;
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) IDdlBuilder(org.jumpmind.db.platform.IDdlBuilder) Database(org.jumpmind.db.model.Database) SqlScript(org.jumpmind.db.sql.SqlScript) AbstractJdbcDatabasePlatform(org.jumpmind.db.platform.AbstractJdbcDatabasePlatform)

Example 24 with Database

use of org.jumpmind.db.model.Database in project symmetric-ds by JumpMind.

the class TestSetupUtil method dropAndCreateDatabaseTables.

public static void dropAndCreateDatabaseTables(String databaseType, ISymmetricEngine engine) {
    IDatabasePlatform platform = dropDatabaseTables(databaseType, engine);
    Database testDb = platform.readDatabaseFromXml("/test-schema.xml", true);
    platform.createDatabase(testDb, false, true);
}
Also used : IDatabasePlatform(org.jumpmind.db.platform.IDatabasePlatform) Database(org.jumpmind.db.model.Database)

Example 25 with Database

use of org.jumpmind.db.model.Database in project symmetric-ds by JumpMind.

the class AbstractSymmetricDialect method getCreateSymmetricDDL.

public String getCreateSymmetricDDL() {
    Database database = readSymmetricSchemaFromXml();
    prefixConfigDatabase(database);
    IDdlBuilder builder = platform.getDdlBuilder();
    return builder.createTables(database, true);
}
Also used : IDdlBuilder(org.jumpmind.db.platform.IDdlBuilder) Database(org.jumpmind.db.model.Database)

Aggregations

Database (org.jumpmind.db.model.Database)37 Table (org.jumpmind.db.model.Table)21 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)9 Test (org.junit.Test)7 IOException (java.io.IOException)6 IoException (org.jumpmind.exception.IoException)6 AbstractServiceTest (org.jumpmind.symmetric.service.impl.AbstractServiceTest)5 IDdlBuilder (org.jumpmind.db.platform.IDdlBuilder)4 SqlException (org.jumpmind.db.sql.SqlException)4 SqlScript (org.jumpmind.db.sql.SqlScript)4 DbExport (org.jumpmind.symmetric.io.data.DbExport)4 DbImport (org.jumpmind.symmetric.io.data.DbImport)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 InputStreamReader (java.io.InputStreamReader)2 LinkedHashMap (java.util.LinkedHashMap)2 AddTableChange (org.jumpmind.db.alter.AddTableChange)2 RemoveTableChange (org.jumpmind.db.alter.RemoveTableChange)2 TableChange (org.jumpmind.db.alter.TableChange)2 Column (org.jumpmind.db.model.Column)2