use of com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel in project cubrid-manager by CUBRID.
the class TableSchemaCompareExtraColumnLabelProvider method getText.
public String getText(Object element) {
TableSchemaCompareModel cm = (TableSchemaCompareModel) element;
TableDetailInfo tableInfo = null;
if (focus == 0) {
if (cm.getCompareStatus() != TableSchemaCompareModel.SCHEMA_SMISS) {
tableInfo = cm.getSourceTableDetailInfo();
}
} else if (focus == 1) {
if (cm.getCompareStatus() != TableSchemaCompareModel.SCHEMA_TMISS) {
tableInfo = cm.getTargetTableDetailInfo();
if (tableInfo == null) {
TableSchema tableSchema = (TableSchema) cm.getRight();
SchemaInfo schemaInfo = cm.getTargetSchemas().get(tableSchema.getName());
int columnCount = schemaInfo.getAttributes().size();
int idxCount = 0;
int pk = 0;
for (Constraint constraint : schemaInfo.getConstraints()) {
if (constraint.getType().equals(ConstraintType.PRIMARYKEY.getText())) {
pk++;
continue;
} else {
idxCount++;
}
}
tableInfo = new TableDetailInfo();
tableInfo.setPkCount(pk);
tableInfo.setColumnsCount(columnCount);
tableInfo.setIndexCount(idxCount);
}
}
}
if (type == RECORDS_COUNT) {
long tableRecordCount = 0;
if (tableInfo != null) {
tableRecordCount = tableInfo.getRecordsCount();
}
if (focus == 0) {
cm.setSourceRecords(tableRecordCount);
} else if (focus == 1) {
cm.setTargetRecords(tableRecordCount);
}
if (tableRecordCount < 0) {
return Messages.notCount;
}
return String.valueOf(tableRecordCount);
} else if (type == ATTRIBUTES_COUNT) {
int attributeCount = 0;
if (tableInfo != null) {
attributeCount = tableInfo.getColumnsCount();
}
return String.valueOf(attributeCount);
} else if (type == INDEX_COUNT) {
int indexCount = 0;
if (tableInfo != null) {
indexCount = tableInfo.getIndexCount();
}
return String.valueOf(indexCount);
} else if (type == PK_STATUS) {
int pkCount = 0;
if (tableInfo != null) {
pkCount = tableInfo.getPkCount();
}
if (pkCount > 0) {
return "Y";
}
return "";
}
return "";
}
use of com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel in project cubrid-manager by CUBRID.
the class TableSchemaCompareInfoPart method copyTableAlterDDL.
/**
* copyTableLeftAlterDDL
*/
private void copyTableAlterDDL(CubridDatabase leftDB, CubridDatabase rightDB, boolean leftToRight) {
// FIXME logic code move to core module
StringBuffer clipboardDataString = new StringBuffer();
TableItem[] tableItems = tablesSchemaCompareTable.getTable().getSelection();
String title = "";
String msg = "";
for (int i = 0; i < tableItems.length; i++) {
if (i > 0) {
clipboardDataString.append(StringUtil.NEWLINE);
clipboardDataString.append(StringUtil.NEWLINE);
}
TableSchemaCompareModel compareModel = (TableSchemaCompareModel) tableItems[i].getData();
TableSchema leftTableSchema = (TableSchema) compareModel.getLeft();
TableSchema rightTableSchema = (TableSchema) compareModel.getRight();
String tableCompare = leftTableSchema.getName();
if (StringUtil.isEmpty(leftTableSchema.getName())) {
tableCompare = rightTableSchema.getName();
}
String alterDDL = null;
if (compareModel.getCompareStatus() != TableSchemaCompareModel.SCHEMA_EQUAL && compareModel.getCompareStatus() != TableSchemaCompareModel.RECORDS_DIFF) {
Map<String, SchemaInfo> sourceSchemas = compareModel.getSourceSchemas();
Map<String, SchemaInfo> targetSchemas = compareModel.getTargetSchemas();
SchemaInfo sourceTableSchemaInfo = null;
SchemaInfo targetTableSchemaInfo = null;
if (leftToRight) {
sourceTableSchemaInfo = sourceSchemas.get(tableCompare);
targetTableSchemaInfo = targetSchemas.get(tableCompare);
} else {
targetTableSchemaInfo = sourceSchemas.get(tableCompare);
sourceTableSchemaInfo = targetSchemas.get(tableCompare);
}
alterDDL = tableComp.getTableAlterScript(leftDB, rightDB, tableCompare, sourceTableSchemaInfo, targetTableSchemaInfo);
if (StringUtil.isNotEmpty(alterDDL)) {
clipboardDataString.append(alterDDL.trim());
}
}
}
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboardDataString.length() != 0) {
if ("--NotSupportAlterAutoIncrement".equals(clipboardDataString.toString())) {
title = Messages.compareStatusTip;
msg = Messages.alterAutoIncrementNotSupport;
} else {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { clipboardDataString.toString() };
clipboard.setContents(data, transfers);
title = Messages.alterScript;
msg = Messages.tableSchemaAlterCopyMessage;
}
} else {
clipboard.clearContents();
title = Messages.emptyAlterScript;
msg = Messages.schemaIdenticalMessage;
}
CommonUITool.openInformationBox(title, msg);
}
use of com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel in project cubrid-manager by CUBRID.
the class TableSchemaComparator method compare.
/**
* Returns a list of table schema compare model
*
* @param left
* @param right
* @return TableSchemaCompareModel
*/
public TableSchemaCompareModel compare(TableSchemaModel left, TableSchemaModel right) {
TableSchemaCompareModel compareModel = new TableSchemaCompareModel(left, right, sourceClasses, targetClasses);
compareModel.setTitle(left != null ? left.getName() : null);
List<TableSchemaCompareModel> tableCompareModelList = compareDetail(left, right);
if (tableCompareModelList == null) {
tableCompareModelList = new ArrayList<TableSchemaCompareModel>();
}
compareModel.setTableCompareList(tableCompareModelList);
compareModel.setDuplicateNameMap(duplicateNameMap);
return compareModel;
}
Aggregations