Search in sources :

Example 1 with TableSchemaCompareUpdateDDL

use of com.cubrid.common.ui.compare.schema.model.TableSchemaCompareUpdateDDL in project cubrid-manager by CUBRID.

the class TableSchemaCompareComposite method getTableAlterScript.

/**
	 * Returns table schema update/alter script
	 *
	 * @param sourceDatabase
	 * @param targetDatabase
	 * @param tableCompare
	 */
public String getTableAlterScript(CubridDatabase sourceDatabase, CubridDatabase targetDatabase, String tableCompare, SchemaInfo sourceSchemaInfo, SchemaInfo targetSchemaInfo) {
    // FIXME logic code move to core module
    String alterDDL = null;
    try {
        DatabaseInfo source_dbInfo = sourceDatabase.getDatabaseInfo();
        DatabaseInfo target_dbInfo = targetDatabase.getDatabaseInfo();
        if (sourceSchemaInfo == null || !"normal".equals(sourceSchemaInfo.getVirtual()))
            sourceSchemaInfo = null;
        if (targetSchemaInfo == null || !"normal".equals(targetSchemaInfo.getVirtual()))
            targetSchemaInfo = null;
        SchemaChangeManager sourceChangeManger = new SchemaChangeManager(source_dbInfo, false);
        SchemaDDL sourceSchemaDDL = new SchemaDDL(sourceChangeManger, sourceDatabase.getDatabaseInfo());
        SchemaChangeManager targetChangeManger = new SchemaChangeManager(target_dbInfo, false);
        SchemaDDL targetSchemaDDL = null;
        if (targetDatabase.isVirtual()) {
            WrappedDatabaseInfo info = ERXmlDatabaseInfoMapper.getWrappedDatabaseInfo(target_dbInfo);
            targetSchemaDDL = new SchemaDDL(targetChangeManger, info);
        } else {
            targetSchemaDDL = new SchemaDDL(targetChangeManger, targetDatabase.getDatabaseInfo());
        }
        TableSchemaCompareUpdateDDL tableCompareDDL = new TableSchemaCompareUpdateDDL(sourceChangeManger, sourceSchemaDDL, targetSchemaDDL, sourceSchemaInfo, targetSchemaInfo);
        alterDDL = tableCompareDDL.getTableSchemaAlterDDL();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return alterDDL;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) SchemaChangeManager(com.cubrid.cubridmanager.core.cubrid.table.model.SchemaChangeManager) SchemaDDL(com.cubrid.cubridmanager.core.cubrid.table.model.SchemaDDL) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) TableSchemaCompareUpdateDDL(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareUpdateDDL)

Aggregations

TableSchemaCompareUpdateDDL (com.cubrid.common.ui.compare.schema.model.TableSchemaCompareUpdateDDL)1 WrappedDatabaseInfo (com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 SchemaChangeManager (com.cubrid.cubridmanager.core.cubrid.table.model.SchemaChangeManager)1 SchemaDDL (com.cubrid.cubridmanager.core.cubrid.table.model.SchemaDDL)1