Search in sources :

Example 6 with CubridTableParser

use of com.cubrid.common.ui.er.model.CubridTableParser in project cubrid-manager by CUBRID.

the class ERDNDController method addTables.

private void addTables(List<SchemaInfo> schemaInfoList, int x, int y) {
    if (schemaInfoList == null) {
        return;
    }
    List<String> existTables = new ArrayList<String>();
    String message = "";
    ERSchema erSchema = editor.getERSchema();
    Iterator<SchemaInfo> it = schemaInfoList.iterator();
    while (it.hasNext()) {
        SchemaInfo table = (SchemaInfo) it.next();
        ERTable existTable = erSchema.getTable(table.getClassname());
        if (existTable != null) {
            existTables.add(table.getClassname());
            it.remove();
            continue;
        }
    }
    CubridTableParser tableParser = new CubridTableParser(erSchema);
    if (schemaInfoList.size() == 1) {
        tableParser.buildERTables(schemaInfoList, x, y, false);
    } else {
        tableParser.buildERTables(schemaInfoList, x, y, true);
    }
    erSchema.FireAddedTable(tableParser.getSuccessTables());
    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 (existTables.size() > 0) {
        if (!message.equals("")) {
            message += "\n";
        }
        message += Messages.bind(com.cubrid.common.ui.er.Messages.errExistTables, existTables);
    }
    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);
    }
}
Also used : ArrayList(java.util.ArrayList) ERSchema(com.cubrid.common.ui.er.model.ERSchema) ERTable(com.cubrid.common.ui.er.model.ERTable) CubridTableParser(com.cubrid.common.ui.er.model.CubridTableParser) ArrayList(java.util.ArrayList) List(java.util.List) SQLException(java.sql.SQLException) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)6 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)5 ERTable (com.cubrid.common.ui.er.model.ERTable)4 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)4 List (java.util.List)4 Constraint (com.cubrid.common.core.common.model.Constraint)3 ERSchema (com.cubrid.common.ui.er.model.ERSchema)3 ArrayList (java.util.ArrayList)2 ERWinDBAttribute (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute)1 ERWinSchemaInfo (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)1 AddFKDialog (com.cubrid.common.ui.cubrid.table.dialog.AddFKDialog)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1