use of com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo in project cubrid-manager by CUBRID.
the class ImportERwinAction method run.
public void run() {
// FIXME logic code move to core module
int selected = 0;
int logined = 0;
Object[] objects = getSelectedObj();
if (objects instanceof Object[]) {
for (Object object : objects) {
if (object instanceof CubridDatabase) {
selected++;
CubridDatabase database = (CubridDatabase) object;
if (database.isLogined()) {
logined++;
}
}
}
}
if (selected > 1) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectOneDbToImport);
return;
}
if (selected <= 0) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectImportDbToImport);
return;
}
if (logined <= 0) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectLoginedDbToImport);
return;
}
Object[] obj = getSelectedObj();
if (obj == null || obj.length != 1) {
return;
}
if (!(obj[0] instanceof CubridDatabase)) {
return;
}
database = (CubridDatabase) obj[0];
ERwinImportDialog dialog = new ERwinImportDialog(getShell(), database);
int returnvalue = dialog.open();
if (returnvalue != IDialogConstants.OK_ID) {
return;
}
ERXmlContainer container = dialog.getContainer();
if (container.getErrMsg() != null && !container.getErrMsg().equals("")) {
CommonUITool.openErrorBox(container.getErrMsg());
return;
}
Map<String, TableSchema> tableSchema = container.getTableSchemas();
Map<String, ERWinSchemaInfo> schemaInfos = container.getSchemaInfos();
String modelName = container.getDatabaseName();
createCompareModel(modelName, tableSchema, schemaInfos);
}
use of com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo in project cubrid-manager by CUBRID.
the class CubridTableParser method appendLogicalInfo.
/**
* After build physical info to ERTable, append logical info to success
* tables.
*
* @param schemaInfos
* @return void
*/
public void appendLogicalInfo(Map<String, ERWinSchemaInfo> schemaInfos) {
for (ERTable table : successTables) {
String physicalTName = table.getName();
ERWinSchemaInfo erwinSchemaInfo = schemaInfos.get(physicalTName);
String logicalTableName = erwinSchemaInfo.getLogicalName();
if (StringUtil.isEmpty(logicalTableName)) {
logicalTableName = physicalTName;
}
table.setName(logicalTableName, false);
if (!logicalTableName.equals(physicalTName)) {
table.setDescription(logicalTableName);
}
List<ERWinDBAttribute> erwinAttrList = erwinSchemaInfo.getERWinAttributes();
for (ERWinDBAttribute attr : erwinAttrList) {
String physicalColName = attr.getName();
ERTableColumn column = table.getColumn(physicalColName);
String logicalColName = attr.getLogicalName();
if (StringUtil.isEmpty(logicalColName)) {
logicalColName = physicalColName;
}
column.setName(logicalColName, false);
if (!logicalColName.equals(physicalColName)) {
column.setDescription(logicalColName);
}
String logicType = attr.getLogicalDataType();
if (StringUtil.isEmpty(logicType)) {
String physicalRealType = column.getRealType();
logicType = column.getERSchema().convert2LogicalShowType(physicalRealType);
}
column.setShowType(logicType, false);
}
}
}
use of com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo in project cubrid-manager by CUBRID.
the class ImportERwinDataController method buildERDSchema.
private void buildERDSchema(ERSchema erSchema, Map<String, ERWinSchemaInfo> schemaInfos) {
String message = "";
CubridTableParser tableParser = new CubridTableParser(erSchema);
Set<SchemaInfo> dbSchemaInfos = new HashSet<SchemaInfo>();
Collection<ERWinSchemaInfo> erwinSchemas = schemaInfos.values();
for (ERWinSchemaInfo erwinSchema : erwinSchemas) {
SchemaInfo schemaInfo = (SchemaInfo) erwinSchema;
dbSchemaInfos.add(schemaInfo);
}
tableParser.buildERTables(dbSchemaInfos, -1, -1, true);
tableParser.appendLogicalInfo(schemaInfos);
List<ERTable> successTables = tableParser.getSuccessTables();
for (ERTable table : successTables) {
ERWinSchemaInfo savedTable = schemaInfos.get(table.getName());
table.setLogicalName(savedTable.getLogicalName());
List<ERTableColumn> columns = table.getColumns();
for (ERTableColumn column : columns) {
String colName = column.getName();
ERWinDBAttribute savedDBAttr = savedTable.getERWinDBAttr(colName);
column.setLogicalName(savedDBAttr.getLogicalName());
column.setLogicalType(savedDBAttr.getLogicalDataType());
}
}
erSchema.FireAddedTable(successTables);
Map<String, Exception> failedTables = tableParser.getFailedTables();
Map<String, List<Constraint>> removedFKs = tableParser.getRemovedFKConstraints();
if (failedTables.size() > 0) {
message = Messages.bind(com.cubrid.common.ui.er.Messages.errorAddTables, failedTables.keySet());
}
if (removedFKs.size() > 0) {
if (!message.equals("")) {
message += "\n";
}
message += Messages.bind(com.cubrid.common.ui.er.Messages.cannotBeBuiltFK, tableParser.getOneRemovedFK().getName());
if (tableParser.getRemovedFKCount() > 1) {
message += ", ...";
}
}
if (!message.equals("")) {
CommonUITool.openErrorBox(message);
}
}
Aggregations