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;
}
Aggregations