From 0d00f56cf0aaf5c4a5fac782afc002cf64c12de1 Mon Sep 17 00:00:00 2001 From: hwany7seo Date: Wed, 28 Feb 2024 13:52:09 +0900 Subject: [PATCH] [TOOLS-4565] Improved details information output in object mapping page (#156) http://jira.cubrid.org/browse/TOOLS-4565 - PK warning message is sort. - Prevents warning messages related to column length from being output. --- .../ui/wizard/page/ObjectMappingPage.java | 3 + .../ui/wizard/utils/MigrationCfgUtils.java | 68 ++++++++++--------- .../ui/wizard/utils/VerifyResultMessages.java | 25 +++++++ 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/page/ObjectMappingPage.java b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/page/ObjectMappingPage.java index 3dfee00f..2c614805 100644 --- a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/page/ObjectMappingPage.java +++ b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/page/ObjectMappingPage.java @@ -768,6 +768,9 @@ private boolean validateConfig() { setErrorMessage(null); // Show confirm dialog. StringBuffer detailMsg = new StringBuffer(); + if (result.hasPKConfirm()) { + detailMsg.append(result.getPKConfirmMessage()).append("\r\n"); + } if (result.hasConfirm()) { detailMsg.append(result.getConfirmMessage()).append("\r\n"); } diff --git a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/MigrationCfgUtils.java b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/MigrationCfgUtils.java index 9365c074..d86222fa 100644 --- a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/MigrationCfgUtils.java +++ b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/MigrationCfgUtils.java @@ -222,6 +222,7 @@ public VerifyResultMessages checkAll(MigrationConfiguration config) { try { StringBuffer sbWarning = new StringBuffer(); StringBuffer sbConfirm = new StringBuffer(); + StringBuffer pkConfirm = new StringBuffer(); if (!config.hasObjects2Export()) { throw new MigrationConfigurationCheckingErrorException( "There is no object to be migrated."); @@ -231,16 +232,17 @@ public VerifyResultMessages checkAll(MigrationConfiguration config) { result = checkCSVCfg(config); } else { result = checkEntryTableCfg(config); - mergeVerifyResults(sbWarning, sbConfirm, result); + mergeVerifyResults(sbWarning, sbConfirm, pkConfirm, result); result = checkSQLTableCfg(config); - mergeVerifyResults(sbWarning, sbConfirm, result); + mergeVerifyResults(sbWarning, sbConfirm, pkConfirm, result); result = checkViewCfg(config); - mergeVerifyResults(sbWarning, sbConfirm, result); + mergeVerifyResults(sbWarning, sbConfirm, pkConfirm, result); result = checkSerialCfg(config); - mergeVerifyResults(sbWarning, sbConfirm, result); + mergeVerifyResults(sbWarning, sbConfirm, pkConfirm, result); } result.setWarningMessage(sbWarning.toString().trim()); result.setConfirmMessage(sbConfirm.toString().trim()); + result.setPKConfirmMessage(pkConfirm.toString().trim()); return result; } catch (MigrationConfigurationCheckingErrorException ex) { return new VerifyResultMessages(ex.getMessage(), null, null); @@ -316,6 +318,7 @@ protected VerifyResultMessages checkCSVCfg(MigrationConfiguration config) { protected VerifyResultMessages checkEntryTableCfg(MigrationConfiguration config) { StringBuffer sbWarning = new StringBuffer(); StringBuffer sbConfirm = new StringBuffer(); + StringBuffer pkConfirm = new StringBuffer(); for (SourceEntryTableConfig setc : config.getExpEntryTableCfg()) { VerifyResultMessages result = checkEntryTableCfg(config, setc); if (result.hasWarning() && sbWarning.indexOf(result.getWarningMessage()) < 0) { @@ -324,9 +327,15 @@ protected VerifyResultMessages checkEntryTableCfg(MigrationConfiguration config) if (result.hasConfirm() && sbConfirm.indexOf(result.getConfirmMessage()) < 0) { sbConfirm.append(result.getConfirmMessage()).append(LINE_SEP); } + if (result.hasPKConfirm() && pkConfirm.indexOf(result.getPKConfirmMessage()) < 0) { + pkConfirm.append(result.getPKConfirmMessage()).append(LINE_SEP); + } } return new VerifyResultMessages( - null, sbWarning.toString().trim(), sbConfirm.toString().trim()); + null, + sbWarning.toString().trim(), + sbConfirm.toString().trim(), + pkConfirm.toString().trim()); } /** @@ -371,6 +380,7 @@ protected VerifyResultMessages checkEntryTableCfg( StringBuffer sbWarn = new StringBuffer(); StringBuffer sbConfirm = new StringBuffer(); StringBuffer sbNoPkTable = new StringBuffer(); + StringBuffer sbpkConfirm = new StringBuffer(); // If there is no PK in the source table, output a warning. if (!srcTable.hasPK()) { if (config.getSrcCatalog().getSchemas().size() > 1) { @@ -379,14 +389,13 @@ protected VerifyResultMessages checkEntryTableCfg( sbNoPkTable.append(srcTable.getName()); - String errorMessage = - NLS.bind(Messages.objectMapPageErrMsgNoPK, sbNoPkTable.toString()); - sbConfirm.append(errorMessage).append(LINE_SEP); + sbpkConfirm.append(NLS.bind(Messages.objectMapPageErrMsgNoPK, sbNoPkTable.toString())); + sbpkConfirm.append(LINE_SEP); } checkTableIsInTargetDb(config, setc, targetTable, sbConfirm); checkTableColumns(config, setc, srcTable, targetTable, sbConfirm); checkEntryTableConstrains(setc, targetTable, sbWarn, sbConfirm); - return createVerifyResult(sbWarn, sbConfirm); + return createVerifyResult(sbWarn, sbConfirm, sbpkConfirm); } /** @@ -664,17 +673,6 @@ protected VerifyResultMessages checkSQLTableCfg( String errorMessage = NLS.bind(Messages.objectMapPageErrMsgColumnNotMatched, bindings); sbConfirm.append(errorMessage).append(LINE_SEP); - } else if (verifyInfo.getResult() == VerifyInfo.TYPE_NOENOUGH_LENGTH) { - String[] bindings = - new String[] { - scol.getName(), - scol.getShownDataType(), - tcol.getName(), - tcol.getShownDataType(), - srcTable.getName() - }; - String errorMessage = NLS.bind(Messages.msgErrColumnNotEnoughLength, bindings); - sbConfirm.append(errorMessage).append(LINE_SEP); } } return createVerifyResult(sbWarn, sbConfirm); @@ -753,17 +751,6 @@ protected void checkTableColumns( String errorMessage = NLS.bind(Messages.objectMapPageErrMsgColumnNotMatched, bindings); sbConfirm.append(errorMessage).append(LINE_SEP); - } else if (verifyInfo.getResult() == VerifyInfo.TYPE_NOENOUGH_LENGTH) { - String[] bindings = - new String[] { - scol.getName(), - scol.getShownDataType(), - tcol.getName(), - tcol.getShownDataType(), - srcTable.getName() - }; - String errorMessage = NLS.bind(Messages.msgErrColumnNotEnoughLength, bindings); - sbConfirm.append(errorMessage).append(LINE_SEP); } } // If no column to be migrated @@ -889,6 +876,17 @@ protected VerifyResultMessages createVerifyResult(StringBuffer sbWarn, StringBuf return result; } + protected VerifyResultMessages createVerifyResult( + StringBuffer sbWarn, StringBuffer sbConfirm, StringBuffer pkConfirm) { + VerifyResultMessages result = createVerifyResult(sbWarn, sbConfirm); + + if (pkConfirm.length() > 0) { + result.setPKConfirmMessage(pkConfirm.toString().trim()); + } + + return result; + } + /** @return true if user should change the target character type's size to avoid data lost. */ public boolean doesNeedToChangeCharacterTypeSize() { return DatabaseType.MYSQL.equals(config.getSourceDBType()) @@ -946,13 +944,19 @@ protected int getRightCharacerTypePrecision(long precision) { * @param result VerifyResultMessages */ protected void mergeVerifyResults( - StringBuffer sbWarning, StringBuffer sbConfirm, VerifyResultMessages result) { + StringBuffer sbWarning, + StringBuffer sbConfirm, + StringBuffer pkConfirm, + VerifyResultMessages result) { if (result.hasWarning()) { sbWarning.append(result.getWarningMessage()).append(LINE_SEP); } if (result.hasConfirm()) { sbConfirm.append(result.getConfirmMessage()).append(LINE_SEP); } + if (result.hasPKConfirm()) { + pkConfirm.append(result.getPKConfirmMessage()).append(LINE_SEP); + } } /** diff --git a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/VerifyResultMessages.java b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/VerifyResultMessages.java index 9364ea61..3e6389c4 100644 --- a/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/VerifyResultMessages.java +++ b/com.cubrid.cubridmigration.ui/src/com/cubrid/cubridmigration/ui/wizard/utils/VerifyResultMessages.java @@ -41,6 +41,7 @@ public class VerifyResultMessages { private String errorMessage; private String warningMessage; private String confirmMessage; + private String pkConfirmMsg; public VerifyResultMessages() { // do nothing. @@ -50,6 +51,18 @@ public VerifyResultMessages(String errorMessage, String warningMessage, String c this.errorMessage = errorMessage; this.warningMessage = warningMessage; this.confirmMessage = confirmMessage; + this.pkConfirmMsg = ""; + } + + public VerifyResultMessages( + String errorMessage, + String warningMessage, + String confirmMessage, + String pkConfirmMsg) { + this.errorMessage = errorMessage; + this.warningMessage = warningMessage; + this.confirmMessage = confirmMessage; + this.pkConfirmMsg = pkConfirmMsg; } /** @@ -79,6 +92,10 @@ public boolean hasConfirm() { return !StringUtils.isEmpty(confirmMessage); } + public boolean hasPKConfirm() { + return !StringUtils.isEmpty(pkConfirmMsg); + } + public String getErrorMessage() { return errorMessage; } @@ -102,4 +119,12 @@ public String getConfirmMessage() { public void setConfirmMessage(String confirmMessage) { this.confirmMessage = confirmMessage; } + + public String getPKConfirmMessage() { + return pkConfirmMsg; + } + + public void setPKConfirmMessage(String pkConfirmMsg) { + this.pkConfirmMsg = pkConfirmMsg; + } }