From b8cba28bde71992b41aedcd2abb969e615da6134 Mon Sep 17 00:00:00 2001 From: hwanyseo Date: Sun, 10 Jul 2022 22:36:55 +0900 Subject: [PATCH] [CA, CM] For Support CUBRID Server 11.2 (UserSchema And Etc.) http://jira.cubrid.org/browse/TOOLS-4364 Many features have changed in version 11.2. And many failures occurred in the conformance test(APIS-923). So we will fix the Fail List and other issue List for compatibility. --- .../core/common/model/DBResolution.java | 22 +- .../core/common/model/PartitionInfo.java | 30 +- .../common/core/common/model/SchemaInfo.java | 52 +-- .../common/core/common/model/SerialInfo.java | 19 ++ .../common/core/common/model/Trigger.java | 9 + .../core/common/model/ViewDetailInfo.java | 9 + .../schemacomment/SchemaCommentHandler.java | 181 +++++++---- .../common/core/util/CompatibleUtil.java | 27 +- .../cubrid/common/core/util/QueryUtil.java | 41 ++- .../navigator/CubridColumnNavigatorView.java | 6 +- .../control/DataCompareDetailEditorPart.java | 4 +- .../data/control/DataCompareEditorPart.java | 34 +- .../compare/schema/TableSchemaComparator.java | 12 +- .../schema/TableSchemaCompareUtil.java | 2 + .../control/TableSchemaCompareInfoPart.java | 6 +- .../model/TableSchemaCompareUpdateDDL.java | 14 +- .../cubrid/database/erwin/ERXmlContainer.java | 6 +- .../erwin/action/ImportERwinAction.java | 2 +- .../database/erwin/task/ExportSchemaTask.java | 16 +- .../common/ui/cubrid/serial/Messages.java | 5 + .../ui/cubrid/serial/Messages.properties | 5 + .../cubrid/serial/Messages_ko_KR.properties | 5 + .../serial/action/CreateSerialAction.java | 4 +- .../serial/action/DeleteSerialAction.java | 4 +- .../serial/action/EditSerialAction.java | 2 +- .../dialog/CreateOrEditSerialDialog.java | 129 ++++++-- .../editor/SerialDashboardEditorPart.java | 52 ++- .../common/ui/cubrid/table/Messages.java | 1 + .../ui/cubrid/table/Messages.properties | 1 + .../ui/cubrid/table/Messages_ko_KR.properties | 25 +- .../table/action/CreateLikeTableAction.java | 30 +- .../cubrid/table/action/CreateViewAction.java | 8 +- .../cubrid/table/action/EditViewAction.java | 1 + .../table/action/RenameTableAction.java | 29 +- .../AttributeTableViewerLabelProvider.java | 7 +- .../table/control/CreatePartitionWizard.java | 6 +- .../table/control/PartitionEditListPage.java | 2 +- .../table/control/PartitionTypePage.java | 2 +- .../control/TableDashboardComposite.java | 4 +- .../dashboard/control/TableDashboardPart.java | 8 +- .../ui/cubrid/table/dialog/AddFKDialog.java | 4 +- .../table/dialog/AddResolutionDialog.java | 4 +- .../cubrid/table/dialog/CreateViewDialog.java | 81 ++++- .../table/dialog/RenameTableDialog.java | 16 +- .../exp/ExportSettingForLoadDBPage.java | 43 ++- .../table/dialog/exp/ExportSettingPage.java | 40 ++- .../imp/FileToTableMappingComposite.java | 48 ++- .../table/editor/AttributeCellModifier.java | 2 +- .../cubrid/table/editor/TableEditorPart.java | 297 ++++++++++++------ .../table/export/ExportSchemaThread.java | 36 ++- .../export/handler/AbsExportDataHandler.java | 14 +- .../export/handler/ExportLoadDBHandler.java | 16 +- .../export/handler/ExportToTxtHandler.java | 2 +- .../export/handler/ExportToXlsHandler.java | 2 +- .../export/handler/ExportToXlsxHandler.java | 2 +- .../export/handler/ExprotToOBSHandler.java | 2 +- .../export/handler/ExprotToSqlHandler.java | 2 +- .../table/progress/ExportDataViewPart.java | 19 +- .../ExportTableDefinitionLayoutType1.java | 2 +- .../ExportTableDefinitionLayoutType2.java | 2 +- .../ExportTableDefinitionProgress.java | 29 +- .../common/ui/cubrid/trigger/Messages.java | 1 + .../ui/cubrid/trigger/Messages.properties | 1 + .../cubrid/trigger/Messages_ko_KR.properties | 1 + .../trigger/action/AlterTriggerAction.java | 10 +- .../trigger/action/NewTriggerAction.java | 6 +- .../trigger/dialog/CreateTriggerDialog.java | 42 ++- .../editor/TriggerDashboardEditorPart.java | 38 ++- .../ui/cubrid/user/dialog/EditUserDialog.java | 16 +- .../view/editor/ViewDashboardComposite.java | 2 +- .../view/editor/ViewDashboardEditorPart.java | 28 +- .../common/ui/er/CubridSchemaInfoManager.java | 8 +- .../ui/er/action/AbstractSelectionAction.java | 1 + .../ui/er/action/ModifyTableNameAction.java | 3 +- .../ui/er/commands/AddTableCommand.java | 1 + .../ui/er/dialog/EditVirtualTableDialog.java | 22 +- .../common/ui/er/dnd/ERDNDController.java | 16 +- .../common/ui/er/editor/ERSchemaEditor.java | 6 +- .../common/ui/er/model/CubridTableParser.java | 18 +- .../cubrid/common/ui/er/model/ERTable.java | 7 +- .../QueryPlanCompositeWithHistory.java | 4 +- .../query/editor/ColumnProposalAdvisor.java | 4 +- .../editor/ColumnProposalDetailInfo.java | 4 +- .../common/ui/spi/model/CubridDatabase.java | 2 +- .../ui/spi/model/DefaultCubridNode.java | 20 +- .../ui/spi/model/DefaultSchemaNode.java | 15 + .../common/ui/spi/model/ICubridNode.java | 2 + .../common/ui/spi/model/MoreTablesNode.java | 2 +- .../loader/CubridSerialFolderLoader.java | 23 +- .../loader/CubridTriggerFolderLoader.java | 33 +- .../schema/CubridPartitionedTableLoader.java | 21 +- .../schema/CubridSystemTableFolderLoader.java | 4 +- .../schema/CubridSystemViewFolderLoader.java | 5 +- .../schema/CubridTablesFolderLoader.java | 24 +- .../schema/CubridUserTableColumnLoader.java | 4 +- .../schema/CubridUserTableIndexLoader.java | 5 +- .../loader/schema/CubridUserTableLoader.java | 4 +- .../schema/CubridViewsFolderLoader.java | 17 +- .../spi/progress/LoadTableDetailInfoTask.java | 2 +- .../OpenTablesDetailInfoPartProgress.java | 101 ++++-- .../OpenViewsDetailInfoPartProgress.java | 43 ++- .../common/ui/spi/util/ActionSupportUtil.java | 10 + .../common/ui/spi/util/GetInfoDataUtil.java | 2 +- .../cubrid/serial/task/SerialTaskTest.java | 28 +- .../cubrid/table/model/ClassInfoTest.java | 5 +- .../cubrid/table/model/DBResolutionTest.java | 8 +- .../cubrid/table/model/PartitionInfoTest.java | 38 +-- .../table/model/SchemaAlterDDLTest.java | 38 +-- .../table/model/SchemaChangeManagerTest.java | 1 + .../cubrid/table/model/SchemaDDLTest.java | 35 ++- .../cubrid/table/model/SchemaInfoTest.java | 19 +- .../cubrid/table/model/TableModelTest.java | 4 +- .../model/CubridBrokerConfParaConstants.java | 2 +- .../core/common/socket/SocketTask.java | 1 + .../common/task/CommonSQLExcuterTask.java | 2 +- .../cubrid/database/model/DatabaseInfo.java | 41 ++- .../serial/task/CreateOrEditSerialTask.java | 34 +- .../serial/task/GetSerialInfoListTask.java | 2 +- .../cubrid/serial/task/GetSerialInfoTask.java | 7 +- .../core/cubrid/table/model/ClassInfo.java | 44 ++- .../core/cubrid/table/model/SchemaDDL.java | 123 ++++++-- .../cubrid/table/model/SuperClassUtil.java | 22 +- .../core/cubrid/table/model/TableIndex.java | 12 + .../cubrid/table/task/CheckSubClassTask.java | 15 +- .../cubrid/table/task/GetAllAttrTask.java | 24 +- .../table/task/GetAllClassListTask.java | 38 ++- .../table/task/GetAllPartitionClassTask.java | 11 +- .../cubrid/table/task/GetAllSchemaTask.java | 246 ++++++++++++--- .../task/GetPartitionedClassListTask.java | 43 ++- .../core/cubrid/table/task/GetSchemaTask.java | 145 +++++++-- .../core/cubrid/table/task/GetTablesTask.java | 31 +- .../table/task/GetUserClassColumnsTask.java | 2 +- .../table/task/GetUserClassIndexesTask.java | 25 +- .../table/task/GetViewAllColumnsTask.java | 7 +- .../core/cubrid/trigger/model/TriggerDDL.java | 47 ++- .../trigger/task/JDBCGetTriggerInfoTask.java | 18 +- .../trigger/task/JDBCGetTriggerListTask.java | 22 +- .../cubridmanager/core/utils/ModelUtil.java | 2 +- .../control/BrokersParameterPropertyPage.java | 2 +- .../database/dialog/CopyDatabaseDialog.java | 5 +- .../database/dialog/LoginDatabaseDialog.java | 3 + .../dialog/LoginDatabaseTaskExecutor.java | 2 + .../jobauto/action/AddBackupPlanAction.java | 2 +- .../jobauto/action/AddQueryPlanAction.java | 2 +- .../model/loader/CQBDbConnectionLoader.java | 12 +- .../model/loader/CQBDbUsersFolderLoader.java | 2 +- 146 files changed, 2353 insertions(+), 882 deletions(-) diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/DBResolution.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/DBResolution.java index 87e5445e..384aedf9 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/DBResolution.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/DBResolution.java @@ -44,13 +44,13 @@ public class DBResolution implements Cloneable { private static final Logger LOGGER = LogUtil.getLogger(DBResolution.class); private String name; - private String className; + private String tableName; private String alias; private boolean isClassResolution; - public DBResolution(String name, String className, String alias) { + public DBResolution(String name, String tableName, String alias) { this.name = name; - this.className = className; + this.tableName = tableName; this.alias = alias; } @@ -81,12 +81,12 @@ public void setName(String name) { this.name = name; } - public String getClassName() { - return className; + public String getTableName() { + return tableName; } - public void setClassName(String className) { - this.className = className; + public void setTableName(String tableName) { + this.tableName = tableName; } /** @@ -113,7 +113,7 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result - + ((className == null) ? 0 : className.hashCode()); + + ((tableName == null) ? 0 : tableName.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } @@ -135,11 +135,11 @@ public boolean equals(Object obj) { // FIXME more simplify return false; } final DBResolution other = (DBResolution) obj; - if (className == null) { - if (other.className != null) { + if (tableName == null) { + if (other.tableName != null) { return false; } - } else if (!className.equals(other.className)) { + } else if (!tableName.equals(other.tableName)) { return false; } if (name == null) { diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/PartitionInfo.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/PartitionInfo.java index 3ea95b36..c3d0379d 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/PartitionInfo.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/PartitionInfo.java @@ -44,7 +44,7 @@ */ public class PartitionInfo implements Cloneable { private static final Logger LOGGER = LogUtil.getLogger(PartitionInfo.class); - private String className = null; + private String tableName = null; private String partitionName = null; private String partitionClassName = null; private PartitionType partitionType = null; @@ -60,8 +60,8 @@ public class PartitionInfo implements Cloneable { @Override public String toString() { // FIXME ToStringBuilder StringBuilder sb = new StringBuilder(); - sb.append("PartitionInfo[className=").append(className); sb.append(",partitionName=").append(partitionName); + sb.append("PartitionInfo[className=").append(tableName); sb.append(",partitionClassName=").append(partitionClassName); sb.append(",partitionType=").append(partitionType); sb.append(",partitionExpr=").append(partitionExpr); @@ -74,15 +74,15 @@ public PartitionInfo() { noOp(); } - public PartitionInfo(String className, PartitionType partitionType) { - this.className = className; + public PartitionInfo(String tableName, PartitionType partitionType) { + this.tableName = tableName; this.partitionType = partitionType; } - public PartitionInfo(String className, String partitionName, + public PartitionInfo(String tableName, String partitionName, PartitionType partitionType, String partitionExpr, List partitionValues, int rows) { - this.className = className; + this.tableName = tableName; this.partitionName = partitionName; this.partitionType = partitionType; this.partitionExpr = partitionExpr; @@ -90,10 +90,10 @@ public PartitionInfo(String className, String partitionName, this.rows = rows; } - public PartitionInfo(String className, String partitionName, + public PartitionInfo(String tableName, String partitionName, String partitionClassName, PartitionType partitionType, String partitionExpr, List partitionValues, int rows) { - this.className = className; + this.tableName = tableName; this.partitionName = partitionName; this.partitionClassName = partitionClassName; this.partitionType = partitionType; @@ -102,12 +102,12 @@ public PartitionInfo(String className, String partitionName, this.rows = rows; } - public String getClassName() { - return className; + public String getTableName() { + return tableName; } - public void setClassName(String className) { - this.className = className; + public void setTableName(String tableName) { + this.tableName = tableName; } public String getPartitionName() { @@ -131,9 +131,9 @@ public void setPartitionName(String partitionName) { */ public String getPartitionClassName() { if (partitionClassName == null - || !partitionClassName.equals(className + "__p__" + || !partitionClassName.equals(tableName + "__p__" + partitionName)) { - partitionClassName = className + "__p__" + partitionName; + partitionClassName = tableName + "__p__" + partitionName; } return partitionClassName; } @@ -289,7 +289,7 @@ public boolean equals(Object obj) { if (partitionInfo.partitionType != partitionType) { return false; } - if (!compareStr(partitionInfo.className, this.className)) { + if (!compareStr(partitionInfo.tableName, this.tableName)) { return false; } if (!compareStr(partitionInfo.partitionName, this.partitionName)) { diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SchemaInfo.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SchemaInfo.java index 08b47908..da81071f 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SchemaInfo.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SchemaInfo.java @@ -75,6 +75,8 @@ public class SchemaInfo implements Comparable, Cloneable { private List partitions = null; // cubrid 9.1 private String collation; + // Added For UserSchema(CUBRID 11.2 Or Higher) + private String uniqueName = null; public DBAttribute getAutoIncrementColumn() { if (attributes == null) { @@ -416,7 +418,7 @@ public boolean isAttributeUnique(DBAttribute attr, return false; } else { String attrName = attr.getName(); - boolean isInherited = attr.getInherit().equals(this.getClassname()) ? false + boolean isInherited = attr.getInherit().equals(this.getUniqueName()) ? false : true; for (Constraint constraint : constraints) { String constraintName = constraint.getName(); @@ -454,18 +456,18 @@ public boolean isAttributeUnique(DBAttribute attr, * * @param newClassName String the given new class name */ - private void fireClassNameChanged(String newClassName) { + private void fireClassNameChanged(String newTableName) { List list = new ArrayList(); list.addAll(getAttributes()); list.addAll(getClassAttributes()); for (DBAttribute a : list) { - if (a.getInherit().equals(classname)) { - a.setInherit(newClassName); + if (a.getInherit().equals(uniqueName)) { + a.setInherit(newTableName); } } if (this.partitions != null && !this.partitions.isEmpty()) { for (PartitionInfo info : partitions) { - info.setClassName(newClassName); + info.setTableName(newTableName); } } } @@ -602,7 +604,8 @@ public SchemaInfo clone() { public String toString() { StringBuffer bf = new StringBuffer(); bf.append("DB name:" + this.dbname + "\n"); - bf.append("table name:" + this.classname + "\n"); + bf.append("unique name:" + this.uniqueName + "\n"); + bf.append("class name:" + this.classname + "\n"); bf.append("\tOwner:" + this.owner + "\n"); bf.append("\ttype:" + this.type + "\n"); bf.append("\tvirtual:" + this.virtual + "\n"); @@ -1054,7 +1057,7 @@ public boolean isSystemClass() { * argument obj. */ public int compareTo(SchemaInfo obj) { - return classname.compareTo(obj.classname); + return uniqueName.compareTo(obj.uniqueName); } /** @@ -1205,6 +1208,14 @@ public boolean equals(Object obj) { // FIXME need to find to reduce code lines return true; } + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + public String getClassname() { return classname; } @@ -1214,10 +1225,19 @@ public String getClassname() { * @param classname String the given class name */ public void setClassname(String classname) { - fireClassNameChanged(classname); + //fireClassNameChanged(classname); this.classname = classname; } + public String getUniqueName() { + return uniqueName; + } + + public void setUniqueName(String uniqueName) { + fireClassNameChanged(uniqueName); + this.uniqueName = uniqueName; + } + public String getType() { return type; } @@ -1226,14 +1246,6 @@ public void setType(String type) { this.type = type; } - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - public String getVirtual() { return virtual; } @@ -1308,7 +1320,7 @@ public List getLocalClassAttributes() { } List list = new ArrayList(); for (DBAttribute classAttribute : classAttributes) { - if (classAttribute.getInherit().equals(this.getClassname())) { + if (classAttribute.getInherit().equals(this.getUniqueName())) { list.add(classAttribute); } } @@ -1327,7 +1339,7 @@ public List getLocalAttributes() { } List list = new ArrayList(); for (DBAttribute attribute : attributes) { - if (attribute.getInherit().equals(this.getClassname())) { + if (attribute.getInherit().equals(this.getUniqueName())) { list.add(attribute); } } @@ -1346,7 +1358,7 @@ public List getInheritClassAttributes() { } List list = new ArrayList(); for (DBAttribute classAttribute : classAttributes) { - if (!classAttribute.getInherit().equals(this.getClassname())) { + if (!classAttribute.getInherit().equals(this.getUniqueName())) { list.add(classAttribute); } } @@ -1365,7 +1377,7 @@ public List getInheritAttributes() { } List list = new ArrayList(); for (DBAttribute attribute : attributes) { - if (!attribute.getInherit().equals(this.getClassname())) { + if (!attribute.getInherit().equals(this.getUniqueName())) { list.add(attribute); } } diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SerialInfo.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SerialInfo.java index 6f7986b0..c785d48f 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SerialInfo.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/SerialInfo.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import com.cubrid.common.core.util.LogUtil; +import com.cubrid.common.core.util.QuerySyntax; /** * @@ -408,4 +409,22 @@ public void setDescription(String description) { public String getDescription() { return description; } + + public String getUniqueName(boolean isSupportUserSchema) { + if (isSupportUserSchema) { + if (owner != null || !owner.isEmpty()) { + return owner + "." + name; + } + } + return name; + } + + public String getUniqueNameEscapeKeyword(boolean isSupportUserSchema) { + if (isSupportUserSchema) { + if (owner != null || !owner.isEmpty()) { + return QuerySyntax.escapeKeyword(owner) + "." + QuerySyntax.escapeKeyword(name); + } + } + return QuerySyntax.escapeKeyword(name); + } } diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/Trigger.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/Trigger.java index f12c6260..1dbcd0ed 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/Trigger.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/Trigger.java @@ -66,6 +66,7 @@ public class Trigger implements Comparable { // FIXME use javadoc style comment such as /** ~ */ for all methods // trigger name private String name; + private String owner; // the time to evaluate trigger condition: before,after,deferred private String conditionTime; // 8 types: insert,update,delete(statement @@ -125,6 +126,14 @@ public void setName(String name) { this.name = name; } + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + public String getConditionTime() { return conditionTime; } diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/ViewDetailInfo.java b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/ViewDetailInfo.java index 23c75789..a5408fc4 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/common/model/ViewDetailInfo.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/common/model/ViewDetailInfo.java @@ -70,4 +70,13 @@ public String getViewOwnerName() { public void setViewOwnerName(String viewOwnerName) { this.viewOwnerName = viewOwnerName; } + + public String getViewUniqueName(boolean isSupportUserSchema) { + if (isSupportUserSchema) { + if (viewOwnerName != null && !viewOwnerName.isEmpty()) { + return viewOwnerName + "." + viewName; + } + } + return viewName; + } } diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/schemacomment/SchemaCommentHandler.java b/com.cubrid.common.core/src/com/cubrid/common/core/schemacomment/SchemaCommentHandler.java index 52695237..d22b0343 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/schemacomment/SchemaCommentHandler.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/schemacomment/SchemaCommentHandler.java @@ -33,6 +33,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.slf4j.Logger; @@ -171,10 +172,18 @@ public static boolean installMetaTable(IDatabaseSpec dbSpec, Connection conn) { return true; } - private static SchemaComment resultToMetaDesc(ResultSet rs) + private static SchemaComment resultToMetaDesc(ResultSet rs, boolean isSupportUserSchema) throws SQLException { SchemaComment meta = new SchemaComment(); - meta.setTable(rs.getString("table_name")); + String className = rs.getString("table_name"); + String tableName; + if (isSupportUserSchema) { + String ownerName = rs.getString("owner"); + tableName = ownerName + "." + className; + } else { + tableName = className; + } + meta.setTable(tableName); String columnName = rs.getString("column_name"); if (StringUtil.isEqual(columnName, "*")) { columnName = null; @@ -184,18 +193,18 @@ private static SchemaComment resultToMetaDesc(ResultSet rs) return meta; } - public static Map loadDescriptions(IDatabaseSpec dbSpec, Connection conn) + public static Map loadDescriptions(IDatabaseSpec dbSpec, Connection conn, boolean isSupportUserSchema) throws SQLException { - return loadDescription(dbSpec, conn, null); + return loadDescription(dbSpec, conn, isSupportUserSchema, null); } - public static Map loadTableDescriptions(IDatabaseSpec dbSpec, Connection conn) + public static Map loadTableDescriptions(IDatabaseSpec dbSpec, Connection conn, boolean isSupportUserSchema) throws SQLException { boolean isSupportInEngine = CompatibleUtil.isCommentSupports(dbSpec); String sql = null; if(isSupportInEngine) { - sql = "SELECT class_name as table_name, null as column_name, comment as description " + sql = "SELECT owner_name as owner, class_name as table_name, null as column_name, comment as description " + "FROM db_class " + "WHERE is_system_class='NO'"; } else { @@ -222,7 +231,7 @@ public static Map loadTableDescriptions(IDatabaseSpec dbS stmt = conn.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { - SchemaComment meta = resultToMetaDesc(rs); + SchemaComment meta = resultToMetaDesc(rs, isSupportUserSchema); results.put(meta.getId(), meta); } } catch (SQLException e) { @@ -237,22 +246,36 @@ public static Map loadTableDescriptions(IDatabaseSpec dbS } public static Map loadDescription(IDatabaseSpec dbSpec, - Connection conn, String tableName) throws SQLException { + Connection conn, boolean isSupportUserSchema, String tableName) throws SQLException { boolean isSupportInEngine = CompatibleUtil.isCommentSupports(dbSpec); String sql = null; String tableCondition = null; String columnCondition = null; if (isSupportInEngine) { - sql = "SELECT class_name as table_name, null as column_name, comment as description " - + "FROM db_class " - + "WHERE is_system_class='NO' %s" - + "UNION ALL " - + "SELECT class_name as table_name, attr_name as column_name, comment as description " - + "FROM db_attribute %s"; + if (isSupportUserSchema) { + sql = "SELECT owner_name as owner, class_name as table_name, null as column_name, comment as description " + + "FROM db_class " + + "WHERE is_system_class='NO' %s" + + "UNION ALL " + + "SELECT owner_name as owner, class_name as table_name, attr_name as column_name, comment as description " + + "FROM db_attribute %s"; + } else { + sql = "SELECT class_name as table_name, null as column_name, comment as description " + + "FROM db_class " + + "WHERE is_system_class='NO' %s" + + "UNION ALL " + + "SELECT class_name as table_name, attr_name as column_name, comment as description " + + "FROM db_attribute %s"; + } if (StringUtil.isNotEmpty(tableName)) { - tableCondition = "AND class_name = '" + tableName + "' "; - columnCondition = "WHERE class_name = '" + tableName + "'"; + if (isSupportUserSchema) { + tableCondition = "AND CONCAT(owner_name, '.' ,class_name)='" + tableName + "' "; + columnCondition = "WHERE CONCAT(owner_name, '.' ,class_name) = '" + tableName + "'"; + } else { + tableCondition = "AND class_name = '" + tableName + "' "; + columnCondition = "WHERE class_name = '" + tableName + "'"; + } } else { tableCondition = "AND comment is not null "; columnCondition = "WHERE comment is not null"; @@ -280,7 +303,7 @@ public static Map loadDescription(IDatabaseSpec dbSpec, stmt = conn.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { - SchemaComment meta = resultToMetaDesc(rs); + SchemaComment meta = resultToMetaDesc(rs, isSupportUserSchema); results.put(meta.getId(), meta); } } catch (SQLException e) { @@ -295,45 +318,85 @@ public static Map loadDescription(IDatabaseSpec dbSpec, } public static SchemaComment loadObjectDescription(IDatabaseSpec dbSpec, - Connection conn, String objName, CommentType type) throws SQLException { + Connection conn, boolean isSupportUserschema, String objName, CommentType type) throws SQLException { String sql = null; - - switch (type) { - case INDEX: - sql = "SELECT index_name, comment " + - "FROM db_index " + - "WHERE index_name = ?"; - break; - case VIEW: - sql = "SELECT vclass_name, comment " + - "FROM db_vclass " + - "WHERE vclass_name = ?"; - break; - case SP: - sql = "SELECT sp_name, comment " + - "FROM db_stored_procedure " + - "WHERE sp_name = ?"; - break; - case TRIGGER: - sql = "SELECT name, comment " + - "FROM db_trigger " + - "WHERE name = ?"; - break; - case SERIAL: - sql = "SELECT name, comment " + - "FROM db_serial " + - "WHERE name = ?"; - break; - case USER: - sql = "SELECT name, comment " + - "FROM db_user " + - "WHERE name = ?"; - break; - case PARTITION: - sql = "SELECT partition_name, comment " + - "FROM db_partition " + - "WHERE partition_name = ?"; - break; + + if (isSupportUserschema) { + switch (type) { + case INDEX: + sql = "SELECT index_name, comment " + + "FROM db_index " + + "WHERE CONCAT(owner_name, '.', index_name) = ?"; + break; + case VIEW: + sql = "SELECT vclass_name, comment " + + "FROM db_vclass " + + "WHERE CONCAT(owner_name, '.', vclass_name) = ?"; + break; + case SP: + sql = "SELECT sp_name, comment " + + "FROM db_stored_procedure " + + "WHERE sp_name = ?"; + break; + case TRIGGER: + sql = "SELECT trigger_name, comment " + + "FROM db_trig " + + "WHERE LOWER(CONCAT(owner_name , '.' , trigger_name))=?"; + break; + case SERIAL: + sql = "SELECT name, comment " + + "FROM db_serial " + + "WHERE CONCAT(owner.name, '.' , name) = ?"; + break; + case USER: + sql = "SELECT name, comment " + + "FROM db_user " + + "WHERE name = ?"; + break; + case PARTITION: + sql = "SELECT partition_name, comment " + + "FROM db_partition " + + "WHERE CONCAT(owner_name, '.', partition_name) = ?"; + break; + } + } else { + switch (type) { + case INDEX: + sql = "SELECT index_name, comment " + + "FROM db_index " + + "WHERE index_name = ?"; + break; + case VIEW: + sql = "SELECT vclass_name, comment " + + "FROM db_vclass " + + "WHERE vclass_name = ?"; + break; + case SP: + sql = "SELECT sp_name, comment " + + "FROM db_stored_procedure " + + "WHERE sp_name = ?"; + break; + case TRIGGER: + sql = "SELECT name, comment " + + "FROM db_trigger " + + "WHERE name = ?"; + break; + case SERIAL: + sql = "SELECT name, comment " + + "FROM db_serial " + + "WHERE name = ?"; + break; + case USER: + sql = "SELECT name, comment " + + "FROM db_user " + + "WHERE name = ?"; + break; + case PARTITION: + sql = "SELECT partition_name, comment " + + "FROM db_partition " + + "WHERE partition_name = ?"; + break; + } } // [TOOLS-2425]Support shard broker @@ -348,7 +411,11 @@ public static SchemaComment loadObjectDescription(IDatabaseSpec dbSpec, try { pstmt = conn.prepareStatement(sql); - pstmt.setString(1, objName); + if (type == CommentType.TRIGGER) { + pstmt.setString(1, objName.toLowerCase(Locale.getDefault())); + } else { + pstmt.setString(1, objName); + } rs = pstmt.executeQuery(); if (rs.next()) { schemaComment = new SchemaComment(); @@ -527,7 +594,7 @@ public static void bindSchemaInfo(Map comments, SchemaInf return; } - String tableName = schema.getClassname(); + String tableName = schema.getUniqueName(); SchemaComment cmt = find(comments, tableName, null); if (cmt != null) { schema.setDescription(cmt.getDescription()); diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/util/CompatibleUtil.java b/com.cubrid.common.core/src/com/cubrid/common/core/util/CompatibleUtil.java index ac0df9bc..ebb454f1 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/util/CompatibleUtil.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/util/CompatibleUtil.java @@ -60,8 +60,7 @@ public final class CompatibleUtil { private static final String VER_10_2_1 = "10.2.1"; private static final String VER_11_0_0 = "11.0.0"; private static final String VER_11_0_1 = "11.0.1"; - private static final String VER_11_2_0 = - "11.2.0"; // From 11.2 version, the engine and jdbc versioning are different. + private static final String VER_11_2_0 = "11.2.0"; // From 11.2 version, the engine and jdbc versioning are different. private CompatibleUtil() {} @@ -368,6 +367,16 @@ public static boolean isAfter100(IDatabaseSpec database) { return compareVersion(database.getVersion(), VER_10_0_0) >= 0; } + /** + * Is the version of database after the 10.2.0 + * + * @param database IDatabaseSpec + * @return true:10.2.0 or higher + */ + public static boolean isAfter1020(IDatabaseSpec database) { + return compareVersion(database.getVersion(), VER_10_2_0) >= 0; + } + /** * Is the version of database after the 10.2.1 * @@ -388,6 +397,16 @@ public static boolean isAfter1101(IServerSpec serverInfo) { return compareVersion(serverInfo.getServerVersionKey(), VER_11_0_1) >= 0; } + /** + * Is the version of database after the 11.2.0 + * + * @param database IDatabaseSpec + * @return true:11.2.0 or higher + */ + public static boolean isAfter112(IDatabaseSpec database) { + return compareVersion(database.getVersion(), VER_11_2_0) >= 0; + } + /** * Is the version of database after the 11.2.0 * @@ -981,10 +1000,6 @@ public static boolean isSupportEnableAccessControl(IServerSpec serverInfo) { return false; } - if (isAfter1101(serverInfo)) { - return false; - } - return isAfter840(serverInfo); } diff --git a/com.cubrid.common.core/src/com/cubrid/common/core/util/QueryUtil.java b/com.cubrid.common.core/src/com/cubrid/common/core/util/QueryUtil.java index b0811b4b..f8dd24f7 100644 --- a/com.cubrid.common.core/src/com/cubrid/common/core/util/QueryUtil.java +++ b/com.cubrid.common.core/src/com/cubrid/common/core/util/QueryUtil.java @@ -639,9 +639,9 @@ public static String extractBindParameterName(String bindParameter) { return m.group(2); } - public static String getSelectSQL(Connection conn, String name) { + public static String getSelectSQL(Connection conn, String name, boolean isSupportUserSchema) { String sql = null; - List columnList = getColumnList(conn, name); + List columnList = getColumnList(conn, name, isSupportUserSchema); StringBuilder columns = new StringBuilder(); int size = columnList.size(); for (int i = 0; i < columnList.size(); i++) { @@ -654,11 +654,17 @@ public static String getSelectSQL(Connection conn, String name) { return sql; } - private static List getColumnList(Connection conn, String tableName) { + private static List getColumnList(Connection conn, String tableName, boolean isSupportUserSchema) { List columnList = new ArrayList(); PreparedStatement pstmt = null; ResultSet rs = null; - String sql = "SELECT attr_name FROM db_attribute WHERE class_name = ? ORDER BY def_order"; + + String sql; + if (isSupportUserSchema) { + sql = "SELECT attr_name FROM db_attribute WHERE CONCAT(owner_name, '.' + class_name) = ? ORDER BY def_order"; + } else { + sql = "SELECT attr_name FROM db_attribute WHERE class_name = ? ORDER BY def_order"; + } try { pstmt = conn.prepareStatement(sql); @@ -676,10 +682,17 @@ private static List getColumnList(Connection conn, String tableName) { return columnList; } - public static List getPrimaryKeys(Connection conn, String tableName) { - String sql = "SELECT key_attr_name " + + public static List getPrimaryKeys(Connection conn, String tableName, boolean isSupportUserSchema) { + String sql; + if (isSupportUserSchema) { + sql = "SELECT key_attr_name " + "FROM db_index_key " + - "WHERE class_name= ? AND index_name = 'pk'"; + "WHERE CONCAT(owner_name, '.' , class_name)= ? AND index_name = 'pk'"; + } else { + sql = "SELECT key_attr_name " + + "FROM db_index_key " + + "WHERE class_name= ? AND index_name = 'pk'"; + } PreparedStatement pstmt = null; ResultSet rs = null; List pkColumns = new ArrayList(); @@ -716,7 +729,7 @@ public static boolean isStringDataType(String type) { public static String getColumnDescSql(Connection con, String tableName, String columnName) { StringBuilder sql = new StringBuilder(); - sql.append("SHOW CREATE TABLE " + tableName); + sql.append("SHOW CREATE TABLE " + QuerySyntax.escapeKeyword(tableName)); PreparedStatement pstmt = null; ResultSet rs = null; @@ -725,10 +738,11 @@ public static String getColumnDescSql(Connection con, String tableName, rs = pstmt.executeQuery(); sql.setLength(0); - sql.append("ALTER TABLE " + tableName + " MODIFY "); + sql.append("ALTER TABLE " + QuerySyntax.escapeKeyword(tableName) + " MODIFY "); if (rs.next()) { - sql.append(parseColumnDefinition(rs.getString(2), columnName)); + String temp = rs.getString(2); + sql.append(parseColumnDefinition(temp, columnName)); } } catch (SQLException e) { LOGGER.error(e.getLocalizedMessage()); @@ -766,10 +780,11 @@ private static String parseColumnDefinition(String createSql, String columnName) * @param SerialInfo serial * @param DatabaseInfo databaseInfo */ - public static String createSerialSQLScript(SerialInfo serial, boolean isSupportCache) { + public static String createSerialSQLScript(SerialInfo serial, boolean isSupportCache, boolean isSupportUserSchema) { StringBuilder sql = new StringBuilder(); - sql.append("CREATE SERIAL "); - sql.append(QuerySyntax.escapeKeyword(serial.getName())); + sql.append("CREATE SERIAL "); + sql.append(QuerySyntax.escapeKeyword(serial.getUniqueNameEscapeKeyword(isSupportUserSchema))); + String startVal = serial.getStartedValue(); String currentVal = serial.getCurrentValue(); String minVal = serial.getMinValue(); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/common/navigator/CubridColumnNavigatorView.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/common/navigator/CubridColumnNavigatorView.java index a8c6fe4c..1b0b5216 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/common/navigator/CubridColumnNavigatorView.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/common/navigator/CubridColumnNavigatorView.java @@ -213,7 +213,7 @@ public void updateView(DatabaseInfo databaseInfo, SchemaInfo schemaInfo) { cleanView(); } if (schemaInfo != null) { - this.schemaName = schemaInfo.getClassname(); + this.schemaName = schemaInfo.getUniqueName(); } redrawView(databaseInfo, schemaInfo); } @@ -228,9 +228,9 @@ public void cleanView() { } private void redrawView(DatabaseInfo databaseInfo, SchemaInfo schemaInfo) { - if (schemaInfo != null && schemaInfo.getClassname() != null) { + if (schemaInfo != null && schemaInfo.getUniqueName() != null) { String msg = com.cubrid.common.ui.common.Messages.lblQuickViewColInfo + " " - + schemaInfo.getClassname(); + + schemaInfo.getUniqueName(); lblSchemaName.setText(msg); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareDetailEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareDetailEditorPart.java index d0558519..d6be40cf 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareDetailEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareDetailEditorPart.java @@ -107,7 +107,7 @@ private void createTopPanel(Composite parent) { String srcDb = compInput.getSourceDB().getDbName() + "@" + compInput.getSourceDB().getBrokerIP(); String tgtDb = compInput.getTargetDB().getDbName() + "@" + compInput.getTargetDB().getBrokerIP(); - String statusText = Messages.bind(Messages.msgStatusText, new String[] {compInput.getSourceSchemaInfo().getClassname(), srcDb, tgtDb}); + String statusText = Messages.bind(Messages.msgStatusText, new String[] {compInput.getSourceSchemaInfo().getUniqueName(), srcDb, tgtDb}); Label lblStatus = new Label(left, SWT.NONE); lblStatus.setText(statusText); @@ -300,7 +300,7 @@ private boolean loadData(int beginPage) { // FIXME logic code move to core modul private void fetchData(Connection conn, CompareViewData obj, SchemaInfo schemaInfo, List pkColumns, List pkTypes, boolean isSource) { // FIXME logic code move to core module StringBuilder sql = new StringBuilder(); - sql.append(SQLGenerateUtils.getSelectSQLNoWhere(schemaInfo.getClassname(), schemaInfo.getAttributes(), false)); + sql.append(SQLGenerateUtils.getSelectSQLNoWhere(schemaInfo.getUniqueName(), schemaInfo.getAttributes(), false)); sql.append(" WHERE "); for (int i = 0; i < pkColumns.size(); i++) { String columnName = pkColumns.get(i); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareEditorPart.java index 20a7ee70..9151958b 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/data/control/DataCompareEditorPart.java @@ -987,7 +987,7 @@ private List fetchHashedCompareData(Connection conn, SchemaIn sql.append(extraColumns); } - String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); sql.append(" FROM ").append(escapedTableName); sql.append(" ORDER BY ").append(pkColumns); sql.append(" FOR ORDERBY_NUM() BETWEEN ").append(start + 1); @@ -1067,7 +1067,7 @@ private void compareHashedCompareData(Connection conn, DataCompare dataCompare, StringBuilder extraColumns = new StringBuilder(); StringBuilder sql = new StringBuilder(); - sql.append("SELECT MD5(CONCAT("); + sql.append("SELECT MD5("); StringBuilder cols = new StringBuilder(); List attrs = schemaInfo.getAttributes(); @@ -1077,21 +1077,21 @@ private void compareHashedCompareData(Connection conn, DataCompare dataCompare, DBAttribute attr = attrs.get(i); if (cols.length() > 0) { - cols.append(","); + cols.append(" || "); } makeColumnsClause(extraColumns, cols, attr); } sql.append(cols); - sql.append(")) AS _record_hash_ "); + sql.append(") AS _record_hash_ "); if (extraColumns.length() > 0) { sql.append(","); sql.append(extraColumns); } - String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); sql.append(" FROM ").append(escapedTableName); sql.append(" WHERE "); { @@ -1139,13 +1139,13 @@ private void compareHashedCompareData(Connection conn, DataCompare dataCompare, if (!exists) { dataCompare.increaseNotExists(); - addLog(schemaInfo.getClassname(), data, charset); + addLog(schemaInfo.getUniqueName(), data, charset); } else { if (data.getHash().equals(hash)) { dataCompare.increaseMatches(); } else { dataCompare.increaseNotMatches(); - addLog(schemaInfo.getClassname(), data, charset); + addLog(schemaInfo.getUniqueName(), data, charset); } } @@ -1176,7 +1176,7 @@ private List fetchHashedCompareDataCompatible(Connection conn } } - String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); StringBuilder sql = new StringBuilder(); sql.append(" SELECT * FROM ").append(escapedTableName); sql.append(" ORDER BY ").append(pkColumns); @@ -1249,7 +1249,7 @@ private void compareHashedCompareDataCompatible(Connection conn, DataCompare dat ResultSet rs = null; SchemaInfo schemaInfo = dataCompare.getSchemaInfo(); - String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); StringBuilder sql = new StringBuilder(); sql.append(" SELECT * FROM ").append(escapedTableName); @@ -1322,13 +1322,13 @@ private void compareHashedCompareDataCompatible(Connection conn, DataCompare dat if (!exists) { dataCompare.increaseNotExists(); - addLog(schemaInfo.getClassname(), data, charset); + addLog(schemaInfo.getUniqueName(), data, charset); } else { if (data.getHash().equals(StringUtil.md5(hash.toString()))) { dataCompare.increaseMatches(); } else { dataCompare.increaseNotMatches(); - addLog(schemaInfo.getClassname(), data, charset); + addLog(schemaInfo.getUniqueName(), data, charset); } } @@ -1587,10 +1587,10 @@ private void doRefresh(boolean collectRecordCount) { // FIXME logic code move to } } for (SchemaInfo schemaInfo : sourceList) { - DataCompare dataCompare = dataCompareMap.get(schemaInfo.getClassname()); + DataCompare dataCompare = dataCompareMap.get(schemaInfo.getUniqueName()); if (dataCompare == null) { dataCompare = new DataCompare(); - dataCompare.setTableName(schemaInfo.getClassname()); + dataCompare.setTableName(schemaInfo.getUniqueName()); dataCompare.setSchemaInfo(schemaInfo); dataCompare.setRefreshed(false); } else { @@ -1600,9 +1600,9 @@ private void doRefresh(boolean collectRecordCount) { // FIXME logic code move to dataCompare.setProgressPosition(0); } - if (schemaInfo.hasPK() && !partitions.contains(schemaInfo.getClassname())) { + if (schemaInfo.hasPK() && !partitions.contains(schemaInfo.getUniqueName())) { SchemaInfo targetSchemeInfo = getSchemeInfoByName( - schemaInfo.getClassname(), targetList); + schemaInfo.getUniqueName(), targetList); boolean isSameSchema = canCompareData(schemaInfo, targetSchemeInfo); dataCompare.setSameSchema(isSameSchema); compareList.add(dataCompare); @@ -1638,7 +1638,7 @@ public int compare(DataCompare o1, DataCompare o2) { private SchemaInfo getSchemeInfoByName(String name, List list) { for (SchemaInfo s : list) { - if (StringUtil.isEqual(name, s.getClassname())) { + if (StringUtil.isEqual(name, s.getUniqueName())) { return s; } } @@ -1891,7 +1891,7 @@ public void setOffline(boolean offline) { public void showDataCompareDetailEditor(SchemaInfo schemaInfo) { try { - String hashedTableName = StringUtil.md5(schemaInfo.getClassname()); + String hashedTableName = StringUtil.md5(schemaInfo.getUniqueName()); String path = logFileBasePath + File.separatorChar + logFileBaseName + "_" + hashedTableName + ".compared"; DataCompareDetailEditorInput input = new DataCompareDetailEditorInput(getSourceDB(), diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaComparator.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaComparator.java index 35889c25..283ca2ca 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaComparator.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaComparator.java @@ -155,7 +155,7 @@ private List compareTableSchema( while (leftkeys.hasNext()) { compareStatus = TableSchemaCompareModel.SCHEMA_EQUAL; - String key = (String) leftkeys.next().toLowerCase(); + String key = (String) leftkeys.next(); TableSchema lTableSchema = leftTableSchema.get(key); TableDetailInfo lTableDetail = leftTableDetail.get(key); @@ -181,8 +181,8 @@ private List compareTableSchema( rTableSchema = new TableSchema(null, null); compareStatus = TableSchemaCompareModel.SCHEMA_TMISS; } else { - String left = lTableSchema.getName().toLowerCase(); - String right = rTableSchema.getName().toLowerCase(); + String left = lTableSchema.getName(); + String right = rTableSchema.getName(); if (valueEqual(left, right)) { // TODO refactoring boolean compScheInfo = compareSchemaInfo(sourceDBInfo, targetDBInfo, sourceSchemaDDL, targetSchemaDDL, lTableSchema, rTableSchema); @@ -215,10 +215,10 @@ private List compareTableSchema( TableSchema lTableSchema = leftTableSchema.get(key); TableDetailInfo lTableDetail = leftTableDetail.get(key); - if (!duplicateNameMap.containsKey(key.toLowerCase() + RIGHT_PATTERN)) { - duplicateNameMap.put(key.toLowerCase() + RIGHT_PATTERN, new ArrayList()); + if (!duplicateNameMap.containsKey(key + RIGHT_PATTERN)) { + duplicateNameMap.put(key + RIGHT_PATTERN, new ArrayList()); } - duplicateNameMap.get(key.toLowerCase() + RIGHT_PATTERN).add(key); + duplicateNameMap.get(key + RIGHT_PATTERN).add(key); TableSchema rTableSchema = rightTableSchema.get(key); TableDetailInfo rTableDetail = rightTableDetail.get(key); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaCompareUtil.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaCompareUtil.java index 58f0a391..25fc427f 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaCompareUtil.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/TableSchemaCompareUtil.java @@ -128,6 +128,7 @@ public static List getTableInfoList(CubridDatabase db) { // FIX if (tableNameSet != null) { List tableNames = new ArrayList(); for (String tableName : tableNameSet) { + tableNames.add(tableName); } @@ -136,6 +137,7 @@ public static List getTableInfoList(CubridDatabase db) { // FIX for (String tableName : tableNames) { TableDetailInfo info = map.get(tableName); String classType = info.getClassType(); + if (classType.equals("CLASS") || classType.equals("VCLASS")) { info.setRecordsCount(-1); tableList.add(info); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/control/TableSchemaCompareInfoPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/control/TableSchemaCompareInfoPart.java index 0b31a0fa..31075118 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/control/TableSchemaCompareInfoPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/control/TableSchemaCompareInfoPart.java @@ -259,7 +259,7 @@ public void execute(IProgressMonitor monitor) { Map target = compareModel.getTargetSchemas(); List commonTables = new LinkedList(); for (SchemaInfo sourceTable : source.values()) { - if (target.containsKey(sourceTable.getClassname())) { + if (target.containsKey(sourceTable.getUniqueName())) { commonTables.add(sourceTable); } } @@ -653,7 +653,7 @@ private String getDBSchema(CubridDatabase db, Map schemaInfo Set commonNames = new HashSet(); for (SchemaInfo table : commonTables) { - commonNames.add(table.getClassname()); + commonNames.add(table.getUniqueName()); } StringBuilder buf = new StringBuilder(); @@ -685,7 +685,7 @@ private String getDBSchema(CubridDatabase db, Map schemaInfo addSchemaDDL(buf, schemaDDL, schemaInfo, true, true); } for (SchemaInfo si : tables) { - if (commonNames.contains(si.getClassname())) { + if (commonNames.contains(si.getUniqueName())) { continue; } addSchemaDDL(buf, schemaDDL, si, true, true); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/model/TableSchemaCompareUpdateDDL.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/model/TableSchemaCompareUpdateDDL.java index 2a3318ca..e49bfa93 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/model/TableSchemaCompareUpdateDDL.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/compare/schema/model/TableSchemaCompareUpdateDDL.java @@ -77,7 +77,7 @@ public String getTableSchemaAlterDDL() { // FIXME logic code move to core module if (sourceTableSchema == null) { alterDDL = targetSchemaDDL.getSchemaDDL(targetTableSchema); } else if (targetTableSchema == null) { - String escapedTableName = QuerySyntax.escapeKeyword(sourceTableSchema.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(sourceTableSchema.getUniqueName()); alterDDL = "DROP TABLE " + escapedTableName + ";" + StringUtil.NEWLINE; } else { setClassNameAlterDDL(); @@ -95,8 +95,8 @@ public String getTableSchemaAlterDDL() { // FIXME logic code move to core module * Compare table class name */ public void setClassNameAlterDDL() { // FIXME logic code move to core module - String sourceClassName = sourceTableSchema.getClassname(); - String targetClassName = targetTableSchema.getClassname(); + String sourceClassName = sourceTableSchema.getUniqueName(); + String targetClassName = targetTableSchema.getUniqueName(); if (!sourceClassName.toLowerCase().equals(targetClassName.toLowerCase())) { changeManager.addSchemeChangeLog(new SchemaChangeLog( @@ -160,16 +160,16 @@ public void setIndexAlterDDL() { // FIXME logic code move to core module if (sourceCons != null) { if (!targetCons.equals(sourceCons)) { changeManager.addSchemeChangeLog(new SchemaChangeLog( - sourceCons.getDefaultName(sourceTableSchema.getClassname()) + sourceCons.getDefaultName(sourceTableSchema.getUniqueName()) + "$" + sourceCons.getName(), - targetCons.getDefaultName(targetTableSchema.getClassname()) + targetCons.getDefaultName(targetTableSchema.getUniqueName()) + "$" + targetCons.getName(), SchemeInnerType.TYPE_INDEX)); } } else { changeManager.addSchemeChangeLog(new SchemaChangeLog( null, - targetCons.getDefaultName(targetTableSchema.getClassname()) + targetCons.getDefaultName(targetTableSchema.getUniqueName()) + "$" + targetCons.getName(), SchemeInnerType.TYPE_INDEX)); } @@ -184,7 +184,7 @@ public void setIndexAlterDDL() { // FIXME logic code move to core module && (sourceCons.getType().equals(Constraint.ConstraintType.INDEX.getText()) || sourceCons.getType().equals(Constraint.ConstraintType.UNIQUE.getText()))) { changeManager.addSchemeChangeLog(new SchemaChangeLog( - sourceCons.getDefaultName(sourceTableSchema.getClassname()) + sourceCons.getDefaultName(sourceTableSchema.getUniqueName()) + "$" + sourceCons.getName(), null, SchemeInnerType.TYPE_INDEX)); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/ERXmlContainer.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/ERXmlContainer.java index c670f084..a9d0c406 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/ERXmlContainer.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/ERXmlContainer.java @@ -295,7 +295,7 @@ private void createSchemaInfo() { for (String tableName : tableSchemas.keySet()) { ERWinSchemaInfo schemaInfo = new ERWinSchemaInfo(); schemaInfo.setType("user"); - schemaInfo.setClassname(tableName); + schemaInfo.setUniqueName(tableName); schemaInfos.put(tableName, schemaInfo); } @@ -329,7 +329,7 @@ private void createSchemaDDL() { Collection erwinSchemas = schemaInfos.values(); for (ERWinSchemaInfo erwinSchema : erwinSchemas) { SchemaInfo schemaInfo = (SchemaInfo) erwinSchema; - dbSchemaInfos.put(schemaInfo.getClassname(), schemaInfo); + dbSchemaInfos.put(schemaInfo.getUniqueName(), schemaInfo); } wrappedDatabaseInfo.addSchemaInfos(dbSchemaInfos); wrappedDatabaseInfo.addTableSchemas(tableSchemas); @@ -354,7 +354,7 @@ private void createSchemaDDL() { } private String createViewSchema(SchemaInfo schemaInfo) { - ViewModel model = viewModelMap.get(schemaInfo.getClassname()); + ViewModel model = viewModelMap.get(schemaInfo.getUniqueName()); if (model != null) { return model.returnViewDDL(); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/action/ImportERwinAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/action/ImportERwinAction.java index ea305600..3188061d 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/action/ImportERwinAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/action/ImportERwinAction.java @@ -187,7 +187,7 @@ public void execute(IProgressMonitor monitor) { Collection erwinSchemas = schemaInfos.values(); for (ERWinSchemaInfo erwinSchema : erwinSchemas) { SchemaInfo schemaInfo = (SchemaInfo) erwinSchema; - dbSchemaInfos.put(schemaInfo.getClassname(), schemaInfo); + dbSchemaInfos.put(schemaInfo.getUniqueName(), schemaInfo); } wrappedDatabaseInfo.addSchemaInfos(dbSchemaInfos); wrappedDatabaseInfo.addTableSchemas(tableSchema); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/task/ExportSchemaTask.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/task/ExportSchemaTask.java index 67c2fa1e..41f59c6a 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/task/ExportSchemaTask.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/database/erwin/task/ExportSchemaTask.java @@ -352,7 +352,7 @@ public void execute() { // FIXME logic code move to core module continue; SchemaInfo schemaInfo = entry.getValue(); - Map schemaAttrMap = entityAttrMap.get(schemaInfo.getClassname()); + Map schemaAttrMap = entityAttrMap.get(schemaInfo.getUniqueName()); KeyGroupGroups keyGroups = new KeyGroupGroups(); entity.setKeyGroupGroups(keyGroups); @@ -417,7 +417,7 @@ public void execute() { // FIXME logic code move to core module if (pEntity == null) { continue; } - Map tempAttrMap = entityAttrMap.get(schemaInfo.getClassname()); + Map tempAttrMap = entityAttrMap.get(schemaInfo.getUniqueName()); Map parentAttrMap = entityAttrMap.get(inherit); Relationship relationShip = new Relationship(); @@ -486,7 +486,7 @@ public void execute() { // FIXME logic code move to core module relationShipPropsList.setRelationshipChildEntity(new RelationshipChildEntity()); relationShipPropsList.getRelationshipChildEntity().setValue( - entityMap.get(schemaInfo.getClassname()).getId()); + entityMap.get(schemaInfo.getUniqueName()).getId()); LinkedList pkAttr = new LinkedList(); SchemaInfo parentTable = allSchemaInfos.get(inherit); @@ -560,9 +560,15 @@ public void execute() { // FIXME logic code move to core module KeyGroupPosition position = new KeyGroupPosition(); propList.setKeyGroupPosition(position); position.setValue("" + order++); - + String AttrKeyName; KeyGroupMemberColumn column = new KeyGroupMemberColumn(); - Attribute attrTemp = schemaAttrMap.get(keyName); + if (keyName.indexOf("char_length") >= 0) { + AttrKeyName = keyName.substring( + keyName.lastIndexOf("[") + 1, keyName.lastIndexOf("]")); + } else { + AttrKeyName = keyName; + } + Attribute attrTemp = schemaAttrMap.get(AttrKeyName); column.setValue(attrTemp.getId()); propList.setKeyGroupMemberColumn(column); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.java index fd528807..07617fae 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.java @@ -65,11 +65,15 @@ public class Messages extends public static String errSerialName; public static String errSerialNameLength; public static String errStartValue; + public static String errStartValueAfter1020; public static String msgStartValue; public static String msgCurrentValue; public static String errIncrementValue; + public static String errIncrementValueAfter1020; public static String errMinValue; + public static String errMinValueAfter1020; public static String errMaxValue; + public static String errMaxValueAfter1020; public static String errSerialExist; public static String errValue; public static String errDiffValue; @@ -86,6 +90,7 @@ public class Messages extends //serial dashboard public static String serialsDetailInfoPartTitle; + public static String serialsDetailInfoPartTableOwnerCol; public static String serialsDetailInfoPartTableNameCol; public static String serialsDetailInfoPartTableCurValCol; public static String serialsDetailInfoPartTableIncreValCol; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.properties index 8e28b523..3a8e7e2e 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages.properties @@ -20,9 +20,13 @@ errSerialNameLength=The serial name's length should be less than {0}. msgStartValue=start msgCurrentValue=current errStartValue=The {0} value is not valid. It can only be an integer between -1.0e36 and 1.0e37. +errStartValueAfter1020=The {0} value is not valid. It can only be an integer between -1.0e37 and 1.0e38. errIncrementValue=The increment value is not valid. It can only be an integer between -1.0e36 and 1.0e37. +errIncrementValueAfter1020=The increment value is not valid. It can only be an integer between -1.0e37 and 1.0e38. errMinValue=The min value is not valid. It can only be an integer between -1.0e36 and 1.0e37. +errMinValueAfter1020=The min value is not valid. It can only be an integer between -1.0e37 and 1.0e38. errMaxValue=The max value is not valid. It can only be an integer between -1.0e36 and 1.0e37. +errMaxValueAfter1020=The max value is not valid. It can only be an integer between -1.0e37 and 1.0e38. errSerialExist=The serial already exists. errValue=The {0} value must be between MINVALUE value and MAXVALUE value. errDiffValue=The absolute value of the increment must be smaller than the difference between MAXVALUE and MINVALUE. @@ -39,6 +43,7 @@ errNameNotExist=This serial does not exist. serialsDetailInfoPartTitle=Serials +serialsDetailInfoPartTableOwnerCol=Owner serialsDetailInfoPartTableNameCol=Name serialsDetailInfoPartTableCurValCol=Current Value serialsDetailInfoPartTableIncreValCol=Increment Value diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages_ko_KR.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages_ko_KR.properties index 4de2ae22..ded17d7b 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages_ko_KR.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/Messages_ko_KR.properties @@ -20,9 +20,13 @@ errSerialNameLength=\uc2dc\ub9ac\uc5bc \uc774\ub984\uc758 \uae38\uc774\ub294 {0} msgStartValue=\uc2dc\uc791 msgCurrentValue=\ud604\uc7ac errStartValue={0} \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e36 ~ 1.0e37\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. +errStartValueAfter1020={0} \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e37 ~ 1.0e38\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. errIncrementValue=\uc99d\uac00 \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e36 ~ 1.0e37\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. +errIncrementValueAfter1020=\uc99d\uac00 \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e37 ~ 1.0e38\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. errMinValue=\ucd5c\uc18c \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e36 ~ 1.0e37\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. +errMinValueAfter1020=\ucd5c\uc18c \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e37 ~ 1.0e38\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. errMaxValue=\ucd5c\ub300 \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e36 ~ 1.0e37\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. +errMaxValueAfter1020=\ucd5c\ub300 \uac12\uc774 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc815\uc218 -1.0e37 ~ 1.0e38\uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. errSerialExist=\uc2dc\ub9ac\uc5bc\uc774 \uc774\ubbf8 \uc874\uc7ac\ud569\ub2c8\ub2e4. errValue={0} \uac12\uc740 \ubc18\ub4dc\uc2dc \ucd5c\uc18c \uac12\uacfc \ucd5c\ub300 \uac12 \uc0ac\uc774\uc758 \uac12\ub9cc \uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4. errDiffValue=\uc99d\uac00 \uac12\uc740 \ucd5c\ub300 \uac12\uacfc \ucd5c\uc18c \uac12\uc758 \ucc28\ubcf4\ub2e4 \uc791\uc544\uc57c \ud569\ub2c8\ub2e4. @@ -39,6 +43,7 @@ errNameNotExist=\ud574\ub2f9 \uc2dc\ub9ac\uc5bc\uc774 \uc874\uc7ac\ud558\uc9c0 \ serialsDetailInfoPartTitle=\uc2dc\ub9ac\uc5bc +serialsDetailInfoPartTableOwnerCol=\uc18c\uc720\uc790 serialsDetailInfoPartTableNameCol=\uc774\ub984 serialsDetailInfoPartTableCurValCol=\ud604\uc7ac \uac12 serialsDetailInfoPartTableIncreValCol=\uc99d\uac00 \uac12 diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/CreateSerialAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/CreateSerialAction.java index 8f4f391e..0d45f4c4 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/CreateSerialAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/CreateSerialAction.java @@ -150,11 +150,11 @@ public void run (CubridDatabase database) { Locale.getDefault()); DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo(); String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR - + serialName; + + userInfo.getName() + "." + serialName; SerialInfo serialInfo = new SerialInfo(); serialInfo.setName(serialName); serialInfo.setOwner(userInfo.getName()); - ICubridNode newNode = CubridSerialFolderLoader.createSerialNode(id, + ICubridNode newNode = CubridSerialFolderLoader.createSerialNode(database.getDatabaseInfo(), id, serialInfo); CommonUITool.addNodeToTree(treeViewer, folderNode, newNode); CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/DeleteSerialAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/DeleteSerialAction.java index c8ed46ce..a2c913bc 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/DeleteSerialAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/DeleteSerialAction.java @@ -148,9 +148,9 @@ public void run(ISchemaNode[] nodeArray) { } ISchemaNode schemaNode = (ISchemaNode) nodeArray[i]; if (i == 0) { - serialNames.append(schemaNode.getLabel()); + serialNames.append(schemaNode.getName()); } - serialNameList.add(schemaNode.getLabel()); + serialNameList.add(schemaNode.getName()); } if (nodeArray.length > 1) { serialNames.append(", ..."); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/EditSerialAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/EditSerialAction.java index ebd5653f..c45116f0 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/EditSerialAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/action/EditSerialAction.java @@ -142,7 +142,7 @@ public boolean exec(final IProgressMonitor monitor) { SerialInfo serialInfo = null; if (task instanceof GetSerialInfoTask) { GetSerialInfoTask getSerialInfoTask = (GetSerialInfoTask) task; - serialInfo = getSerialInfoTask.getSerialInfo(node.getLabel()); + serialInfo = getSerialInfoTask.getSerialInfo(node.getName()); } final String msg = task.getErrorMsg(); if (openErrorBox(shell, msg, monitor)) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/dialog/CreateOrEditSerialDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/dialog/CreateOrEditSerialDialog.java index cdd9eaa1..fbd5d543 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/dialog/CreateOrEditSerialDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/dialog/CreateOrEditSerialDialog.java @@ -94,9 +94,13 @@ public class CreateOrEditSerialDialog extends CMTitleAreaDialog implements Modif private String taskName; private CubridDatabase database; private boolean isEditAble; + private String ownerName = null; private String serialName; - private static final String SERIAL_MIN = "-1000000000000000000000000000000000000"; - private static final String SERIAL_MAX = "10000000000000000000000000000000000000"; + private static final String SERIAL_MIN = "-1000000000000000000000000000000000000"; + private static final String SERIAL_MIN_AFTER_120 = "-99999999999999999999999999999999999999"; + private static final String SERIAL_MAX = "10000000000000000000000000000000000000"; + private static final String SERIAL_MAX_AFTER_120 = "99999999999999999999999999999999999999"; + private boolean isCommentSupport = false; public CreateOrEditSerialDialog(Shell parentShell, boolean isEditAble) { @@ -194,7 +198,7 @@ private Composite createGeneralInfoComp() { startValLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1)); startValText = new Text(composite, SWT.LEFT | SWT.BORDER); - startValText.setTextLimit(38); + startValText.setTextLimit(getTextLimit()); startValText.setLayoutData(CommonUITool.createGridData( GridData.FILL_HORIZONTAL, 2, 1, -1, -1)); @@ -204,7 +208,7 @@ private Composite createGeneralInfoComp() { incrementValLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1)); incrementValText = new Text(composite, SWT.LEFT | SWT.BORDER); - incrementValText.setTextLimit(38); + incrementValText.setTextLimit(getTextLimit()); incrementValText.setLayoutData(CommonUITool.createGridData( GridData.FILL_HORIZONTAL, 2, 1, -1, -1)); @@ -213,7 +217,7 @@ private Composite createGeneralInfoComp() { minValLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1)); minValText = new Text(composite, SWT.LEFT | SWT.BORDER); - minValText.setTextLimit(38); + minValText.setTextLimit(getTextLimit()); minValText.setLayoutData(CommonUITool.createGridData( GridData.FILL_HORIZONTAL, 1, 1, -1, -1)); @@ -239,7 +243,7 @@ public void widgetSelected(SelectionEvent event) { maxValLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1)); maxValText = new Text(composite, SWT.LEFT | SWT.BORDER); - maxValText.setTextLimit(38); + maxValText.setTextLimit(getTextLimit()); maxValText.setLayoutData(CommonUITool.createGridData( GridData.FILL_HORIZONTAL, 1, 1, -1, -1)); @@ -334,21 +338,27 @@ private Composite createSqlScriptComposite() { */ private String getSQLScript() { // FIXME move this logic to core module StringBuffer sb = new StringBuffer(); + String serialName = serialNameText.getText(); + if (database.getDatabaseInfo().isSupportUserSchema()) { + if (ownerName != null && !ownerName.isEmpty()){ + serialName = QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(serialName); + } + } + serialName = QuerySyntax.escapeKeyword(serialName); + if (editedNode == null) { sb.append("CREATE").append(" SERIAL "); - String serialName = serialNameText.getText(); if (serialName.trim().length() == 0) { sb.append(""); } else { - sb.append(QuerySyntax.escapeKeyword(serialName)); + sb.append(serialName); } } else { sb.append("ALTER").append(" SERIAL "); - String serialName = serialNameText.getText(); if (serialName.trim().length() == 0) { sb.append(""); } else { - sb.append(QuerySyntax.escapeKeyword(serialName)); + sb.append(serialName); } } String startedValue = startValText.getText(); @@ -472,6 +482,7 @@ private void initialize() { if (serialInfo != null) { serialNameText.setEditable(false); serialNameText.setText(serialInfo.getName()); + ownerName = serialInfo.getOwner(); String description = serialInfo.getDescription(); if (isCommentSupport && StringUtil.isNotEmpty(description)) { serialDescriptionText.setText(description); @@ -480,19 +491,20 @@ private void initialize() { String incrValue = serialInfo.getIncrementValue(); incrementValText.setText(incrValue); String minValue = serialInfo.getMinValue(); - if (incrValue.indexOf("-") >= 0 && SERIAL_MIN.equals(minValue)) { + if (incrValue.indexOf("-") >= 0 && serialMinValue().equals(minValue)) { noMinValueBtn.setSelection(true); minValText.setEnabled(false); } else { minValText.setText(minValue); } String maxValue = serialInfo.getMaxValue(); - if (incrValue.indexOf("-") < 0 && SERIAL_MAX.equals(maxValue)) { + if (incrValue.indexOf("-") < 0 && serialMaxValue().equals(maxValue)) { noMaxValueBtn.setSelection(true); maxValText.setEnabled(false); } else { maxValText.setText(maxValue); } + if (isSupportCache) { String cacheCount = serialInfo.getCacheCount(); if (cacheCount == null @@ -565,11 +577,11 @@ public boolean exec(final IProgressMonitor monitor) { if (task instanceof CreateOrEditSerialTask) { CreateOrEditSerialTask createSerialTask = (CreateOrEditSerialTask) task; if (editedNode == null) { - createSerialTask.createSerial(serialName, startVal, + createSerialTask.createSerial(ownerName, serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache, description); } else { - createSerialTask.editSerial(serialName, startVal, + createSerialTask.editSerial(ownerName, serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache, description); } @@ -639,11 +651,19 @@ private void valid() { boolean isValidStartVal = verifyBigValue(startVal); if (!isValidStartVal) { if (editedNode == null) { - setErrorMessage(Messages.bind(Messages.errStartValue, Messages.msgStartValue)); + if (isChangeMaxMinValue()) { + setErrorMessage(Messages.bind(Messages.errStartValueAfter1020, Messages.msgStartValue)); + } else { + setErrorMessage(Messages.bind(Messages.errStartValue, Messages.msgStartValue)); + } setEnabled(false); return; } else { - setErrorMessage(Messages.bind(Messages.errStartValue, Messages.msgCurrentValue)); + if (isChangeMaxMinValue()) { + setErrorMessage(Messages.bind(Messages.errStartValueAfter1020, Messages.msgCurrentValue)); + } else { + setErrorMessage(Messages.bind(Messages.errStartValue, Messages.msgCurrentValue)); + } setEnabled(false); return; } @@ -651,7 +671,11 @@ private void valid() { boolean isValidIncrementVal = verifyBigValue(incrementVal); if (!isValidIncrementVal) { - setErrorMessage(Messages.errIncrementValue); + if (isChangeMaxMinValue()) { + setErrorMessage(Messages.errIncrementValueAfter1020); + } else { + setErrorMessage(Messages.errIncrementValue); + } setEnabled(false); return; } @@ -660,7 +684,11 @@ private void valid() { if (!isNoMinValue) { isValidMinVal = verifyBigValue(minVal); if (!isValidMinVal) { - setErrorMessage(Messages.errMinValue); + if (isChangeMaxMinValue()) { + setErrorMessage(Messages.errMinValueAfter1020); + } else { + setErrorMessage(Messages.errMinValue); + } setEnabled(false); return; } @@ -670,7 +698,11 @@ private void valid() { if (!isNoMaxValue) { isValidMaxVal = verifyBigValue(maxVal); if (!isValidMaxVal) { - setErrorMessage(Messages.errMaxValue); + if (isChangeMaxMinValue()) { + setErrorMessage(Messages.errMaxValueAfter1020); + } else { + setErrorMessage(Messages.errMaxValue); + } setEnabled(false); return; } @@ -730,17 +762,30 @@ private void valid() { * @return true if it is valid;false otherwise */ private boolean verifyBigValue(String bigValue) { - String bigValueTrim = bigValue.trim(); - if (bigValueTrim.length() == 0) { - return false; - } - - boolean notLimitValue = !bigValueTrim.equals(SERIAL_MAX) && !bigValueTrim.equals(SERIAL_MIN); boolean isValidBigVal = ValidateUtil.isInteger(bigValue); - if (isValidBigVal && bigValueTrim.length() == 38 && notLimitValue) { - isValidBigVal = false; - } + if (isChangeMaxMinValue()) { + if (!isValidBigVal) { + isValidBigVal = false; + } + String intbigValue = bigValue.replaceAll("[^\\d]",""); + + if (isValidBigVal && intbigValue.length() > 38) { + isValidBigVal = false; + } + + } else { + String bigValueTrim = bigValue.trim(); + if (bigValueTrim.length() == 0) { + return false; + } + + boolean notLimitValue = !bigValueTrim.equals(serialMaxValue()) && !bigValueTrim.equals(serialMinValue()); + + if (isValidBigVal && bigValueTrim.length() == 38 && notLimitValue) { + isValidBigVal = false; + } + } return isValidBigVal; } @@ -775,4 +820,32 @@ public String getSerialName() { public void setDatabase(CubridDatabase database) { this.database = database; } + + private boolean isChangeMaxMinValue() { + if (CompatibleUtil.isAfter1020(database.getDatabaseInfo())){ + return true; + } + return false; + } + + private String serialMinValue() { + if (isChangeMaxMinValue()){ + return SERIAL_MIN_AFTER_120; + } + return SERIAL_MIN; + } + + private String serialMaxValue() { + if (isChangeMaxMinValue()){ + return SERIAL_MAX_AFTER_120; + } + return SERIAL_MAX; + } + + private int getTextLimit() { + if (isChangeMaxMinValue()){ + return 39; + } + return 38; + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/editor/SerialDashboardEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/editor/SerialDashboardEditorPart.java index d1bc6c19..3e53476a 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/editor/SerialDashboardEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/serial/editor/SerialDashboardEditorPart.java @@ -103,6 +103,11 @@ public class SerialDashboardEditorPart extends CubridEditorPart { private TableViewer serialsDetailInfoTable; private List serialList; + private static final String SERIAL_MIN = "-1000000000000000000000000000000000000"; + private static final String SERIAL_MIN_AFTER_120 = "-99999999999999999999999999999999999999"; + private static final String SERIAL_MAX = "10000000000000000000000000000000000000"; + private static final String SERIAL_MAX_AFTER_120 = "99999999999999999999999999999999999999"; + public void createPartControl(Composite parent) { parent.setLayout(new GridLayout(1, false)); @@ -161,6 +166,10 @@ public void createSerialsDetailInfoTable(Composite parent) { serialsDetailInfoTable.getTable().setLinesVisible(true); CommonUITool.hackForYosemite(serialsDetailInfoTable.getTable()); + final TableViewerColumn ownerColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT); + ownerColumn.getColumn().setWidth(80); + ownerColumn.getColumn().setText(Messages.serialsDetailInfoPartTableOwnerCol); + final TableViewerColumn nameColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT); nameColumn.getColumn().setWidth(150); nameColumn.getColumn().setText(Messages.serialsDetailInfoPartTableNameCol); @@ -275,7 +284,7 @@ public void editSerial() { private void openEditSerialDialog(SerialInfo serialInfo) { Set typeSet = new HashSet(); typeSet.add(NodeType.SERIAL); - ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName()); + ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getUniqueName(isSupportUserSchema())); if (serialNode != null) { EditSerialAction action = (EditSerialAction) ActionManager.getInstance().getAction(EditSerialAction.ID); if (action.run(database, (ISchemaNode) serialNode) == IDialogConstants.OK_ID) { @@ -293,7 +302,7 @@ public void dropSerial() { Set typeSet = new HashSet(); typeSet.add(NodeType.SERIAL); - ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName()); + ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getUniqueName(isSupportUserSchema())); selectNodeList.add((ISchemaNode)serialNode); } @@ -427,27 +436,28 @@ public String getColumnText(Object element, int columnIndex) { String incrValue = serialInfo.getIncrementValue(); boolean isSupportCache = CompatibleUtil.isSupportCache(database.getDatabaseInfo()); switch (columnIndex) { - case 0 : return serialInfo.getName(); - case 1 : return serialInfo.getCurrentValue(); - case 2 : return serialInfo.getIncrementValue(); - case 3 : + case 0 : return serialInfo.getOwner(); + case 1 : return serialInfo.getName(); + case 2 : return serialInfo.getCurrentValue(); + case 3 : return serialInfo.getIncrementValue(); + case 4 : String minValue = serialInfo.getMinValue(); if (incrValue.indexOf("-") >= 0 - && "-1000000000000000000000000000000000000".equals(minValue)) { + && serialMinValue().equals(minValue)) { return "NOMINVALUE"; } else { return minValue; } - case 4 : + case 5 : String maxValue = serialInfo.getMaxValue(); if (incrValue.indexOf("-") < 0 - && "10000000000000000000000000000000000000".equals(maxValue)) { + && serialMaxValue().equals(maxValue)) { return "NOMAXVALUE"; } else { return maxValue; } - case 5 : + case 6 : String cacheCount = serialInfo.getCacheCount(); if (isSupportCache && cacheCount == null @@ -456,7 +466,7 @@ public String getColumnText(Object element, int columnIndex) { } else { return cacheCount; } - case 6 : + case 7 : return serialInfo.isCyclic() ? "YES" : "NO"; } } @@ -500,7 +510,7 @@ class ColumnViewerSorter extends ViewerSorter { public int compare(Viewer viewer, Object e1, Object e2) { SerialInfo s1 = (SerialInfo)e1; SerialInfo s2 = (SerialInfo)e2; - return s1.getName().compareTo(s2.getName()); + return s1.getOwner().compareTo(s2.getOwner()); } } @@ -521,4 +531,22 @@ public boolean isSaveAsAllowed() { public CubridDatabase getDatabase() { return database; } + + private String serialMinValue() { + if (database != null && database.getDatabaseInfo().isSupportUserSchema()){ + return SERIAL_MIN_AFTER_120; + } + return SERIAL_MIN; + } + + private String serialMaxValue() { + if (database != null && database.getDatabaseInfo().isSupportUserSchema()){ + return SERIAL_MAX_AFTER_120; + } + return SERIAL_MAX; + } + + private boolean isSupportUserSchema() { + return database.getDatabaseInfo().isSupportUserSchema(); + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.java index fcfa9ae0..fcc00d07 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.java @@ -362,6 +362,7 @@ public class Messages extends public static String exportWizardLoadDBPageErrMsg6; public static String exportWizardLoadDBPageErrMsg7; public static String exportWizardLoadDBPageErrMsg8; + public static String exportWizardLoadDBPageErrMsg9; public static String exportWizardSettngPageFilepathErrMsg; public static String exportWizardLoadDBPageFilepathErrMsg1; public static String exportWizardLoadDBPageFilepathErrMsg2; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.properties index f94c71df..e8a8e7f2 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages.properties @@ -132,6 +132,7 @@ exportWizardLoadDBPageErrMsg8=Please fill in the trigger path. exportWizardLoadDBPageErrMsg5=Please select the file charset. exportWizardLoadDBPageErrMsg6=Unsupported file charset. exportWizardLoadDBPageErrMsg7=Export file can't same as the others! +exportWizardLoadDBPageErrMsg9=Please set schema file for export index data. exportWizardBackConfirmMsg=All options will be cleared. Are you sure you want to go back? #import data diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages_ko_KR.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages_ko_KR.properties index 87015c1c..abf0db0d 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages_ko_KR.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/Messages_ko_KR.properties @@ -128,10 +128,11 @@ exportWizardLoadDBPageErrMsg1=\ud30c\uc77c\uc774 \uc800\uc7a5\ub420 \uacbd\ub85c exportWizardLoadDBPageErrMsg2=Schema \ud30c\uc77c\uc774 \uc800\uc7a5\ub420 \uacbd\ub85c \ubc0f \ud30c\uc77c\uba85\uc744 \uc785\ub825\ud574\uc8fc\uc138\uc694. exportWizardLoadDBPageErrMsg3=Index \ud30c\uc77c\uc774 \uc800\uc7a5\ub420 \uacbd\ub85c \ubc0f \ud30c\uc77c\uba85\uc744 \uc785\ub825\ud574\uc8fc\uc138\uc694. exportWizardLoadDBPageErrMsg4=Data \ud30c\uc77c\uc774 \uc800\uc7a5\ub420 \uacbd\ub85c \ubc0f \ud30c\uc77c\uba85\uc744 \uc785\ub825\ud574\uc8fc\uc138\uc694. -exportWizardLoadDBPageErrMsg8=Trigger \uD30C\uC77C\uC774 \uC800\uC7A5\uB420 \uACBD\uB85C \uBC0F \uD30C\uC77C\uBA85\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694. +exportWizardLoadDBPageErrMsg8=Trigger \ud30c\uc77c\uc774 \uc800\uc7a5\ub420 \uacbd\ub85c \ubc0f \ud30c\uc77c\uba85\uc744 \uc785\ub825\ud574\uc8fc\uc138\uc694. exportWizardLoadDBPageErrMsg5=\ud30c\uc77c \ubb38\uc790\uc14b\uc744 \uc9c0\uc815\ud574\uc8fc\uc138\uc694. exportWizardLoadDBPageErrMsg6=\uc9c0\uc6d0\ub418\uc9c0 \uc54a\ub294 \ud30c\uc77c \ubb38\uc790\uc14b \uc785\ub2c8\ub2e4. exportWizardLoadDBPageErrMsg7=\ub0b4\ubcf4\ub0bc \ud30c\uc77c\uc774 \uc774\ubbf8 \uc788\uc2b5\ub2c8\ub2e4. +exportWizardLoadDBPageErrMsg9=index\ub97c \ub0b4\ubcf4\ub0b4\uae30 \uc704\ud574\uc11c\ub294 Schema \ud30c\uc77c \uc124\uc815\uc774 \ud544\uc694\ud569\ub2c8\ub2e4. exportWizardBackConfirmMsg=\uc124\uc815\ud55c \uc815\ubcf4\uac00 \ucd08\uae30\ud654 \ub429\ub2c8\ub2e4. \uc774\uc804\uc73c\ub85c \ub418\ub3cc\uc544\uac00\uc2dc\uaca0\uc2b5\ub2c8\uae4c? #import data @@ -572,7 +573,7 @@ titleExecuteResult=\uacb0\uacfc \uc2e4\ud589 msgExecuteResult=SQL\ubb38 \uc218\ud589\uc774 \uc644\ub8cc\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \uc804\uccb4 {0}\ucd08\uac00 \uc18c\uc694\ub418\uc5c8\uc2b5\ub2c8\ub2e4. msgPstmtType=\uc720\ud615 #PstmtMultiDataDialog -msgPstmtMultiDataDialog=\uC120\uD0DD\uD55C \uD30C\uC77C(xls, csv)\uC758 \uB370\uC774\uD130\uC640 \uC815\uC758\uB41C SQL\uBB38 \uC0AC\uC774\uC758 \uAD00\uACC4\uB97C \uC124\uC815\uD558\uC2E0 \uD6C4 \uC218\uD589\uD558\uC2ED\uC2DC\uC624.%r%n\uC774 SQL\uBB38\uC740 \uBC18\uB4DC\uC2DC \uB9E4\uAC1C \uBCC0\uC218(?)\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. +msgPstmtMultiDataDialog=\uc120\ud0dd\ud55c \ud30c\uc77c(xls, csv)\uc758 \ub370\uc774\ud130\uc640 \uc815\uc758\ub41c SQL\ubb38 \uc0ac\uc774\uc758 \uad00\uacc4\ub97c \uc124\uc815\ud558\uc2e0 \ud6c4 \uc218\ud589\ud558\uc2ed\uc2dc\uc624.%r%n\uc774 SQL\ubb38\uc740 \ubc18\ub4dc\uc2dc \ub9e4\uac1c \ubcc0\uc218(?)\uac00 \ud544\uc694\ud569\ub2c8\ub2e4. grpSelectFile=\ud30c\uc77c \uc120\ud0dd lblTotalLines=\ub370\uc774\ud130 \uac1c\uc218 lblThreadCount=\ub3d9\uc2dc\uc791\uc5c5\uc218 @@ -680,12 +681,12 @@ tablesDetailInfoPartBtnViewDataTip=View first 100 lines data tablesDetailInfoPartBtnViewDataSelectOne=Please select one element in the table list. tablesDetailInfoPartBtnEsitmateRecord=Count (*) tablesDetailInfoPartBtnEsitmateRecordTip=\ub808\ucf54\ub4dc\uc218 \ud655\uc778\uc744 \uc704\ud574 \ub808\ucf54\ub4dc\uc218 \uc9c8\uc758\ub97c \uc2e4\ud589 -tablesDetailInfoPartBtnEsitmateColumnTip=\uCEEC\uB7FC\uC218 \uD655\uC778\uC744 \uC704\uD574 \uCEEC\uB7FC\uC218 \uC9C8\uC758\uB97C \uC2E4\uD589 -tablesDetailInfoPartBtnEsitmateKeyTip=\uD0A4 \uAC2F\uC218 \uD655\uC778\uC744 \uC704\uD574 \uC9C8\uC758\uB97C \uC2E4\uD589 -tablesDetailInfoPartBtnEsitmateRecordSizeTip=\uB808\uCF54\uB4DC\uC0AC\uC774\uC988 \uD655\uC778\uC744 \uC704\uD574 \uC9C8\uC758\uB97C \uC218\uD589 +tablesDetailInfoPartBtnEsitmateColumnTip=\uceec\ub7fc\uc218 \ud655\uc778\uc744 \uc704\ud574 \uceec\ub7fc\uc218 \uc9c8\uc758\ub97c \uc2e4\ud589 +tablesDetailInfoPartBtnEsitmateKeyTip=\ud0a4 \uac2f\uc218 \ud655\uc778\uc744 \uc704\ud574 \uc9c8\uc758\ub97c \uc2e4\ud589 +tablesDetailInfoPartBtnEsitmateRecordSizeTip=\ub808\ucf54\ub4dc\uc0ac\uc774\uc988 \ud655\uc778\uc744 \uc704\ud574 \uc9c8\uc758\ub97c \uc218\ud589 tablesDetailInfoPartBtnRefreshTip=\uc0c8\ub85c\uace0\uce68 tablesDetailInfoPartBtnEsitmateRecordAlert=\ub808\ucf54\ub4dc\uc218 \uc218\uc9d1\uc744 \uc704\ud574 SELECT COUNT(*)\ub97c \uc2e4\ud589\ud558\uac8c \ub429\ub2c8\ub2e4.\n\uae30\ubcf8\ud0a4(Primary Key)\uac00 \uc5c6\ub294 \ud14c\uc774\ube14\uc5d0\uc11c\ub294 \uc11c\ube44\uc2a4\uc5d0 \uc601\ud5a5\uc744 \ub07c\uce60 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n\uacc4\uc18d\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c? -tablesDetailInfoPartBtnEsitmateAlert=\uC774 \uC791\uC5C5\uC740 {0}\uC758 \uC218\uB97C \uACC4\uC0B0\uD558\uAE30 \uC704\uD574 \uC2E4\uD589\uB429\uB2C8\uB2E4.\n\uB9CE\uC740 \uD14C\uC774\uBE14\uC744 \uC120\uD0DD\uD558\uBA74 \uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC18D\uB3C4\uAC00 \uC800\uD558 \uB420 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n\uACC4\uC18D \uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C? +tablesDetailInfoPartBtnEsitmateAlert=\uc774 \uc791\uc5c5\uc740 {0}\uc758 \uc218\ub97c \uacc4\uc0b0\ud558\uae30 \uc704\ud574 \uc2e4\ud589\ub429\ub2c8\ub2e4.\n\ub9ce\uc740 \ud14c\uc774\ube14\uc744 \uc120\ud0dd\ud558\uba74 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc18d\ub3c4\uac00 \uc800\ud558 \ub420 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n\uacc4\uc18d \ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c? tablesDetailInfoPartAlertNotSelected=\ub808\ucf54\ub4dc\uc218 \uc218\uc9d1 \ub300\uc0c1 \ud14c\uc774\ube14\uc744 \uc120\ud0dd\ud574\uc8fc\uc138\uc694. tablesDetailInfoPartBtnCopyTableNames=Copy tablesDetailInfoPartBtnCopyTableNamesTip=\ud14c\uc774\ube14 \uc774\ub984\uc744 \ud074\ub9bd\ubcf4\ub4dc\ub85c \ubcf5\uc0ac @@ -707,10 +708,10 @@ tablesDetailInfoPartCloseOthersMenu=\ub2e4\ub978 \ud0ed \ub2eb\uae30 tablesDetailInfoPartRefreshMenu=\uc0c8\ub85c\uace0\uce68 tablesDetailInfoLoadingDataTitle=\ub85c\ub529... tablesDetailInfoLoadingData=\ud14c\uc774\ube14 "{0}" \ub85c\ub529... -loadTableRecordCountsProgressTaskName=\uD14C\uC774\uBE14\uC758 \uB808\uCF54\uB4DC\uC218\uB97C \uC218\uC9D1\uC911 \uC785\uB2C8\uB2E4... -loadTableColumnsProgressTaskName=\uD14C\uC774\uBE14\uC758 \uCEEC\uB7FC \uAC1C\uC218\uB97C \uC218\uC9D1\uC911 \uC785\uB2C8\uB2E4... -loadTableKeysProgressTaskName=\uD14C\uC774\uBE14\uC758 \uD0A4 \uAC12\uB4E4\uC744 \uC218\uC9D1\uC911 \uC785\uB2C8\uB2E4... -loadTableRecordSizeProgressTaskName=\uD14C\uC774\uBE14\uC758 \uB808\uCF54\uB4DC \uC0AC\uC774\uC988\uB97C \uC218\uC9D1\uC911 \uC785\uB2C8\uB2E4... +loadTableRecordCountsProgressTaskName=\ud14c\uc774\ube14\uc758 \ub808\ucf54\ub4dc\uc218\ub97c \uc218\uc9d1\uc911 \uc785\ub2c8\ub2e4... +loadTableColumnsProgressTaskName=\ud14c\uc774\ube14\uc758 \uceec\ub7fc \uac1c\uc218\ub97c \uc218\uc9d1\uc911 \uc785\ub2c8\ub2e4... +loadTableKeysProgressTaskName=\ud14c\uc774\ube14\uc758 \ud0a4 \uac12\ub4e4\uc744 \uc218\uc9d1\uc911 \uc785\ub2c8\ub2e4... +loadTableRecordSizeProgressTaskName=\ud14c\uc774\ube14\uc758 \ub808\ucf54\ub4dc \uc0ac\uc774\uc988\ub97c \uc218\uc9d1\uc911 \uc785\ub2c8\ub2e4... errGetSchemaInfo=\ud14c\uc774\ube14 '{0}'\uc758 \uc2a4\ud0a4\ub9c8 \uc815\ubcf4\ub97c \uc870\ud68c\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. @@ -818,7 +819,7 @@ lblExportTargetIndex=\uc778\ub371\uc2a4 lblExportTargetData=\ub370\uc774\ud130 lblExportTargetSerial=\uc2dc\ub9ac\uc5bc lblExportTargetView=\ubdf0 -lblExportTargetTrigger=\uD2B8\uB9AC\uAC70 +lblExportTargetTrigger=\ud2b8\ub9ac\uac70 lblExportTargetStartValue=\ud14c\uc774\ube14 \uc790\ub3d9\uc99d\uac00 \ucd08\uae30 \uac12\uc744 \ud604\uc7ac \uac12\uc73c\ub85c \uc2a4\ud0a4\ub9c8 \uc0dd\uc131 tipExportTargetStartValue=\uc790\ub3d9\uc99d\uac00 \uceec\ub7fc\uc744 \uac00\uc9c4 \ud14c\uc774\ube14\uc758 \ucd08\uae30 \uac12\uc744 \ub9c8\uc9c0\ub9c9\uc73c\ub85c \uc790\ub3d9\uc99d\uac00\ub41c \uac12\uc73c\ub85c \ubcc0\uacbd\ud569\ub2c8\ub2e4. lblExportLobData=Export CLOB/BLOB data @@ -845,7 +846,7 @@ lblExportConfirmIndex=\uc778\ub371\uc2a4 lblExportConfirmData=\ub370\uc774\ud130 lblExportConfirmSerial=\uc2dc\ub9ac\uc5bc lblExportConfirmView=\ubdf0 -lblExportConfirmTrigger=\uD2B8\uB9AC\uAC70 +lblExportConfirmTrigger=\ud2b8\ub9ac\uac70 lblImportConfirmImportType=\uac00\uc838\uc624\uae30 \uc720\ud615 : lblImportConfirmCommitCount=\ucee4\ubc0b\ub2e8\uc704 : lblImportConfirmThreads=\ub3d9\uc2dc\uc791\uc5c5\uc218 : diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateLikeTableAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateLikeTableAction.java index 89bbed0d..a0178b98 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateLikeTableAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateLikeTableAction.java @@ -60,6 +60,8 @@ public class CreateLikeTableAction extends SelectionAction { + private boolean isSupportUserSchema = false; + public static final String ID = CreateLikeTableAction.class.getName(); /** @@ -146,6 +148,7 @@ private void doRun(ISchemaNode node) { CreateLikeTableDialog dialog = new CreateLikeTableDialog(getShell()); dialog.setDatabase(node.getDatabase()); + isSupportUserSchema = node.getDatabase().getDatabaseInfo().isSupportUserSchema(); if (NodeType.USER_TABLE.equals(node.getType())) { String tableName = node.getName(); dialog.setLikeTableName(tableName); @@ -158,9 +161,16 @@ private void doRun(ISchemaNode node) { ClassInfo classInfo = (ClassInfo) node.getAdapter(ClassInfo.class); String id = node.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName; - ClassInfo newClassInfo = new ClassInfo(tableName, null, + ClassInfo newClassInfo = null; + if (isSupportUserSchema) { + newClassInfo = new ClassInfo(getClassName(tableName), getOwnerName(tableName), ClassType.NORMAL, classInfo.isSystemClass(), - classInfo.isPartitionedClass()); + classInfo.isPartitionedClass(), classInfo.isSupportUserSchema()); + } else { + newClassInfo = new ClassInfo(tableName, null, + ClassType.NORMAL, classInfo.isSystemClass(), + classInfo.isPartitionedClass(), classInfo.isSupportUserSchema()); + } newNode = CubridTablesFolderLoader.createUserTableNode( node.getParent(), id, newClassInfo, node.getParent().getLoader().getLevel(), @@ -178,7 +188,7 @@ private void doRun(ISchemaNode node) { String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName; ClassInfo newClassInfo = new ClassInfo(tableName, null, - ClassType.NORMAL, false, false); + ClassType.NORMAL, false, false, false); newNode = CubridTablesFolderLoader.createUserTableNode( node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor()); @@ -189,4 +199,18 @@ private void doRun(ISchemaNode node) { CubridNodeChangedEventType.NODE_ADD)); } } + + private String getClassName(String tableName) { + if (isSupportUserSchema) { + return tableName.substring(tableName.indexOf(".")+1); + } + return tableName; + } + + private String getOwnerName(String tableName) { + if (isSupportUserSchema) { + return tableName.substring(0, tableName.indexOf(".")); + } + return tableName; + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateViewAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateViewAction.java index b574c666..4a7721dc 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateViewAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/CreateViewAction.java @@ -90,6 +90,8 @@ public boolean isSupported(Object obj) { public void run(CubridDatabase database) { TaskExecutor taskExcutor = new CommonTaskExec(null); DatabaseInfo databaseInfo = database.getDatabaseInfo(); + boolean isSupportUserSchema = databaseInfo.isSupportUserSchema(); + JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo); taskExcutor.addTask(task); new ExecTaskWithProgress(taskExcutor).busyCursorWhile(); @@ -117,9 +119,9 @@ public void run(CubridDatabase database) { String viewName = dialog.getNewViewName(); String owner = dialog.getOwner(); String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR - + viewName; - ClassInfo newClassInfo = new ClassInfo(viewName, owner, - ClassType.VIEW, false, false); + + owner + "." + viewName; + ClassInfo newClassInfo = new ClassInfo(dialog.getNewViewName(), owner, + ClassType.VIEW, false, false, isSupportUserSchema); ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode( id, newClassInfo); CommonUITool.addNodeToTree(treeViewer, folderNode, newNode); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/EditViewAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/EditViewAction.java index e3078afa..babc1dc8 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/EditViewAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/EditViewAction.java @@ -191,6 +191,7 @@ public int run (CubridDatabase database, ISchemaNode node) { ClassInfo newClassInfo = (ClassInfo) node.getAdapter(ClassInfo.class); newClassInfo.setClassName(newViewName); newClassInfo.setOwnerName(owner); + newClassInfo.setSupportUserSchema(database.getDatabaseInfo().isSupportUserSchema()); node.setId(node.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + newViewName); node.setLabel(newViewName); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/RenameTableAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/RenameTableAction.java index f9d1c0cb..2f559ad2 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/RenameTableAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/action/RenameTableAction.java @@ -163,22 +163,29 @@ private void doRun(CubridDatabase cubridDatabase, ISchemaNode table) { String tableName = table.getName(); CubridDatabase db = table.getDatabase(); DatabaseInfo dbInfo = db.getDatabaseInfo(); + boolean isSupportUserSchema = dbInfo.isSupportUserSchema(); GetTablesTask getTableTask = new GetTablesTask(dbInfo); List tableList = getTableTask.getAllTableAndViews(); RenameTableDialog dlg = new RenameTableDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), tableName, - isTable, tableList, true); + isTable, tableList, true, isSupportUserSchema); int ret = dlg.open(); if (ret == IDialogConstants.OK_ID) { - String newName = dlg.getNewName(); + String newClassName = dlg.getNewName(); + String newTableName; + if (isSupportUserSchema) { + newTableName = dlg.getOwnerName() + "." + newClassName; + } else { + newTableName = newClassName; + } RenameTableOrViewTask task = new RenameTableOrViewTask(dbInfo); task.setOldClassName(tableName); - task.setNewClassName(newName); + task.setNewClassName(newTableName); task.setTable(isTable); String taskName = Messages.bind( com.cubrid.common.ui.cubrid.table.Messages.renameTableTaskName, - new String[]{tableName, newName }); + new String[]{tableName, newTableName }); TaskExecutor taskExecutor = new CommonTaskExec(taskName); taskExecutor.addTask(task); new ExecTaskWithProgress(taskExecutor).exec(); @@ -199,10 +206,18 @@ private void doRun(CubridDatabase cubridDatabase, ISchemaNode table) { } ClassInfo classInfo = (ClassInfo) table.getAdapter(ClassInfo.class); - classInfo.setClassName(newName); + classInfo.setClassName(newClassName); + classInfo.setSupportUserSchema(dbInfo.isSupportUserSchema()); table.setId(table.getParent().getId() - + ICubridNodeLoader.NODE_SEPARATOR + newName); - table.setLabel(newName); + + ICubridNodeLoader.NODE_SEPARATOR + newTableName); + if (isSupportUserSchema) { + String label = "[" + dlg.getOwnerName() + "] " + newClassName; + table.setLabel(label); + } else { + String label = "[" + dlg.getOwnerName() + "] " + newClassName; + table.setLabel(newTableName); + } + table.setUniqueName(newTableName); viewer.refresh(table, true); LayoutManager.getInstance().getWorkbenchContrItem().reopenEditorOrView( table); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/AttributeTableViewerLabelProvider.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/AttributeTableViewerLabelProvider.java index 11c48768..72395d52 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/AttributeTableViewerLabelProvider.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/AttributeTableViewerLabelProvider.java @@ -101,8 +101,11 @@ public Image getColumnImage(Object element, int columnIndex) { case PK: { String attrName = dbAttribute.getName(); Constraint pk = schema.getPK(supers); - if (null != pk && pk.getAttributes().contains(attrName)) { - return PK_IMAGE; + if (null != pk) { + List attr = pk.getAttributes(); + if (null != attr && attr.contains(attrName)) { + return PK_IMAGE; + } } return editableMode ? UNCHECK_IMAGE : null; } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/CreatePartitionWizard.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/CreatePartitionWizard.java index 4d3aef76..f634330b 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/CreatePartitionWizard.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/CreatePartitionWizard.java @@ -210,7 +210,7 @@ public boolean performFinish() { // FIXME move this logic to core module } for (int i = 0; i < Integer.parseInt(partitionNum); i++) { PartitionInfo partitonInfo = new PartitionInfo( - schemaInfo.getClassname(), "p" + i, partitionType, + schemaInfo.getUniqueName(), "p" + i, partitionType, expr, null, -1); partitionInfoList.add(partitonInfo); } @@ -221,7 +221,7 @@ public boolean performFinish() { // FIXME move this logic to core module List valuesList = listPage.getListValues(); if (this.editedPartitionInfo == null) { PartitionInfo partitonInfo = new PartitionInfo( - schemaInfo.getClassname(), partitionName, + schemaInfo.getUniqueName(), partitionName, partitionType, expr, valuesList, -1); partitonInfo.setPartitionExprType(exprDataType); partitonInfo.setDescription(partitionDescription); @@ -254,7 +254,7 @@ public boolean performFinish() { // FIXME move this logic to core module rangeList.add(newValue); } PartitionInfo partitonInfo = new PartitionInfo( - schemaInfo.getClassname(), partitionName, + schemaInfo.getUniqueName(), partitionName, partitionType, expr, rangeList, -1); partitonInfo.setPartitionExprType(exprDataType); partitonInfo.setDescription(partitionDescription); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionEditListPage.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionEditListPage.java index 042c0bbf..fac6c5ad 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionEditListPage.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionEditListPage.java @@ -437,7 +437,7 @@ private void initValuesCombo() { dbInfo); String expr = partitionExprText.getText(); String[] distinctValues = task.getDistinctValuesInAttribute( - schemaInfo.getClassname(), expr); + schemaInfo.getUniqueName(), expr); if (distinctValues == null || distinctValues.length <= 0) { return; } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionTypePage.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionTypePage.java index 629a73bb..de7cd3ea 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionTypePage.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/control/PartitionTypePage.java @@ -252,7 +252,7 @@ public void widgetSelected(SelectionEvent event) { if (!isNewTable) { GetPartitionedClassListTask task = new GetPartitionedClassListTask( dbInfo); - dbAttrStatList = task.getColumnStatistics(schemaInfo.getClassname()); + dbAttrStatList = task.getColumnStatistics(schemaInfo.getUniqueName()); } attrList.addAll(schemaInfo.getAttributes()); for (int i = 0; dbAttrStatList != null && i < dbAttrStatList.size(); i++) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardComposite.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardComposite.java index 374d31c3..d7093ac6 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardComposite.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardComposite.java @@ -138,7 +138,7 @@ public void setInput(SchemaInfo schema, DatabaseInfo database, boolean isSchemaC this.databaseInfo = database; labelProvider.setSchema(schema); labelProvider.setDatabase(database); - tabItem.setText(schema == null ? "" : schema.getClassname()); + tabItem.setText(schema == null ? "" : schema.getUniqueName()); tabItem.setData(schema); columnTableView.setInput(schema); columnTableView.refresh(); @@ -329,7 +329,7 @@ public void showEditDialog(Table table, int index) { com.cubrid.common.ui.cubrid.table.Messages.labelColumnDescEditor, attr.getDescription()); if (dialog.open() == IDialogConstants.OK_ID) { // FIXME move this logic to core module - String tableName = info.getClassname(); + String tableName = info.getUniqueName(); String columnName = attr.getName(); String description = dialog.getResult(); Connection conn = null; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardPart.java index 44fbacff..3f58516a 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dashboard/control/TableDashboardPart.java @@ -627,11 +627,11 @@ public void setInputs() { if (database.getDatabaseInfo().getUserTableInfoList().size() > 0) { ClassInfo classInfo = database.getDatabaseInfo().getUserTableInfoList().get(0); SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, - classInfo.getClassName()); + classInfo.getUniqueName()); IDatabaseSpec dbSpec = database.getDatabaseInfo(); if (schemaInfo != null && SchemaCommentHandler.isInstalledMetaTable(dbSpec, connection)) { Map comments = SchemaCommentHandler.loadDescription( - dbSpec, connection, classInfo.getClassName()); + dbSpec, connection, database.getDatabaseInfo().isSupportUserSchema(), classInfo.getUniqueName()); if (comments != null) { SchemaCommentHandler.bindSchemaInfo(comments, schemaInfo); } @@ -1262,7 +1262,7 @@ private void fireTableDetailChanged(String name) { SchemaInfo schema = tabItem.getTableInfoComposite().getData(); if (schema != null && StringUtil.isEqualNotIgnoreNull( - schema.getClassname(), name)) { + schema.getUniqueName(), name)) { item.dispose(); } } @@ -1333,7 +1333,7 @@ private void openTableDetail(TableDetailInfo info) { boolean isSchemaCommentInstalled = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn); if (schemaInfo != null && isSchemaCommentInstalled) { Map comments = SchemaCommentHandler.loadDescription( - dbSpec, conn, schemaInfo.getClassname()); + dbSpec, conn, database.getDatabaseInfo().isSupportUserSchema(), schemaInfo.getUniqueName()); SchemaCommentHandler.bindSchemaInfo(comments, schemaInfo); } } catch (SQLException e) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddFKDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddFKDialog.java index c7bb14b3..26ed4e77 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddFKDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddFKDialog.java @@ -219,7 +219,7 @@ protected void buttonPressed(int buttonId) { String fkName = fkNameText.getText().trim(); if (StringUtil.isEmpty(fkName)) { //$NON-NLS-1$ - fkName = ConstraintNamingUtil.getFKName(schema.getClassname(), + fkName = ConstraintNamingUtil.getFKName(schema.getUniqueName(), retFK.getAttributes()); } retFK.setName(fkName); @@ -723,7 +723,7 @@ public int checkFields() { } int fkItemCount = fkTable.getItemCount(); if (fkItemCount == 0) { - setErrorMessage(Messages.errNoColumnInTable + schema.getClassname()); + setErrorMessage(Messages.errNoColumnInTable + schema.getUniqueName()); return 1; } Map pk2fkMap = new HashMap(); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddResolutionDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddResolutionDialog.java index 06ad1c5e..bacab734 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddResolutionDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/AddResolutionDialog.java @@ -247,7 +247,7 @@ protected void buttonPressed(int buttonId) { String alias = aliasText.getText().trim(); resolution = new DBResolution(); resolution.setName(col); - resolution.setClassName(sup); + resolution.setTableName(sup); resolution.setAlias(alias); resolution.setClassResolution(isClassResolution); } else { @@ -398,7 +398,7 @@ private boolean validate() { resolutions = schema.getResolutions(); } for (DBResolution r : resolutions) { - if (r.getName().equals(col) && r.getClassName().equals(sup) + if (r.getName().equals(col) && r.getTableName().equals(sup) && r.getAlias().equals(alias)) { setErrorMessage(Messages.errExistResolution); return false; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/CreateViewDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/CreateViewDialog.java index e3030265..fdd08144 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/CreateViewDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/CreateViewDialog.java @@ -204,6 +204,11 @@ public void widgetSelected(SelectionEvent event) { ownerOld = classInfo.getOwnerName(); } boolean isSameUser = StringUtil.isEqualIgnoreCase(ownerOld, ownerNew); + // on 11.2, not need Alter User After Create view. + if (database.getDatabaseInfo().isSupportUserSchema() && isNewTableFlag) { + isSameUser = true; + } + if (!isSameUser) { sb.append(";"); sb.append(StringUtil.NEWLINE); @@ -546,9 +551,19 @@ protected void buttonPressed(int buttonId) { task.addSqls(sql); DatabaseInfo dbInfo = database.getDatabaseInfo(); - String ownerOld = dbInfo.getAuthLoginedDbUserInfo().getName(); + String ownerOld = ""; + if (isNewTableFlag) { + ownerOld = ownerCombo.getText(); + } else { + ownerOld = classInfo.getOwnerName(); + } String ownerNew = ownerCombo.getText(); boolean isSameOwner = StringUtil.isEqualIgnoreCase(ownerOld, ownerNew); + // on 11.2, not need Alter User After Create view. + if (dbInfo.isSupportUserSchema() && isNewTableFlag) { + isSameOwner = true; + } + if (!isSameOwner) { sql = makeChangeOwnerSQLScript(); @@ -601,10 +616,11 @@ public void modifyText(ModifyEvent event) { } viewNameText.setEditable(false); viewNameText.setText(classInfo.getClassName()); + ownerOld = classInfo.getOwnerName(); if (isCommentSupport) { if (!classInfo.isSystemClass()) { - String comment = getViewComment(); + String comment = getViewComment(ownerOld); if (comment != null) { viewDescriptionText.setText(comment); } @@ -613,12 +629,11 @@ public void modifyText(ModifyEvent event) { } } - ownerOld = classInfo.getOwnerName(); - String[] strs = new String[] { classInfo.getClassName(), + String[] strs = new String[] { classInfo.getUniqueName(), isPropertyQuery ? Messages.msgPropertyInfo : Messages.msgEditInfo }; setTitle(Messages.bind(Messages.editViewMsgTitle, strs)); setMessage(Messages.editViewMsg); - strs = new String[] { classInfo.getClassName(), + strs = new String[] { classInfo.getUniqueName(), isPropertyQuery ? Messages.msgPropertyInfo : Messages.msgEditInfo }; String title = Messages.bind(Messages.editViewShellTitle, strs); getShell().setText(title); @@ -716,7 +731,7 @@ private void fillOwnerCombo() { * * @return */ - private String getViewComment() { + private String getViewComment(String owner) { Connection conn = null; Statement stmt = null; ResultSet rs = null; @@ -725,9 +740,12 @@ private String getViewComment() { try { DatabaseInfo dbInfo = database.getDatabaseInfo(); + if (dbInfo.isSupportUserSchema()) { + viewName = owner + "." + viewName; + } conn = JDBCConnectionManager.getConnection(dbInfo, true); schemaComment = SchemaCommentHandler.loadObjectDescription( - dbInfo, conn, viewName, CommentType.VIEW); + dbInfo, conn, dbInfo.isSupportUserSchema(), viewName, CommentType.VIEW); } catch (SQLException e) { LOGGER.error(e.getMessage()); CommonUITool.openErrorBox(e.getMessage()); @@ -814,13 +832,20 @@ private String makeDropSQLScript() { return ""; } String classNameOld = classInfo.getClassName(); - String classNameNew = viewNameText.getText(); + String classNameNew; + classNameNew = viewNameText.getText(); + boolean isSameClass = StringUtil.isEqualIgnoreCase(classNameOld, classNameNew); if (isNewTableFlag || isSameClass) { return ""; } - String ddl = "DROP VIEW " + QuerySyntax.escapeKeyword(classInfo.getClassName()) + ";"; + String ddl; + if (database.getDatabaseInfo().isSupportUserSchema()) { + ddl = "DROP VIEW " + classInfo.getOwnerName() + "." + QuerySyntax.escapeKeyword(classInfo.getClassName()) + ";"; + } else { + ddl = "DROP VIEW " + QuerySyntax.escapeKeyword(classInfo.getClassName()) + ";"; + } return ddl; } @@ -852,8 +877,10 @@ private String makeCreateSQLScript() { // FIXME move this logic to core module if (isNewTableFlag) { ddl.append("CREATE VIEW "); } else { - boolean isSameClass = StringUtil.isEqualIgnoreCase(classInfo.getClassName(), - viewNameText.getText()); + boolean isSameClass; + isSameClass = StringUtil.isEqualIgnoreCase(classInfo.getClassName(), + viewNameText.getText()); + boolean canSupport = CompatibleUtil.isSupportReplaceView(database.getDatabaseInfo()); if (canSupport && isSameClass) { ddl.append("CREATE OR REPLACE VIEW "); @@ -866,10 +893,22 @@ private String makeCreateSQLScript() { // FIXME move this logic to core module if (viewNameText == null || StringUtil.isEmpty(viewNameText.getText())) { ddl.append("[VIEWNAME]"); } else { - viewName = viewNameText.getText(); - } - if (viewName != null) { - ddl.append(QuerySyntax.escapeKeyword(viewName)); + if (database.getDatabaseInfo().isSupportUserSchema()) { + String ownerName; + if (isNewTableFlag) { + ownerName = ownerCombo.getText(); + } else { + ownerName = classInfo.getOwnerName(); + } + viewName = QuerySyntax.escapeKeyword(ownerName) + + "." + QuerySyntax.escapeKeyword(viewNameText.getText()); + ddl.append(viewName); + } else { + viewName = viewNameText.getText(); + if (viewName != null) { + ddl.append(QuerySyntax.escapeKeyword(viewName)); + } + } } ddl.append("("); @@ -1076,7 +1115,12 @@ private String makeChangeOwnerSQLScript() { // FIXME move this logic to core mod String viewName = viewNameText.getText(); String ownerNew = ownerCombo.getText(); - String ownerOld = dbInfo.getAuthLoginedDbUserInfo().getName(); + String ownerOld; + if (database.getDatabaseInfo().isSupportUserSchema()) { + ownerOld = classInfo.getOwnerName(); + } else { + ownerOld = dbInfo.getAuthLoginedDbUserInfo().getName(); + } if (ownerOld.equalsIgnoreCase(ownerNew)) { return null; @@ -1087,6 +1131,11 @@ private String makeChangeOwnerSQLScript() { // FIXME move this logic to core mod StringBuffer bf = new StringBuffer(); if (CompatibleUtil.isSupportChangeOwnerWithAlterStatement(dbInfo)) { + if (database.getDatabaseInfo().isSupportUserSchema()) { + viewName = QuerySyntax.escapeKeyword(ownerOld) + "." + QuerySyntax.escapeKeyword(viewName); + } else { + viewName = QuerySyntax.escapeKeyword(viewName); + } createAlterStatementForChangingOwner(bf, viewName, ownerNew); } else { createMethodCallForChangingOwner(bf, viewName, ownerNew); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/RenameTableDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/RenameTableDialog.java index 90fe90cb..99bf77f9 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/RenameTableDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/RenameTableDialog.java @@ -67,8 +67,11 @@ public class RenameTableDialog extends private String newName; private String tableOrView; + private boolean isSupportUserSchema; + private String ownerName; + public RenameTableDialog(Shell parentShell, String name, boolean isTable, - List nameList, boolean isPhysical) { + List nameList, boolean isPhysical, boolean isSupportUserSchema) { super(parentShell); this.oldName = name; this.existNameList = nameList; @@ -79,6 +82,7 @@ public RenameTableDialog(Shell parentShell, String name, boolean isTable, tableOrView = Messages.renameView; } this.isPhysical = isPhysical; + this.isSupportUserSchema = isSupportUserSchema; } /** @@ -151,6 +155,11 @@ protected Control createDialogArea(Composite parent) { data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; + if (isSupportUserSchema) { + ownerName = oldName.substring(0, oldName.indexOf(".")); + oldName = oldName.substring(oldName.indexOf(".") + 1); + } + newTableText.setLayoutData(data); newTableText.setText(oldName); newTableText.selectAll(); @@ -200,4 +209,9 @@ public String getNewName() { return newName; } + + public String getOwnerName() { + return ownerName; + + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingForLoadDBPage.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingForLoadDBPage.java index c67d74d1..b95dabb9 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingForLoadDBPage.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingForLoadDBPage.java @@ -572,12 +572,21 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { ResultSet rs = null; StringBuilder sql = new StringBuilder(); - sql.append("SELECT c.class_name, c.class_type "); - sql.append("FROM db_class c, db_attribute a "); - sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); - sql.append("AND a.from_class_name IS NULL "); - sql.append("GROUP BY c.class_name, c.class_type "); - sql.append("ORDER BY c.class_type, c.class_name"); + if (isSupportUserSchema()) { + sql.append("SELECT c.class_name, c.class_type, c.owner_name "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' AND c.owner_name=a.owner_name "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("GROUP BY c.owner_name, c.class_name, c.class_type "); + sql.append("ORDER BY c.owner_name, c.class_type, c.class_name"); + } else { + sql.append("SELECT c.class_name, c.class_type "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("GROUP BY c.class_name, c.class_type "); + sql.append("ORDER BY c.class_type, c.class_name"); + } String query = sql.toString(); @@ -593,8 +602,16 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { stmt = conn.createStatement(); rs = stmt.executeQuery(query); while (rs.next()) { - String tableName = rs.getString(1); //$NON-NLS-1$ + String className = rs.getString(1); //$NON-NLS-1$ String tableType = rs.getString(2); //$NON-NLS-1$ + String tableName; + if (isSupportUserSchema()) { + String owenrName = rs.getString(3); + tableName = owenrName + "." + className; + } else { + tableName = className; + } + if (ConstantsUtil.isExtensionalSystemTable(tableName)) { continue; } @@ -604,7 +621,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { //export all view now so don't need select view node continue; } - ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, + ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, tableName, iconPath); classNode.setContainer(true); classNode.setType(NodeType.TABLE_COLUMN_FOLDER); @@ -713,6 +730,12 @@ private void updateDialogStatus() { setPageComplete(false); return; } + + if (!schemaButton.getSelection()) { + setErrorMessage(Messages.exportWizardLoadDBPageErrMsg9); + setPageComplete(false); + return; + } } if (dataButton.getSelection()) { String dataPath = dataPathText.getText().trim(); @@ -1037,4 +1060,8 @@ public void clearOptions() { } tablesOrViewLst.clear(); } + + private boolean isSupportUserSchema() { + return getDatabase().getDatabaseInfo().isSupportUserSchema(); + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingPage.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingPage.java index 7b1e109e..1183d4c7 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingPage.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/exp/ExportSettingPage.java @@ -859,12 +859,22 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { ResultSet rs = null; StringBuilder sql = new StringBuilder(); - sql.append("SELECT c.class_name, c.class_type "); - sql.append("FROM db_class c, db_attribute a "); - sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); - sql.append("AND a.from_class_name IS NULL "); - sql.append("GROUP BY c.class_name, c.class_type "); - sql.append("ORDER BY c.class_type, c.class_name"); + if (isSupportUserSchema()) { + sql.append("SELECT c.class_name, c.class_type, c.owner_name "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sql.append("AND c.owner_name=a.owner_name "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("GROUP BY c.owner_name, c.class_name, c.class_type "); + sql.append("ORDER BY c.owner_name, c.class_type, c.class_name"); + } else { + sql.append("SELECT c.class_name, c.class_type "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("GROUP BY c.class_name, c.class_type "); + sql.append("ORDER BY c.class_type, c.class_name"); + } String query = sql.toString(); // [TOOLS-2425]Support shard broker @@ -879,8 +889,15 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { stmt = conn.createStatement(); rs = stmt.executeQuery(query); while (rs.next()) { - String tableName = rs.getString(1); //$NON-NLS-1$ + String className = rs.getString(1); //$NON-NLS-1$ String tableType = rs.getString(2); //$NON-NLS-1$ + String tableName; + if (isSupportUserSchema()) { + String ownerName = rs.getString(3); + tableName = ownerName + "." + className; + } else { + tableName = className; + } if (ConstantsUtil.isExtensionalSystemTable(tableName)) { continue; } @@ -890,7 +907,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { //export all view now so don't need select view node continue; } - ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, + ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, tableName, iconPath); if ("VCLASS".equalsIgnoreCase(tableType)) { classNode.setData(VIEWNODEFLAG, "true"); @@ -1397,4 +1414,11 @@ private void setRowDelimeter(String delimeter) { rowDelimiterCombo.setText(delimeter); } } + + private boolean isSupportUserSchema() { + if (getDatabase() != null) { + return getDatabase().getDatabaseInfo().isSupportUserSchema(); + } + return false; + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/imp/FileToTableMappingComposite.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/imp/FileToTableMappingComposite.java index e3e1b5a5..1d47e303 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/imp/FileToTableMappingComposite.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/dialog/imp/FileToTableMappingComposite.java @@ -221,27 +221,47 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { monitor.worked(1); StringBuilder sql = new StringBuilder(); - sql.append("SELECT c.class_name "); - sql.append("FROM db_class c, db_attribute a "); - sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' "); - sql.append("AND a.from_class_name IS NULL "); - sql.append("AND c.class_type = 'CLASS' "); - sql.append("GROUP BY c.class_name "); - sql.append("ORDER BY c.class_name"); + + if (isSupportUserSchema()) { + sql.append("SELECT c.class_name, c.owner_name "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' "); + sql.append("AND c.owner_name = a.owner_name "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("AND c.class_type = 'CLASS' "); + sql.append("GROUP BY c.owner_name, c.class_name "); + sql.append("ORDER BY c.owner_name, c.class_name"); + } else { + sql.append("SELECT c.class_name "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' "); + sql.append("AND a.from_class_name IS NULL "); + sql.append("AND c.class_type = 'CLASS' "); + sql.append("GROUP BY c.class_name "); + sql.append("ORDER BY c.class_name"); + } conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true); stmt = conn.createStatement(); rsTable = stmt.executeQuery(sql.toString()); while (rsTable.next()) { - String tableName = rsTable.getString(1); //$NON-NLS-1$ - if (ConstantsUtil.isExtensionalSystemTable(tableName)) { + String className = rsTable.getString(1); //$NON-NLS-1$ + String tableName; + + if (ConstantsUtil.isExtensionalSystemTable(className)) { continue; } - + + if (isSupportUserSchema()) { + tableName = rsTable.getString(2) + "." + className; + } else { + tableName = className; + } + String iconPath = "icons/navigator/schema_table_item.png"; - ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath); + ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, tableName, iconPath); classNode.setContainer(true); allTableList.add(classNode); } @@ -714,7 +734,7 @@ public ICubridNode createClassNode(String tableName, List colNameList, List colTypeList) { // FIXME move this logic to core module int columnCount = firstRowColsLst.size(); String iconPath = "icons/navigator/schema_table_item.png"; - ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, + ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, tableName, iconPath); classNode.setContainer(true); List columnNames; @@ -873,4 +893,8 @@ private void fillInFromList(List fileColumnList, } } } + + private boolean isSupportUserSchema() { + return database.getDatabaseInfo().isSupportUserSchema(); + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/AttributeCellModifier.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/AttributeCellModifier.java index 6600dc5c..3277796c 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/AttributeCellModifier.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/AttributeCellModifier.java @@ -267,7 +267,7 @@ public void modify(Object element, String property, Object value) { // FIXME mov attr.setName(newName); if (!StringUtil.isEmpty(newName)) { if (!lastAttrs.contains(newAttribute)) { - newAttribute.setInherit(editor.getNewSchemaInfo().getClassname()); + newAttribute.setInherit(editor.getNewSchemaInfo().getUniqueName()); schemaInfo.addAttribute(newAttribute); editor.removeElementByName(newName); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/TableEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/TableEditorPart.java index 16f7e88f..81648a46 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/TableEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/editor/TableEditorPart.java @@ -183,8 +183,8 @@ public class TableEditorPart extends private Table fkTable; private Combo ownerCombo; private StyledText sqlText; - private Text tableNameText; - private Text tableDescText; + private Text classNameText; + private Text classDescText; private CubridDatabase database; private TableColumn sharedColumn; // Should use loadColumnData method to set input data @@ -194,8 +194,8 @@ public class TableEditorPart extends private AttributeLabelProvider attrLabelProvider; private boolean isNewTableFlag; private SchemaInfo oldSchemaInfo; - private SchemaInfo newSchemaInfo; private SchemaChangeManager schemaChangeMgr; + private SchemaInfo newSchemaInfo; private SchemaDDL schemaDDL; private TableViewer fkTableView; private TableViewer indexTableView; @@ -207,7 +207,7 @@ public class TableEditorPart extends private Button editPartitionBtn; private Button delPartitionBtn; private Button reuseOIDBtn; - private String tableName; + private String className; private String owner; private ISchemaNode editedTableNode; private List dbUserList; @@ -279,12 +279,18 @@ public void widgetSelected(final SelectionEvent event) { return; } - String tableName = tableNameText.getText(); - newSchemaInfo.setClassname(tableName); + String className = classNameText.getText(); + newSchemaInfo.setClassname(className); String owner = ownerCombo.getText(); newSchemaInfo.setOwner(owner); + if (isSupportUserSchema()) { + newSchemaInfo.setUniqueName(owner + "." + className); + } else { + newSchemaInfo.setUniqueName(className); + } + if (reuseOIDBtn != null) { newSchemaInfo.setReuseOid(reuseOIDBtn.getSelection()); } @@ -321,7 +327,7 @@ public void widgetSelected(final SelectionEvent event) { init(); if (isNewTableFlag) { - tableNameText.setFocus(); + classNameText.setFocus(); } Composite btnComposite = new Composite(composite, SWT.NONE); @@ -390,12 +396,14 @@ protected void okPressed() { return; } - tableName = tableNameText.getText(); + className = classNameText.getText(); + String tableDesc = classDescText.getText(); owner = ownerCombo.getText(); - String tableDesc = tableDescText.getText(); - newSchemaInfo.setClassname(tableName); newSchemaInfo.setOwner(owner); + newSchemaInfo.setClassname(className); + newSchemaInfo.setUniqueName(getTableName()); newSchemaInfo.setDescription(tableDesc); + if (reuseOIDBtn != null) { newSchemaInfo.setReuseOid(reuseOIDBtn.getSelection()); } @@ -407,10 +415,11 @@ protected void okPressed() { String ddlStr = null; if (isNewTableFlag) { ddlStr = schemaDDL.getSchemaDDL(newSchemaInfo); + } else { ddlStr = schemaDDL.getSchemaDDL(oldSchemaInfo, newSchemaInfo); } - + boolean isExecuteCommonSqlTask = false; String[] sqlStr = ddlStr.split("\\$\\$\\$\\$"); for (String sql : sqlStr) { @@ -424,16 +433,21 @@ protected void okPressed() { } } - // do with table user change - String changeOwnerDDL = getChangeOwnerDDL(); - if (StringUtil.isNotEmpty(changeOwnerDDL)) { - changeOwnerDDL = dbInfo.wrapShardQuery(changeOwnerDDL); - if (CompatibleUtil.isSupportChangeOwnerWithAlterStatement(dbInfo)) { - commonSqlTask.addSqls(changeOwnerDDL); - } else { - commonSqlTask.addCallSqls(changeOwnerDDL); + // When create table on 11.2 or higher, execute only create table + // When create table on less than 11.2, execute create table and alter table owner to. + boolean isNotExcuteChangeOwner = isNewTableFlag && dbInfo.isSupportUserSchema(); + if (!isNotExcuteChangeOwner) { + // do with table user change + String changeOwnerDDL = getChangeOwnerDDL(); + if (StringUtil.isNotEmpty(changeOwnerDDL)) { + changeOwnerDDL = dbInfo.wrapShardQuery(changeOwnerDDL); + if (CompatibleUtil.isSupportChangeOwnerWithAlterStatement(dbInfo)) { + commonSqlTask.addSqls(changeOwnerDDL); + } else { + commonSqlTask.addCallSqls(changeOwnerDDL); + } + isExecuteCommonSqlTask = true; } - isExecuteCommonSqlTask = true; } schemaDDL.setEndLineChar(";"); @@ -510,7 +524,7 @@ protected void okPressed() { int nullColSize = nullToDefaultChangedColumnList.size(); for (int colIndex = 0; colIndex < nullColSize; colIndex++) { UpdateNullToDefault updateNullToDefault = new UpdateNullToDefault(dbInfo); - updateNullToDefault.setTable(tableName); + updateNullToDefault.setTable(getTableName()); updateNullToDefault.setColumn(nullToDefaultChangedColumnList.get(colIndex)); updateNullToDefault.setDefaultValue(defaultValList.get(colIndex)); taskJobExec.addTask(updateNullToDefault); @@ -526,7 +540,7 @@ protected void okPressed() { String serverName = database.getServer().getName(); String dbName = database.getDatabaseInfo().getDbName(); String title = getSite().getShell().getText(); - jobName = title + " - " + tableName + "@" + dbName; + jobName = title + " - " + owner + "." + className + "@" + dbName; JobFamily jobFamily = new JobFamily(); jobFamily.setServerName(serverName); @@ -558,7 +572,7 @@ private List getUpdateDescriptionTaskList(DatabaseInfo db continue; } else { updateDescriptionTaskList.add(new UpdateDescriptionTask( - Messages.updateDescriptionTask, dbInfo, tableName, newAttr.getName(), + Messages.updateDescriptionTask, dbInfo, getTableName(), newAttr.getName(), newAttr.getDescription())); } } @@ -571,7 +585,7 @@ private List getUpdateDescriptionTaskList(DatabaseInfo db if (oldSchemaInfo == null || notSameDescription) { UpdateDescriptionTask task = new UpdateDescriptionTask( - Messages.updateDescriptionTask, dbInfo, tableName, null, + Messages.updateDescriptionTask, dbInfo, getTableName(), null, newSchemaInfo.getDescription()); updateDescriptionTaskList.add(task); } @@ -670,13 +684,19 @@ private String getChangeOwnerDDL() { // FIXME move this logic to core module return ""; } - String tableName = tableNameText.getText(); - + String className = classNameText.getText(); + String TableName; + if (database.getDatabaseInfo().isSupportUserSchema()) { + TableName = oldOwner + "." + className; + } else { + TableName = className; + } + ServerInfo serverInfo = database.getServer().getServerInfo(); if (CompatibleUtil.isSupportChangeOwnerWithAlterStatement(serverInfo)) { - return schemaDDL.getChangeOwnerDDLWithAlterStatement(tableName, newOwner); + return schemaDDL.getChangeOwnerDDLWithAlterStatement(TableName, newOwner); } else { - return schemaDDL.getChangeOwnerDDL(tableName, newOwner); + return schemaDDL.getChangeOwnerDDL(className, newOwner); } } @@ -713,24 +733,33 @@ private void createGeneralTabItem(final TabFolder tabFolder) { tableNameComp.setLayout(gl); tableNameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - tableNameText = new Text(tableNameComp, SWT.BORDER); - tableNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH); + classNameText = new Text(tableNameComp, SWT.BORDER); + classNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH); { GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false); gd.widthHint = 200; - tableNameText.setLayoutData(gd); + classNameText.setLayoutData(gd); } - tableNameText.addModifyListener(new ModifyListener() { + classNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { - if (tableNameText.getText().length() == 0) { + if (classNameText.getText().length() == 0) { CommonUITool.hideErrorBaloon(errorBaloon); } else if (verifyTableName()) { - String tableName = tableNameText.getText(); - newSchemaInfo.setClassname(tableName); + String className = classNameText.getText(); + newSchemaInfo.setClassname(className); + if (isSupportUserSchema()) { + if (ownerCombo != null && !ownerCombo.getText().isEmpty()) { + newSchemaInfo.setUniqueName(ownerCombo.getText() + "." + className); + } else { + newSchemaInfo.setUniqueName(className); + } + } else { + newSchemaInfo.setUniqueName(className); + } } } }); - tableNameText.addFocusListener(new FocusAdapter() { + classNameText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { CommonUITool.hideErrorBaloon(errorBaloon); } @@ -781,18 +810,18 @@ public void widgetDefaultSelected(SelectionEvent e) { final Label tableDescLabel = new Label(group, SWT.NONE); tableDescLabel.setText(Messages.lblTableDesc); - tableDescText = new Text(group, SWT.BORDER); - tableDescText.setTextLimit(512); - tableDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + classDescText = new Text(group, SWT.BORDER); + classDescText.setTextLimit(512); + classDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); if (newSchemaInfo != null && newSchemaInfo.getDescription() != null) { - tableDescText.setText(newSchemaInfo.getDescription()); + classDescText.setText(newSchemaInfo.getDescription()); } - tableDescText.addFocusListener(new FocusAdapter() { + classDescText.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { if (!isSupportTableComment) { - CommonUITool.showErrorBaloon(group, tableDescText, errorBaloon, "", + CommonUITool.showErrorBaloon(group, classDescText, errorBaloon, "", Messages.errNotSupportTableCommentNotice); - tableDescText.setFocus(); + classDescText.setFocus(); } } @@ -800,7 +829,7 @@ public void focusLost(FocusEvent e) { CommonUITool.hideErrorBaloon(errorBaloon); } }); - tableDescText.setEditable(isSupportTableComment); + classDescText.setEditable(isSupportTableComment); if (database == null) { return; @@ -1090,7 +1119,7 @@ private void handleSelectionChangeInColumnTable() { TableItem[] tblItems = columnsTable.getSelection(); DBAttribute attr = (DBAttribute) tblItems[0].getData(); boolean isInheritAttr = attr.getInherit() != null - && !tableNameText.getText().trim().equalsIgnoreCase(attr.getInherit().trim()); + && !classNameText.getText().trim().equalsIgnoreCase(attr.getInherit().trim()); deleteColumnBtn.setEnabled(!isInheritAttr); if (selectionCount > 1) { @@ -1126,7 +1155,7 @@ private void handleSelectionChangeInColumnTable() { for (DBAttribute dbAttr : attrList) { boolean isInheritDbAttr = dbAttr.getInherit() != null && dbAttr.getInherit().trim().length() > 0 - && !tableNameText.getText().trim().equalsIgnoreCase( + && !classNameText.getText().trim().equalsIgnoreCase( dbAttr.getInherit().trim()); if (isInheritDbAttr) { inheritAttrCount++; @@ -1164,7 +1193,7 @@ private void handleSelectionChangeInColumnTable() { public boolean isHasSubClass() { if (isHasSubClass == null) { CheckSubClassTask task = new CheckSubClassTask(database.getDatabaseInfo()); - isHasSubClass = task.checkSubClass(oldSchemaInfo.getClassname()); + isHasSubClass = task.checkSubClass(oldSchemaInfo.getOwner(), oldSchemaInfo.getClassname()); } return isHasSubClass; @@ -1254,7 +1283,7 @@ private void firePKAdded(SchemaInfo newSchema, Constraint newPK) { // FIXME move String attrName = attrList.get(0); Constraint index = newSchema.removeUniqueByAttrName(attrName); if (index != null) { - String key = index.getDefaultName(newSchema.getClassname()) + "$" + String key = index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key, null, SchemeInnerType.TYPE_INDEX); @@ -1309,7 +1338,7 @@ public void firePKRemoved(SchemaInfo newSchema, Constraint oldPK) { // FIXME mov String attrName = attrList.get(0); Constraint index = newSchema.removeUniqueByAttrName(attrName); if (index != null) { - String key = index.getDefaultName(newSchema.getClassname()) + "$" + String key = index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key, null, SchemeInnerType.TYPE_INDEX); @@ -1469,7 +1498,7 @@ public void addNewColumn() { // FIXME move this logic to core module String newAttrName = ""; DBAttribute addAttribute = new DBAttribute(newAttrName, DataType.DATATYPE_CHAR, - newSchemaInfo.getClassname(), false, false, false, false, null, collation); + newSchemaInfo.getUniqueName(), false, false, false, false, null, collation); addAttribute.setNew(true); tempDBAttributeList.add(addAttribute); loadColumnData(); @@ -1494,7 +1523,7 @@ public boolean changeForEditAttribute(String attrName, DBAttribute editAttr, return false; } - String tableName = newSchemaInfo.getClassname(); + String tableName = newSchemaInfo.getUniqueName(); editAttr.setInherit(tableName); String newAttrName = editAttr.getName(); @@ -1596,7 +1625,7 @@ public boolean makeChangeLogForIndex(String attrName, DBAttribute editAttr, DBAt } addedConstrainList.add(newCons); - String key = cons.getDefaultName(newSchemaInfo.getClassname()) + "$" + String key = cons.getDefaultName(newSchemaInfo.getUniqueName()) + "$" + cons.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key, key, SchemeInnerType.TYPE_INDEX); @@ -1680,7 +1709,7 @@ private void deleteColumn() { // FIXME move this logic to core module if (oldAttribute == null) { continue; } - if (!oldAttribute.getInherit().equals(newSchemaInfo.getClassname())) { + if (!oldAttribute.getInherit().equals(newSchemaInfo.getUniqueName())) { CommonUITool.openErrorBox(Messages.errColumnNotDrop); return; } @@ -2038,7 +2067,7 @@ public void widgetSelected(SelectionEvent event) { loadColumnData(); } - String key = constraint.getDefaultName(newSchemaInfo.getClassname()) + "$" + String key = constraint.getDefaultName(newSchemaInfo.getUniqueName()) + "$" + constraint.getName(); schemaChangeMgr.addSchemeChangeLog(new SchemaChangeLog(null, key, SchemeInnerType.TYPE_INDEX)); @@ -2114,9 +2143,9 @@ private void openEditIndexDialog(Constraint editedIndex) { } } - String key1 = editedIndex.getDefaultName(newSchemaInfo.getClassname()) + "$" + String key1 = editedIndex.getDefaultName(newSchemaInfo.getUniqueName()) + "$" + editedIndex.getName(); - String key2 = newIndex.getDefaultName(newSchemaInfo.getClassname()) + "$" + String key2 = newIndex.getDefaultName(newSchemaInfo.getUniqueName()) + "$" + newIndex.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key1, key2, SchemeInnerType.TYPE_INDEX); schemaChangeMgr.addSchemeChangeLog(changeLog); @@ -2172,7 +2201,7 @@ public void widgetSelected(SelectionEvent event) { } newSchemaInfo.removeConstraintByName(indexName, indexType); - String key = index.getDefaultName(newSchemaInfo.getClassname()) + "$" + String key = index.getDefaultName(newSchemaInfo.getUniqueName()) + "$" + index.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key, null, SchemeInnerType.TYPE_INDEX); @@ -2189,35 +2218,39 @@ private void init() { String owner = null; String title = null; + if (oldSchemaInfo == null) { + owner = database.getUserName(); + } else { + owner = oldSchemaInfo.getOwner(); + } + + for (int i = 0, length = ownerCombo.getItemCount(); i < length; i++) { + String item = ownerCombo.getItem(i); + if (item != null && item.equalsIgnoreCase(owner)) { + ownerCombo.select(i); + break; + } + } if (oldSchemaInfo == null) { title = Messages.newTableShellTitle; - tableNameText.setText(""); - owner = database.getUserName(); + classNameText.setText(""); if (reuseOIDBtn != null) { reuseOIDBtn.setSelection(true); } } else { - String tableName = oldSchemaInfo.getClassname(); + String className = oldSchemaInfo.getClassname(); + String tableName = oldSchemaInfo.getUniqueName(); title = Messages.bind(Messages.editTableShellTitle, tableName); - tableNameText.setText(tableName); - tableNameText.setEnabled(false); - owner = oldSchemaInfo.getOwner(); + classNameText.setText(className); + classNameText.setEnabled(false); if (reuseOIDBtn != null) { reuseOIDBtn.setSelection(oldSchemaInfo.isReuseOid()); } } getSite().getShell().setText(title); - for (int i = 0, length = ownerCombo.getItemCount(); i < length; i++) { - String item = ownerCombo.getItem(i); - if (item != null && item.equalsIgnoreCase(owner)) { - ownerCombo.select(i); - break; - } - } - loadColumnData(); } @@ -2275,21 +2308,21 @@ private void fillCollationCombo() { * @return */ private boolean verifyTableName() { - if (WidgetUtil.disposed(tableNameText)) { + if (WidgetUtil.disposed(classNameText)) { return false; } - if (tableNameText.getEnabled()) { - String tableName = tableNameText.getText(); + if (classNameText.getEnabled()) { + String className = classNameText.getText(); String msg = null; - if (StringUtil.isEmpty(tableName)) { + if (StringUtil.isEmpty(className)) { msg = Messages.errNoTableName; } else { boolean canNotUseMultibytes = ValidateUtil.notSupportMB(database) - && ValidateUtil.notASCII(tableName); + && ValidateUtil.notASCII(className); - if (!ValidateUtil.isValidIdentifier(tableName)) { - msg = Messages.bind(Messages.renameInvalidTableNameMSG, "table", tableName); + if (!ValidateUtil.isValidIdentifier(className)) { + msg = Messages.bind(Messages.renameInvalidTableNameMSG, "table", className); } else if (canNotUseMultibytes) { msg = Messages.errMultiBytes; } else { @@ -2297,8 +2330,8 @@ private boolean verifyTableName() { } } - CommonUITool.showErrorBaloon(tableNameComp, tableNameText, errorBaloon, "", msg); - tableNameText.setFocus(); + CommonUITool.showErrorBaloon(tableNameComp, classNameText, errorBaloon, "", msg); + classNameText.setFocus(); return false; } @@ -2358,7 +2391,7 @@ private void addPosAttrLog(DBAttribute attribute) { * @param unique */ private void addNewUniqueLog(Constraint unique) { - String key = newSchemaInfo.getClassname() + "$" + unique.getName(); + String key = newSchemaInfo.getUniqueName() + "$" + unique.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(null, key, SchemeInnerType.TYPE_INDEX); schemaChangeMgr.addSchemeChangeLog(changeLog); } @@ -2373,7 +2406,7 @@ private void addDelUniqueLog(Constraint unique) { return; } - String key = newSchemaInfo.getClassname() + "$" + unique.getName(); + String key = newSchemaInfo.getUniqueName() + "$" + unique.getName(); SchemaChangeLog changeLog = new SchemaChangeLog(key, null, SchemeInnerType.TYPE_INDEX); schemaChangeMgr.addSchemeChangeLog(changeLog); } @@ -2417,7 +2450,7 @@ private void loadPartitionInfoList() { if (isPartitionTable) { GetPartitionedClassListTask task = new GetPartitionedClassListTask( database.getDatabaseInfo()); - List list = task.getPartitionItemList(newSchemaInfo.getClassname()); + List list = task.getPartitionItemList(newSchemaInfo.getUniqueName()); partitionInfoList.clear(); if (!ArrayUtil.isEmpty(list)) { @@ -2472,12 +2505,25 @@ private void createPartitionTabButtons(Composite parent) { addPartitionBtn.setText(Messages.btnAddPartition); addPartitionBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - String tableName = tableNameText.getText(); - if (tableName.trim().length() == 0) { + String ownerName = ownerCombo.getText(); + if (ownerName.trim().length() == 0) { CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName); return; } - newSchemaInfo.setClassname(tableName); + + String className = classNameText.getText(); + if (className.trim().length() == 0) { + CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName); + return; + } + + newSchemaInfo.setOwner(ownerName); + newSchemaInfo.setClassname(className); + if (isSupportUserSchema()) { + newSchemaInfo.setUniqueName(ownerName + "." + className); + } else { + newSchemaInfo.setUniqueName(className); + } Wizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, null); @@ -2573,13 +2619,26 @@ private void editPartition() { partitionInfo = (PartitionInfo) selection.getFirstElement(); } - String tableName = tableNameText.getText(); - if (WidgetUtil.disposed(tableNameText) || StringUtil.isEmpty(tableName)) { + String ownerName = ownerCombo.getText(); + if (WidgetUtil.disposed(ownerCombo) || StringUtil.isEmpty(ownerName)) { CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName); return; } - - newSchemaInfo.setClassname(tableName); + + String className = classNameText.getText(); + if (WidgetUtil.disposed(classNameText) || StringUtil.isEmpty(className)) { + CommonUITool.openErrorBox(getSite().getShell(), Messages.msgNoTableName); + return; + } + + newSchemaInfo.setOwner(ownerName); + newSchemaInfo.setClassname(className); + if (database.getDatabaseInfo().isSupportUserSchema()) { + newSchemaInfo.setUniqueName(ownerName + "." + className); + } else { + newSchemaInfo.setUniqueName(className); + } + CreatePartitionWizard wizard = new CreatePartitionWizard(database.getDatabaseInfo(), newSchemaInfo, partitionInfoList, isNewTableFlag, partitionInfo); CMWizardDialog dialog = new CMWizardDialog(getSite().getShell(), wizard); @@ -2688,12 +2747,20 @@ public void setDbUserList(List dbUserList) { public IStatus postTaskFinished(ITask task) { if (database != null && database.getDatabaseInfo() != null && task instanceof CommonSQLExcuterTask) { - database.getDatabaseInfo().removeSchema(tableName); + database.getDatabaseInfo().removeSchema(getTableName()); } return Status.OK_STATUS; } public void completeAll() { + boolean isSupportUserSchema = database.getDatabaseInfo().isSupportUserSchema(); + String tableName; + if (isSupportUserSchema) { + tableName = owner + "." + className; + } else { + tableName = className; + } + CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgNull2DefComplete, jobName)); @@ -2703,12 +2770,12 @@ public void completeAll() { if (node == null || !node.getLoader().isLoaded()) { return; } - String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName; boolean isPartition = newSchemaInfo.getPartitionList() != null && newSchemaInfo.getPartitionList().size() > 0; - ClassInfo newClassInfo = new ClassInfo(tableName, owner, ClassType.NORMAL, false, - isPartition); + + ClassInfo newClassInfo = new ClassInfo(className, owner, ClassType.NORMAL, false, + isPartition, isSupportUserSchema); ICubridNode newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor()); @@ -2733,7 +2800,7 @@ public void completeAll() { return; } - database.getDatabaseInfo().removeSchema(tableName); + database.getDatabaseInfo().removeSchema(oldSchemaInfo.getUniqueName()); if (oldPartitionInfoList.isEmpty() && !partitionInfoList.isEmpty()) { editedTableNode.setIconPath("icons/navigator/schema_table_partition.png"); editedTableNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER); @@ -2749,8 +2816,15 @@ public void completeAll() { getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false); return; } - + + if (database.getDatabaseInfo().isSupportUserSchema()) { + editedTableNode.setLabel("[" + owner + "] " + className); + } else { + editedTableNode.setLabel(className); + } + editedTableNode.setUniqueName(tableName); CommonUITool.refreshNavigatorTree(treeViewer, editedTableNode); + CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, editedTableNode); CubridNodeManager.getInstance().fireCubridNodeChanged( new CubridNodeChangedEvent(editedTableNode, CubridNodeChangedEventType.NODE_REFRESH)); @@ -2781,8 +2855,9 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException this.supportCharset = CompatibleUtil.isSupportCreateDBByCharset(database.getDatabaseInfo()); if (isNewTableFlag) { newSchemaInfo = new SchemaInfo(); - newSchemaInfo.setClassname(""); //$NON-NLS-1$ newSchemaInfo.setOwner(database.getUserName()); + newSchemaInfo.setClassname(""); //$NON-NLS-1$ + newSchemaInfo.setUniqueName(""); //$NON-NLS-1$ newSchemaInfo.setDbname(database.getName()); newSchemaInfo.setType(Messages.userSchema); newSchemaInfo.setVirtual(Messages.schemaTypeClass); @@ -2820,14 +2895,17 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException IDatabaseSpec dbSpec = database.getDatabaseInfo(); isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn); database.getDatabaseInfo().setSupportTableComment(isSupportTableComment); + if (CompatibleUtil.isAfter112(database.getDatabaseInfo())) { + database.getDatabaseInfo().setSupportUserSchema(true); + } if (isSupportTableComment && !isNewTableFlag && newSchemaInfo != null) { Map map = SchemaCommentHandler.loadDescription(dbSpec, conn, - newSchemaInfo.getClassname()); + database.getDatabaseInfo().isSupportUserSchema(), newSchemaInfo.getUniqueName()); for (DBAttribute attr : newSchemaInfo.getAttributes()) { SchemaComment schemaComment = SchemaCommentHandler.find(map, - newSchemaInfo.getClassname(), attr.getName()); + newSchemaInfo.getUniqueName(), attr.getName()); if (schemaComment != null) { attr.setDescription(schemaComment.getDescription()); } @@ -2838,7 +2916,7 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException if (isCommentSupport) { String indexName = cons.getName(); SchemaComment indexComment = SchemaCommentHandler.loadObjectDescription( - dbSpec, conn, indexName, CommentType.INDEX); + dbSpec, conn, database.getDatabaseInfo().isSupportUserSchema(), indexName, CommentType.INDEX); if (indexComment != null) { cons.setDescription(indexComment.getDescription()); } @@ -2846,7 +2924,7 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException } SchemaComment schemaComment = SchemaCommentHandler.find(map, - newSchemaInfo.getClassname(), null); + newSchemaInfo.getUniqueName(), null); if (schemaComment != null) { newSchemaInfo.setDescription(schemaComment.getDescription()); } @@ -2882,7 +2960,7 @@ public boolean isSaveAsAllowed() { public void setFocus() { if (isNewTableFlag) { - tableNameText.setFocus(); + classNameText.setFocus(); } else { okBtn.setFocus(); } @@ -2997,4 +3075,19 @@ public void removeTempDBAttributeByName(String name) { public boolean isSupportTableComment() { return isSupportTableComment; } + + private boolean isSupportUserSchema() { + if (database != null) { + return database.getDatabaseInfo().isSupportUserSchema(); + } + return false; + } + + private String getTableName() { + if (database.getDatabaseInfo().isSupportUserSchema()) { + return owner + "." + className; + } else { + return className; + } + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/ExportSchemaThread.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/ExportSchemaThread.java index 55b22c62..fc33291c 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/ExportSchemaThread.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/ExportSchemaThread.java @@ -254,7 +254,7 @@ private void exportSerial(String serialFilePath) throws Exception { // FIXME mov task.execute(); boolean isSupportCache = CompatibleUtil.isSupportCache(dbInfo); for (SerialInfo serial : task.getSerialInfoList()) { - fs.write(QueryUtil.createSerialSQLScript(serial, isSupportCache)); + fs.write(QueryUtil.createSerialSQLScript(serial, isSupportCache, dbInfo.isSupportUserSchema())); fs.write(StringUtil.NEWLINE); hasSerial = true; } @@ -284,10 +284,19 @@ private List getAllViewsDDL() { // FIXME move this logic to core module Statement stmt = null; CUBRIDResultSetProxy rs = null; - String sql = "SELECT c.class_name, c.class_type" + " FROM db_class c, db_attribute a" + String sql; + if (dbInfo.isSupportUserSchema()) { + sql = "SELECT c.class_name, c.owner_name, c.class_type" + " FROM db_class c, db_attribute a" + " WHERE c.class_name=a.class_name AND c.is_system_class='NO'" - + " AND c.class_type='VCLASS'" + " GROUP BY c.class_name, c.class_type" - + " ORDER BY c.class_type, c.class_name"; + + " AND c.owner_name=a.owner_name" + + " AND c.class_type='VCLASS'" + " GROUP BY c.owner_name, c.class_name, c.class_type" + + " ORDER BY c.owner_name, c.class_type, c.class_name"; + } else { + sql = "SELECT c.class_name, c.class_type" + " FROM db_class c, db_attribute a" + + " WHERE c.class_name=a.class_name AND c.is_system_class='NO'" + + " AND c.class_type='VCLASS'" + " GROUP BY c.class_name, c.class_type" + + " ORDER BY c.class_type, c.class_name"; + } // [TOOLS-2425]Support shard broker sql = dbInfo.wrapShardQuery(sql); @@ -298,7 +307,14 @@ private List getAllViewsDDL() { // FIXME move this logic to core module rs = (CUBRIDResultSetProxy) stmt.executeQuery(sql); while (rs.next()) { - viewNameList.add(rs.getString(1)); + if (dbInfo.isSupportUserSchema()) { + String className = rs.getString(1); + String ownerName = rs.getString(2); + viewNameList.add(ownerName + "." + className); + } else { + String className = rs.getString(1); + viewNameList.add(className); + } } } catch (Exception e) { LOGGER.error("", e); @@ -311,8 +327,14 @@ private List getAllViewsDDL() { // FIXME move this logic to core module ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); for (String viewName : viewNameList) { - String querySpecSql = "SELECT vclass_def FROM db_vclass WHERE vclass_name='" + String querySpecSql; + if (dbInfo.isSupportUserSchema()) { + querySpecSql = "SELECT vclass_def FROM db_vclass WHERE CONCAT(owner_name, '.' , vclass_name)='" + viewName + "'"; + } else { + querySpecSql = "SELECT vclass_def FROM db_vclass WHERE vclass_name='" + + viewName + "'"; + } // [TOOLS-2425]Support shard broker querySpecSql = dbInfo.wrapShardQuery(querySpecSql); @@ -358,7 +380,7 @@ private String getViewDDL(SchemaInfo viewInfo, DatabaseInfo getDatabaseInfo, Str } else { sb.append("CREATE VIEW "); } - sb.append(QuerySyntax.escapeKeyword(viewInfo.getClassname())); + sb.append(viewInfo.getUniqueName()); sb.append("("); for (DBAttribute addr : viewInfo.getAttributes()) { // "Name", "Data diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/AbsExportDataHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/AbsExportDataHandler.java index c62fa325..5f2bc569 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/AbsExportDataHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/AbsExportDataHandler.java @@ -207,12 +207,12 @@ protected void setIsHasBigValue(String columnType, int precision) { // FIXME mov } } - protected String getSelectSQL(Connection conn, String name) { + protected String getSelectSQL(Connection conn, String name, boolean isSupportUserSchema) { String sql = null; if (exportConfig.getSQL(name) != null) { sql = exportConfig.getSQL(name); } else { - sql = QueryUtil.getSelectSQL(conn, name); + sql = QueryUtil.getSelectSQL(conn, name, isSupportUserSchema); } return sql; } @@ -514,7 +514,7 @@ public static void exportSchemaToOBSFile(DatabaseInfo databaseInfo, task.execute(); boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); for (SerialInfo serial : task.getSerialInfoList()) { - schemaWriter.write(QueryUtil.createSerialSQLScript(serial, isSupportCache)); + schemaWriter.write(QueryUtil.createSerialSQLScript(serial, isSupportCache, databaseInfo.isSupportUserSchema())); schemaWriter.write(StringUtil.NEWLINE); } schemaWriter.flush(); @@ -571,7 +571,7 @@ public static void exportSchemaToOBSFile(DatabaseInfo databaseInfo, triggerNameTask.execute(); triggerList = triggerNameTask.getTriggerInfoList(); for (Trigger t: triggerList) { - triggerWriter.write(TriggerDDL.getDDL(t)); + triggerWriter.write(TriggerDDL.getDDL(t, databaseInfo.isSupportUserSchema())); triggerWriter.write(StringUtil.NEWLINE); } triggerWriter.flush(); @@ -604,7 +604,11 @@ public static String getCurrentValueFromSystemTable(String serialName, DatabaseI sqlbuf.append(QuerySyntax.escapeKeyword("current_val")).append(", "); sqlbuf.append(QuerySyntax.escapeKeyword("increment_val")).append(", "); sqlbuf.append(QuerySyntax.escapeKeyword("started")); - sqlbuf.append(" FROM db_serial WHERE name = '").append(serialName).append("'"); + if (dbInfo.isSupportUserSchema()) { + sqlbuf.append(" FROM db_serial WHERE CONCAT(owner.name, '.', name) = '").append(serialName).append("'"); + } else { + sqlbuf.append(" FROM db_serial WHERE name = '").append(serialName).append("'"); + } String sql = DatabaseInfo.wrapShardQuery(dbInfo, sqlbuf.toString()); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportLoadDBHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportLoadDBHandler.java index b9cc7db4..202ea5bd 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportLoadDBHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportLoadDBHandler.java @@ -142,6 +142,14 @@ public void handle(String nullValue) throws IOException, SQLException { // FIXME } // Export data try { + + if (!exportConfig.isExportData()) { + return; + } + + if (dataTablesName == null) { + return; + } exportDataEventHandler.handleEvent(new ExportDataBeginOneTableEvent(dataTablesName)); fs = FileUtil.getBufferedWriter( @@ -158,7 +166,7 @@ public void handle(String nullValue) throws IOException, SQLException { // FIXME boolean hasNextPage = true; int exportedCount = 0; long beginIndex = 1; - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); isPaginating = isPagination(tableName, sql, whereCondition); boolean isExportedColumnTitles = false; while (hasNextPage) { @@ -215,7 +223,7 @@ public void handle(String nullValue) throws IOException, SQLException { // FIXME if (exportedCount >= COMMIT_LINES) { fs.flush(); exportDataEventHandler.handleEvent(new ExportDataSuccessEvent( - tableName, exportedCount)); + dataTablesName, exportedCount)); exportedCount = 0; } @@ -223,13 +231,13 @@ public void handle(String nullValue) throws IOException, SQLException { // FIXME break; } } - exportDataEventHandler.handleEvent(new ExportDataSuccessEvent(tableName, + exportDataEventHandler.handleEvent(new ExportDataSuccessEvent(dataTablesName, exportedCount)); exportedCount = 0; } catch (SQLException e) { LOGGER.error(e.getMessage(), e); exportDataEventHandler.handleEvent(new ExportDataFailedOneTableEvent( - tableName)); + dataTablesName)); } finally { QueryUtil.freeQuery(rs); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToTxtHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToTxtHandler.java index 2251bbe0..431ffe1b 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToTxtHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToTxtHandler.java @@ -121,7 +121,7 @@ public void exportByQuerying(String tableName) throws IOException, SQLException conn = getConnection(); fs = FileUtil.getBufferedWriter(exportConfig.getDataFilePath(tableName), exportConfig.getFileCharset()); - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); isPaginating = isPagination(tableName, sql, whereCondition); while (hasNextPage) { try { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsHandler.java index b5afc7a9..b3fd1151 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsHandler.java @@ -130,7 +130,7 @@ public void exportByQuerying(String tableName) throws IOException, SQLException WritableSheet sheet = workbook.createSheet("Sheet " + sheetNum, sheetNum); sheetNum++; int exportedCount = 0; - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); isPaginating = isPagination(whereCondition, sql, whereCondition); while (hasNextPage) { try { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsxHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsxHandler.java index 1d9da0c2..f72374cb 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsxHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExportToXlsxHandler.java @@ -146,7 +146,7 @@ public void exportByQuerying(String tableName) throws IOException, SQLException try { conn = getConnection(); - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); isPaginating = isPagination(whereCondition, sql, whereCondition); int exportedCount = 0; while (hasNextPage) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToOBSHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToOBSHandler.java index 3efb2d50..c34475d0 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToOBSHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToOBSHandler.java @@ -127,7 +127,7 @@ public void handle(String tableName) throws IOException, SQLException { // FIXME exportDataEventHandler.handleEvent(new ExportDataBeginOneTableEvent( path)); - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); // [TOOLS-2425]Support shard broker sql = DatabaseInfo.wrapShardQuery(dbInfo, sql); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToSqlHandler.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToSqlHandler.java index b7fcf11b..e65b8084 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToSqlHandler.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/export/handler/ExprotToSqlHandler.java @@ -102,7 +102,7 @@ public void exportByQuerying(String tableName) throws IOException, SQLException conn = getConnection(); fs = FileUtil.getBufferedWriter(exportConfig.getDataFilePath(tableName), exportConfig.getFileCharset()); - String sql = getSelectSQL(conn, tableName); + String sql = getSelectSQL(conn, tableName, dbInfo.isSupportUserSchema()); isPaginating = isPagination(tableName, sql, whereCondition); while (hasNextPage) { try { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportDataViewPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportDataViewPart.java index 0a8e8bd0..87b95829 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportDataViewPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportDataViewPart.java @@ -261,17 +261,24 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException * @param isEnable */ private void setHistroyWidgetStatus(boolean isEnable) { - historyLabel.setEnabled(isEnable); - historyText.setEnabled(isEnable); - saveButton.setEnabled(isEnable); - closeButton.setEnabled(isEnable); + if (historyLabel != null && !historyLabel.isDisposed()) + historyLabel.setEnabled(isEnable); + if (historyText != null && !historyText.isDisposed()) + historyText.setEnabled(isEnable); + if (saveButton != null && !saveButton.isDisposed()) + saveButton.setEnabled(isEnable); + if (closeButton != null && !closeButton.isDisposed()) + closeButton.setEnabled(isEnable); + if (isEnable) { String dateStringNow = DateUtil.getDatetimeStringOnNow("MM/dd HH:mm"); String databaseName = database.getDatabaseInfo().getDbName(); String historyName = Messages.bind(Messages.defaultExportHistoryName, databaseName, dateStringNow); - historyText.setText(historyName); - saveButton.forceFocus(); + if (historyText != null && !historyText.isDisposed()) + historyText.setText(historyName); + if (saveButton != null && !saveButton.isDisposed()) + saveButton.forceFocus(); } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType1.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType1.java index fa0a354e..bf7ae4a1 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType1.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType1.java @@ -131,7 +131,7 @@ public void generateTableDetailSheets(WritableWorkbook wwb, int sheetIndex = 1; for (SchemaInfo schemaInfo : exportSchemaInfoList) { - String tableName = schemaInfo.getClassname(); + String tableName = schemaInfo.getUniqueName(); monitor.subTask(Messages.bind(Messages.exportTableDefinitionProgressTaskWriteTable, tableName)); List supers = SuperClassUtil.getSuperClasses(getProgressObject().getDatabase().getDatabaseInfo(), schemaInfo); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType2.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType2.java index 40d634a3..e651dfd9 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType2.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionLayoutType2.java @@ -131,7 +131,7 @@ public void generateTableDetailSheets(WritableWorkbook wwb, int sheetIndex = 1; for (SchemaInfo schemaInfo : exportSchemaInfoList) { - String tableName = schemaInfo.getClassname(); + String tableName = schemaInfo.getUniqueName(); monitor.subTask(Messages.bind(Messages.exportTableDefinitionProgressTaskWriteTable, tableName)); List supers = SuperClassUtil.getSuperClasses(getProgressObject().getDatabase().getDatabaseInfo(), schemaInfo); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionProgress.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionProgress.java index 53de8be5..cb336707 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionProgress.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/table/progress/ExportTableDefinitionProgress.java @@ -182,12 +182,23 @@ public List getExportTables(Connection conn) { // FIXME move this logic Statement stmt = null; ResultSet rs = null; StringBuilder sql = new StringBuilder(); - sql.append("SELECT c.class_name, c.class_type "); - sql.append("FROM db_class c, db_attribute a "); - sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); - sql.append("AND a.from_class_name IS NULL AND c.class_type='CLASS' "); - sql.append("GROUP BY c.class_name, c.class_type "); - sql.append("ORDER BY c.class_type, c.class_name"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append("SELECT c.class_name, c.class_type, c.owner_name "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sql.append("AND c.owner_name=a.owner_name "); + sql.append("AND a.from_class_name IS NULL AND c.class_type='CLASS' "); + sql.append("GROUP BY c.owner_name, c.class_name, c.class_type "); + sql.append("ORDER BY c.owner_name, c.class_type, c.class_name"); + String query = sql.toString(); + } else { + sql.append("SELECT c.class_name, c.class_type "); + sql.append("FROM db_class c, db_attribute a "); + sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sql.append("AND a.from_class_name IS NULL AND c.class_type='CLASS' "); + sql.append("GROUP BY c.class_name, c.class_type "); + sql.append("ORDER BY c.class_type, c.class_name"); + } String query = sql.toString(); // [TOOLS-2425]Support shard broker @@ -200,6 +211,10 @@ public List getExportTables(Connection conn) { // FIXME move this logic rs = stmt.executeQuery(query); while (rs.next()) { String tableName = rs.getString(1); + if (database.getDatabaseInfo().isSupportUserSchema()) { + String ownerName = rs.getString(3); + tableName = ownerName + "." + tableName; + } if (ConstantsUtil.isExtensionalSystemTable(tableName)) { continue; } @@ -313,7 +328,7 @@ public void loadSchemaCommentData(Connection conn) { // FIXME move this logic to isInstalledMetaTable = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn); if (isInstalledMetaTable) { try { - schemaCommentMap = SchemaCommentHandler.loadDescriptions(dbSpec, conn); + schemaCommentMap = SchemaCommentHandler.loadDescriptions(dbSpec, conn, database.getDatabaseInfo().isSupportUserSchema()); } catch (Exception e) { LOGGER.error("load schema comment error", e); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.java index 0117b5fa..f829f0b3 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.java @@ -137,6 +137,7 @@ public class Messages extends public static String triggersDetailInfoPartEditTriggerBtn; public static String triggersDetailInfoPartDropTriggerBtn; + public static String triggersDetailInfoPartTableOwnerCol; public static String triggersDetailInfoPartTableNameCol; public static String triggersDetailInfoPartTableTargetTableCol; public static String triggersDetailInfoPartTableEventTimeCol; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.properties index 50ceb33a..a9058876 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages.properties @@ -102,6 +102,7 @@ triggersDetailInfoPartEditTriggerBtn=Edit Trigger triggersDetailInfoPartDropTriggerBtn=Drop Trigger triggersDetailInfoPartTitle=Triggers +triggersDetailInfoPartTableOwnerCol=Owner triggersDetailInfoPartTableNameCol=Name triggersDetailInfoPartTableTargetTableCol=Target Table triggersDetailInfoPartTableEventTimeCol=Event Time diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages_ko_KR.properties b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages_ko_KR.properties index 3fb84b11..2558bf39 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages_ko_KR.properties +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/Messages_ko_KR.properties @@ -102,6 +102,7 @@ triggersDetailInfoPartEditTriggerBtn=\ud2b8\ub9ac\uac70 \ud3b8\uc9d1 triggersDetailInfoPartDropTriggerBtn=\ud2b8\ub9ac\uac70 \uc0ad\uc81c triggersDetailInfoPartTitle=\ud2b8\ub9ac\uac70 +triggersDetailInfoPartTableOwnerCol=\uc18c\uc720\uc790 triggersDetailInfoPartTableNameCol=\uc774\ub984 triggersDetailInfoPartTableTargetTableCol=\ub300\uc0c1 \ud14c\uc774\ube14 triggersDetailInfoPartTableEventTimeCol=\uc774\ubca4\ud2b8 \uc2dc\uac04 diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/AlterTriggerAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/AlterTriggerAction.java index e8aa7fbb..85d626df 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/AlterTriggerAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/AlterTriggerAction.java @@ -171,7 +171,7 @@ public boolean exec(final IProgressMonitor monitor) { } } else if (task instanceof JDBCGetTriggerInfoTask) { JDBCGetTriggerInfoTask getTriggerInfoTask = (JDBCGetTriggerInfoTask) task; - trigger = getTriggerInfoTask.getTriggerInfo(node.getLabel()); + trigger = getTriggerInfoTask.getTriggerInfo(node.getName()); } if (trigger == null) { openErrorBox(shell, Messages.errNameNoExist, monitor); @@ -181,9 +181,11 @@ public boolean exec(final IProgressMonitor monitor) { if (CompatibleUtil.isCommentSupports(database.getDatabaseInfo())) { try { SchemaComment schemaComment = SchemaCommentHandler.loadObjectDescription( - database.getDatabaseInfo(), JDBCConnectionManager.getConnection( - database.getDatabaseInfo(), true), trigger.getName(), - CommentType.TRIGGER); + database.getDatabaseInfo(), + JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true), + database.getDatabaseInfo().isSupportUserSchema(), + trigger.getName(), + CommentType.TRIGGER); trigger.setDescription(schemaComment.getDescription()); } catch (SQLException e) { CommonUITool.openErrorBox(e.getMessage()); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/NewTriggerAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/NewTriggerAction.java index 196df7f2..8e3ae245 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/NewTriggerAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/action/NewTriggerAction.java @@ -169,12 +169,14 @@ public void run (CubridDatabase database) { } String triggerName = dlg.getTriggerName().toLowerCase( Locale.getDefault()); + String ownerName = database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName(); String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR - + triggerName; + + ownerName + "." + triggerName; Trigger trigger = new Trigger(); trigger.setName(triggerName); + trigger.setOwner(ownerName); ICubridNode newNode = CubridTriggerFolderLoader.createTriggerNode( - id, trigger); + database.getDatabaseInfo(), id, trigger); CommonUITool.addNodeToTree(treeViewer, folderNode, newNode); CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode); CubridNodeManager.getInstance().fireCubridNodeChanged( diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/dialog/CreateTriggerDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/dialog/CreateTriggerDialog.java index 4f38e656..9f75ce80 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/dialog/CreateTriggerDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/dialog/CreateTriggerDialog.java @@ -27,6 +27,7 @@ */ package com.cubrid.common.ui.cubrid.trigger.dialog; +import java.security.acl.Owner; import java.util.List; import org.eclipse.jface.dialogs.IDialogConstants; @@ -301,6 +302,12 @@ private void executeByJDBC(int buttonId) { // FIXME move this logic to core modu if (StringUtil.isEmpty(createSQL)) { return; } + if (null == trigger) { + ownerName = database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName(); + } else { + ownerName = trigger.getOwner(); + } + triggerName = triggerNameText.getText(); String taskName = null; String message = null; if (buttonId == IDialogConstants.OK_ID) { @@ -318,7 +325,12 @@ private void executeByJDBC(int buttonId) { // FIXME move this logic to core modu taskExecutor.addTask(jdbcTask); new ExecTaskWithProgress(taskExecutor).busyCursorWhile(); if (taskExecutor.isSuccess()) { - triggerName = triggerNameText.getText(); + if(database.getDatabaseInfo().isSupportUserSchema()) { + triggerName = ownerName + "." + triggerNameText.getText(); + } else { + triggerName = triggerNameText.getText(); + } + setReturnCode(buttonId); close(); CommonUITool.openInformationBox(Messages.msgInformation, message); @@ -390,7 +402,11 @@ private void executeBySocket(int buttonId) { // FIXME remove AlterTriggerTask task = new AlterTriggerTask( database.getServer().getServerInfo()); task.setDbName(database.getName()); - task.setTriggerName(trigger.getName()); + if (database.getDatabaseInfo().isSupportUserSchema()) { + task.setTriggerName(trigger.getOwner() + "." + trigger.getName()); + } else { + task.setTriggerName(trigger.getName()); + } String triggerStatus = this.getStatus(); task.setStatus(TriggerStatus.eval(triggerStatus)); @@ -399,7 +415,7 @@ private void executeBySocket(int buttonId) { // FIXME remove task.setPriority(strPriority); taskName = Messages.bind(Messages.alterTriggerTaskName, - trigger.getName()); + task.getTaskname()); message = Messages.alterTriggerSuccess; executedTask = task; } @@ -472,7 +488,15 @@ private void alterInit() { setMessage(Messages.triggerAlterMSG); setTitle(Messages.triggerAlterMSGTitle); + if(database.getDatabaseInfo().isSupportUserSchema()) { + int idx = trigger.getName().indexOf("."); + if (idx > 0) { + trigger.setOwner(trigger.getName().substring(0, idx)); + trigger.setName(trigger.getName().substring(idx +1)); + } + } triggerNameText.setText(trigger.getName()); + ownerName = trigger.getOwner(); String table = trigger.getTarget_class(); if (null == table) { @@ -680,6 +704,10 @@ public void widgetSelected(final SelectionEvent event) { private Trigger getNewTrigger() { // FIXME move this logic to core module Trigger newTrigger = new Trigger(); String triggerName = triggerNameText.getText(); + String owner = null; + if (trigger != null) { + owner = trigger.getOwner(); + } String triggerEventTargetTable = triggerTargetTableCombo.getText().trim(); String triggerEventTargetColumn = triggerTargetColumnCombo.getText().trim(); @@ -701,6 +729,9 @@ private Trigger getNewTrigger() { // FIXME move this logic to core module String strPriority = triggerPriorityText.getText(); newTrigger.setName(triggerName); + if (owner != null && !owner.isEmpty()) { + newTrigger.setOwner(owner); + } newTrigger.setEventType(eventType); newTrigger.setTarget_class(triggerEventTargetTable); newTrigger.setTarget_att(triggerEventTargetColumn); @@ -901,7 +932,8 @@ private void setActionType(String innerActionType) { {Messages.triggerStatusInactive, "INACTIVE" }, }; private List tableList; private String triggerName; - + private String ownerName; + /** * * Get status @@ -1393,5 +1425,5 @@ private StringBuffer generateSqlText() { // FIXME move this logic to core module public String getTriggerName() { return triggerName; } - + } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/editor/TriggerDashboardEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/editor/TriggerDashboardEditorPart.java index 49c0e39b..0525259e 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/editor/TriggerDashboardEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/trigger/editor/TriggerDashboardEditorPart.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; @@ -159,6 +160,15 @@ public void createTriggersDetailInfoTable(Composite parent) { triggersDetailInfoTable.getTable().setHeaderVisible(true); triggersDetailInfoTable.getTable().setLinesVisible(true); + final TableViewerColumn ownerColumn = new TableViewerColumn( + triggersDetailInfoTable, SWT.LEFT); + if (database != null && database.getDatabaseInfo().isSupportUserSchema()) { + ownerColumn.getColumn().setWidth(80); + } else { + ownerColumn.getColumn().setWidth(0); + } + ownerColumn.getColumn().setText(Messages.triggersDetailInfoPartTableOwnerCol); + final TableViewerColumn nameColumn = new TableViewerColumn( triggersDetailInfoTable, SWT.LEFT); nameColumn.getColumn().setWidth(150); @@ -411,17 +421,31 @@ public String getColumnText(Object element, int columnIndex) { if (element instanceof Trigger) { Trigger trigger = (Trigger)element; if (trigger != null) { + String owner; + String name = trigger.getName(); + if (database.getDatabaseInfo().isSupportUserSchema()) { + int idx = name.indexOf("."); + if (idx > 0) { + owner = name.substring(0, idx).toUpperCase(Locale.getDefault()); + name = name.substring(idx + 1); + } else { + owner = ""; + } + } else { + owner = ""; + } switch (columnIndex) { - case 0 : return trigger.getName(); - case 1 : return trigger.getTarget_class(); - case 2 : return trigger.getEventType(); - case 3 : - return trigger.getStatus(); + case 0 : return owner; + case 1 : return name; + case 2 : return trigger.getTarget_class(); + case 3 : return trigger.getEventType(); case 4 : + return trigger.getStatus(); + case 5 : return trigger.getPriority(); - case 5 : - return trigger.getActionTime(); case 6 : + return trigger.getActionTime(); + case 7 : return trigger.getActionType(); } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/user/dialog/EditUserDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/user/dialog/EditUserDialog.java index 953696c5..4161d9e3 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/user/dialog/EditUserDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/user/dialog/EditUserDialog.java @@ -555,13 +555,13 @@ public void widgetSelected(SelectionEvent event) { for (int id : idx) { String tableName = authTable.getItem(id).getText(0); for (ClassInfo bean : allClassInfoList) { - if (tableName.equals(bean.getClassName())) { + if (tableName.equals(bean.getUniqueName())) { if (bean.isSystemClass()) { CommonUITool.openErrorBox(parentComp.getShell(), Messages.errRemoveSysClass); return; } else { Map map = new HashMap(); - map.put("0", bean.getClassName()); + map.put("0", bean.getUniqueName()); map.put("1", bean.isSystemClass() ? Messages.msgSystemSchema : Messages.msgUserSchema); map.put("2", bean.getOwnerName()); map.put("3", bean.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass); @@ -624,7 +624,7 @@ public boolean canModify(Object element, String property) { } String name = (String) map.get("0"); for (ClassInfo bean : allClassInfoList) { - if (name.equals(bean.getClassName())) { + if (name.equals(bean.getUniqueName())) { if (bean.isSystemClass()) { return false; } else if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) { @@ -949,13 +949,13 @@ private void initial() { if (!DB_DBA_USERNAME.equalsIgnoreCase(userName) && !isDBAGroup()) { authTableViewer.refresh(); for (ClassInfo bean : allClassInfoList) { - if (classGrantMap.containsKey(bean.getClassName()) + if (classGrantMap.containsKey(bean.getUniqueName()) || bean.isSystemClass() || bean.getOwnerName().equalsIgnoreCase(DB_DEFAULT_USERNAME)) { continue; } Map map = new HashMap(); - map.put("0", bean.getClassName()); + map.put("0", bean.getUniqueName()); map.put("1", Messages.msgUserSchema); map.put("2", bean.getOwnerName()); map.put("3", bean.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass); @@ -1062,7 +1062,7 @@ private void setAuthBtnEnableDisable() { ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText()); boolean ownertag = false; for (ClassInfo bean : allClassInfoList) { - if (item.getText().equals(bean.getClassName())) { + if (item.getText().equals(bean.getUniqueName())) { if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) { ownertag = true; } @@ -1083,7 +1083,7 @@ private void setAuthBtnEnableDisable() { ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText()); boolean ownertag = false; for (ClassInfo bean : allClassInfoList) { - if (item.getText().equals(bean.getClassName())) { + if (item.getText().equals(bean.getUniqueName())) { if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) { ownertag = true; } @@ -1480,7 +1480,7 @@ public boolean isSystemClass(String name) { return false; } for (ClassInfo bean : allClassInfoList) { - if (bean.getClassName().equals(name) && bean.isSystemClass()) { + if (bean.getUniqueName().equals(name) && bean.isSystemClass()) { return false; } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardComposite.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardComposite.java index b6b72bb8..ddb198b3 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardComposite.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardComposite.java @@ -93,7 +93,7 @@ public void initialize() { } public void setInput(SchemaInfo schema) { - tabItem.setText(schema == null ? "" : schema.getClassname()); + tabItem.setText(schema == null ? "" : schema.getUniqueName()); columnTableView.setInput(schema.getAttributes()); columnTableView.refresh(); pack(); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardEditorPart.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardEditorPart.java index 2be82781..e9a3a770 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardEditorPart.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/cubrid/view/editor/ViewDashboardEditorPart.java @@ -195,6 +195,11 @@ public void createViewsDetailInfoTable(Composite parent) { viewsDetailInfoTable.getTable().setHeaderVisible(true); viewsDetailInfoTable.getTable().setLinesVisible(true); + final TableViewerColumn ownerColumn = new TableViewerColumn( + viewsDetailInfoTable, SWT.LEFT); + ownerColumn.getColumn().setWidth(80); + ownerColumn.getColumn().setText(Messages.viewDetailInfoPartTableOwnerColumn); + final TableViewerColumn columnViewName = new TableViewerColumn( viewsDetailInfoTable, SWT.LEFT); columnViewName.getColumn().setWidth(150); @@ -205,11 +210,6 @@ public void createViewsDetailInfoTable(Composite parent) { scriptDescColumn.getColumn().setWidth(200); scriptDescColumn.getColumn().setText(Messages.viewDetailInfoPartTableDefColumn); - final TableViewerColumn ownerColumn = new TableViewerColumn( - viewsDetailInfoTable, SWT.LEFT); - ownerColumn.getColumn().setWidth(80); - ownerColumn.getColumn().setText(Messages.viewDetailInfoPartTableOwnerColumn); - viewsDetailInfoTable.setContentProvider(new ViewsDetailTableViewerContentProvider()); viewsDetailInfoTable.setLabelProvider(new ViewsDetailTableViewerLabelProvider()); @@ -219,7 +219,7 @@ public void doubleClick(DoubleClickEvent event) { ViewDetailInfo oneViewDetail = (ViewDetailInfo)selection.getFirstElement(); //if had opend,set it selection for (CTabItem tabItem : tabFolder.getItems()) { - if (tabItem.getText().equals(oneViewDetail.getViewName())) { + if (tabItem.getText().equals(oneViewDetail.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema()))) { tabFolder.setSelection(tabItem); return; } @@ -228,7 +228,7 @@ public void doubleClick(DoubleClickEvent event) { ViewDashboardComposite viewComp = new ViewDashboardComposite(tabFolder, SWT.NONE); viewComp.initialize(); - SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName()); + SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema())); viewComp.setInput(schemaInfo); } @@ -361,7 +361,7 @@ public void setInputs() { viewComp.initialize(); if (viewList.size() > 0) { ViewDetailInfo oneViewDetail = viewList.get(0); - SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName()); + SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema())); viewComp.setInput(schemaInfo); } } @@ -405,7 +405,7 @@ public void editView() { Set typeSet = new HashSet(); typeSet.add(NodeType.USER_VIEW); - ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewName()); + ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema())); if (viewNode != null) { EditViewAction action = (EditViewAction) ActionManager.getInstance().getAction(EditViewAction.ID); if (action.run(database, (ISchemaNode) viewNode) == IDialogConstants.OK_ID) { @@ -427,7 +427,7 @@ public void dropView() { typeSet.add(NodeType.USER_VIEW); ICubridNode viewNode = CommonUITool.findNode(database, typeSet, - viewInfo.getViewName()); + viewInfo.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema())); selectNodeList.add((ISchemaNode)viewNode); } @@ -462,7 +462,7 @@ public void addView() { */ public boolean findItemName(String itemName) { for (ViewDetailInfo view : viewList) { - if(view.getViewName().equals(itemName)) { + if(view.getViewUniqueName(database.getDatabaseInfo().isSupportUserSchema()).equals(itemName)) { return true; } } @@ -522,9 +522,9 @@ public String getColumnText(Object element, int columnIndex) { ViewDetailInfo viewDetail = (ViewDetailInfo)element; if (viewDetail != null) { switch (columnIndex) { - case 0 : return viewDetail.getViewName(); - case 1 : return viewDetail.getViewDef(); - case 2 : return viewDetail.getViewOwnerName(); + case 0 : return viewDetail.getViewOwnerName(); + case 1 : return viewDetail.getViewName(); + case 2 : return viewDetail.getViewDef(); } } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/CubridSchemaInfoManager.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/CubridSchemaInfoManager.java index 33e6d0c9..9f6ec557 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/CubridSchemaInfoManager.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/CubridSchemaInfoManager.java @@ -59,10 +59,10 @@ public void addSchemaInfo(SchemaInfo schemaInfo) { if (schemaInfo == null) { return; } - if (schemaInfoMap.get(schemaInfo.getClassname()) != null) { + if (schemaInfoMap.get(schemaInfo.getUniqueName()) != null) { return; } - schemaInfoMap.put(schemaInfo.getClassname(), schemaInfo); + schemaInfoMap.put(schemaInfo.getUniqueName(), schemaInfo); } public void removeSchemaInfo(String name) { @@ -76,10 +76,10 @@ public void removeSchemaInfo(SchemaInfo schemaInfo) { if (schemaInfo == null) { return; } - if (schemaInfoMap.get(schemaInfo.getClassname()) == null) { + if (schemaInfoMap.get(schemaInfo.getUniqueName()) == null) { return; } - schemaInfoMap.remove(schemaInfo.getClassname()); + schemaInfoMap.remove(schemaInfo.getUniqueName()); } public void cleanAllSchemaInfos() { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/AbstractSelectionAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/AbstractSelectionAction.java index ee64339c..8d6ae310 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/AbstractSelectionAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/AbstractSelectionAction.java @@ -150,6 +150,7 @@ protected DatabaseInfo getDatabaseInfo() { return getDataBaseNode().getDatabaseInfo(); } + public IStatus postTaskFinished(ITask task) { return null; } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/ModifyTableNameAction.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/ModifyTableNameAction.java index 2798bafd..ced36d25 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/ModifyTableNameAction.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/action/ModifyTableNameAction.java @@ -92,13 +92,14 @@ protected boolean calculateEnabled() { public void run() { PropertyChangeProvider node = getSelectedNode(); boolean isPhysicModel = getERSchema().isPhysicModel(); + boolean isSupportUserSchema = getERSchema().getCubridDatabase().getDatabaseInfo().isSupportUserSchema(); String oldName = ((ERTable) node).getShownName(); Set names = getERSchema().getAllShownTableNames(); names.remove(oldName); RenameTableDialog dlg = new RenameTableDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), oldName, true, - new ArrayList(names), isPhysicModel); + new ArrayList(names), isPhysicModel, isSupportUserSchema); int ret = dlg.open(); if (ret == IDialogConstants.OK_ID) { String newName = dlg.getNewName(); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/commands/AddTableCommand.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/commands/AddTableCommand.java index 9fc3aebb..9305a68a 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/commands/AddTableCommand.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/commands/AddTableCommand.java @@ -55,6 +55,7 @@ public void execute() { this.erTable.modifyNameAndFire(name); this.erTable.setERSchema(erSchema); schemaInfo.setClassname(name); + schemaInfo.setUniqueName(name); erSchema.addTableAndFire(erTable); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dialog/EditVirtualTableDialog.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dialog/EditVirtualTableDialog.java index 255fc731..81614e4e 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dialog/EditVirtualTableDialog.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dialog/EditVirtualTableDialog.java @@ -210,6 +210,7 @@ public EditVirtualTableDialog(Shell parentShell, CubridDatabase database, boolea if (isNewTable) { SchemaInfo newSchemaInfo = new SchemaInfo(); newSchemaInfo.setClassname(""); //$NON-NLS-1$ + newSchemaInfo.setUniqueName(""); //$NON-NLS-1$ newSchemaInfo.setOwner(database.getUserName()); newSchemaInfo.setDbname(database.getName()); newSchemaInfo.setType(Messages.userSchema); @@ -349,7 +350,7 @@ protected void okPressed() { //check ERSchema tmpErSchema = new ERSchema(erSchema.getName() + "_tmp", erSchema.getInput()); Map schemaInfos = erSchema.getAllSchemaInfo(); - schemaInfos.put(newSchemaInfo.getClassname(), newSchemaInfo); + schemaInfos.put(newSchemaInfo.getUniqueName(), newSchemaInfo); CubridTableParser tableParser = new CubridTableParser(tmpErSchema); tableParser.buildERTables(schemaInfos.values(), -1, -1, false); @@ -534,7 +535,7 @@ private void syncLogicalNameAndPhysicalComment() { String oldTableDesc = oldSchemaInfo.getDescription(); oldSchemaInfo.setDescription(newTableDesc); if (StringUtil.isEmpty(newTableDesc)) { - oldERTable.setName(newSchemaInfo.getClassname(), false); + oldERTable.setName(newSchemaInfo.getUniqueName(), false); } if (StringUtil.isNotEmpty(newTableDesc) && !StringUtil.isEqual(newTableDesc, oldTableDesc)) { @@ -843,6 +844,12 @@ public void modifyText(ModifyEvent event) { } else if (verifyTableName()) { String tableName = tableNameText.getText(); newSchemaInfo.setClassname(tableName); + newSchemaInfo.setOwner(database.getUserName()); + if (isSupportUserSchema()) { + newSchemaInfo.setUniqueName(database.getUserName() + "." + tableName); + } else { + newSchemaInfo.setUniqueName(tableName); + } } } }); @@ -1050,7 +1057,7 @@ private void handleSelectionChangeInColumnTable() { public boolean isHasSubClass() { if (isHasSubClass == null) { CheckSubClassTask task = new CheckSubClassTask(database.getDatabaseInfo()); - isHasSubClass = task.checkSubClass(oldSchemaInfo.getClassname()); + isHasSubClass = task.checkSubClass(oldSchemaInfo.getOwner(), oldSchemaInfo.getClassname()); } return isHasSubClass; @@ -1330,7 +1337,7 @@ public void addNewColumn() { } DBAttribute addAttribute = new DBAttribute("", DataType.DATATYPE_CHAR, - newSchemaInfo.getClassname(), false, false, false, false, null, collation); + newSchemaInfo.getUniqueName(), false, false, false, false, null, collation); ERTableColumn column = new ERTableColumn(newERTable, addAttribute, false); column.setIsNew(true); tempERColumnList.add(column); @@ -2376,4 +2383,11 @@ public ERSchema getErSchema() { public void setErSchema(ERSchema erSchema) { this.erSchema = erSchema; } + + private boolean isSupportUserSchema() { + if (database != null) { + return database.getDatabaseInfo().isSupportUserSchema(); + } + return false; + } } \ No newline at end of file diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dnd/ERDNDController.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dnd/ERDNDController.java index bf07411d..0c4e7aff 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dnd/ERDNDController.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/dnd/ERDNDController.java @@ -58,6 +58,7 @@ import com.cubrid.common.core.common.model.SchemaInfo; import com.cubrid.common.core.schemacomment.SchemaCommentHandler; import com.cubrid.common.core.schemacomment.model.SchemaComment; +import com.cubrid.common.core.util.CompatibleUtil; import com.cubrid.common.core.util.QueryUtil; import com.cubrid.common.core.util.StringUtil; import com.cubrid.common.ui.er.SchemaEditorInput; @@ -154,9 +155,9 @@ private void addTables(List schemaInfoList, int x, int y) { Iterator it = schemaInfoList.iterator(); while (it.hasNext()) { SchemaInfo table = (SchemaInfo) it.next(); - ERTable existTable = erSchema.getTable(table.getClassname()); + ERTable existTable = erSchema.getTable(table.getUniqueName()); if (existTable != null) { - existTables.add(table.getClassname()); + existTables.add(table.getUniqueName()); it.remove(); continue; } @@ -235,22 +236,25 @@ private void getDescInformation(SchemaInfo newSchemaInfo, .isInstalledMetaTable(dbSpec, conn); database.getDatabaseInfo().setSupportTableComment( isSupportTableComment); + if (CompatibleUtil.isAfter112(database.getDatabaseInfo())) { + database.getDatabaseInfo().setSupportUserSchema(true); + } if (isSupportTableComment && newSchemaInfo != null) { Map map = SchemaCommentHandler - .loadDescription(dbSpec, conn, - newSchemaInfo.getClassname()); + .loadDescription(dbSpec, conn, database.getDatabaseInfo().isSupportUserSchema(), + newSchemaInfo.getUniqueName()); for (DBAttribute attr : newSchemaInfo.getAttributes()) { SchemaComment schemaComment = SchemaCommentHandler.find( - map, newSchemaInfo.getClassname(), attr.getName()); + map, newSchemaInfo.getUniqueName(), attr.getName()); if (schemaComment != null) { attr.setDescription(schemaComment.getDescription()); } } SchemaComment schemaComment = SchemaCommentHandler.find(map, - newSchemaInfo.getClassname(), null); + newSchemaInfo.getUniqueName(), null); if (schemaComment != null) { newSchemaInfo .setDescription(schemaComment.getDescription()); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/editor/ERSchemaEditor.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/editor/ERSchemaEditor.java index 594fe015..c6798641 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/editor/ERSchemaEditor.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/editor/ERSchemaEditor.java @@ -474,7 +474,7 @@ private List getUpdateDescriptionTaskList(DatabaseInfo db Map dbSchemaInfoMap = task.getSchemas(); String taskName = com.cubrid.common.ui.cubrid.table.Messages.updateDescriptionTask; for (SchemaInfo newSchemaInfo : erdSchemaInfos) { - String tableName = newSchemaInfo.getClassname(); + String tableName = newSchemaInfo.getUniqueName(); SchemaInfo dbSchemaInfo = dbSchemaInfoMap.get(tableName); if (dbSchemaInfo == null) { continue; @@ -523,7 +523,7 @@ public void compareDDL2DB() { for (String tableName : schemaInfos.keySet()) { SchemaInfo schemaInfo = schemaInfos.get(tableName); - if (schemaInfo == null || !tableName.equals(schemaInfo.getClassname())) { + if (schemaInfo == null || !tableName.equals(schemaInfo.getUniqueName())) { continue; } @@ -643,7 +643,7 @@ private List generateSqls(Collection erdSchemaInfos) } boolean isAddLine = false; - String tableName = newSchemaInfo.getClassname(); + String tableName = newSchemaInfo.getUniqueName(); if (isSupportOnServer) { String description = String.format("'%s'", newSchemaInfo.getDescription()); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/CubridTableParser.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/CubridTableParser.java index cffe6f89..836a6a61 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/CubridTableParser.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/CubridTableParser.java @@ -99,11 +99,11 @@ public void buildERTables(Collection schemaInfos, int startX, int st return; } for (SchemaInfo schemaInfo : schemaInfos) { - if (erSchema.getTable(schemaInfo.getClassname()) != null) { - existedTableNames.add(schemaInfo.getClassname()); + if (erSchema.getTable(schemaInfo.getUniqueName()) != null) { + existedTableNames.add(schemaInfo.getUniqueName()); continue; } - this.schemaInfos.put(schemaInfo.getClassname(), schemaInfo); + this.schemaInfos.put(schemaInfo.getUniqueName(), schemaInfo); } Set tables = this.schemaInfos.keySet(); @@ -111,9 +111,9 @@ public void buildERTables(Collection schemaInfos, int startX, int st SchemaInfo schemaInfo = this.schemaInfos.get(name); ERTable erTable = null; try { - if (erSchema.getTable(schemaInfo.getClassname()) != null) { + if (erSchema.getTable(schemaInfo.getUniqueName()) != null) { // the table has been built by referenced table - erTable = erSchema.getTable(schemaInfo.getClassname()); + erTable = erSchema.getTable(schemaInfo.getUniqueName()); } else { erTable = new ERTable(schemaInfo, erSchema); boolean success = erSchema.addTable(erTable); @@ -229,7 +229,7 @@ public void addFKShip(ERTable erTable, SchemaInfo schemaInfo, Constraint fkConst // load it and do not build the relationship and delete the // constraint schemaInfo.removeFKConstraint(fkConstaint); - addEle2RemovedFKConstraints(schemaInfo.getClassname(), fkConstaint); + addEle2RemovedFKConstraints(schemaInfo.getUniqueName(), fkConstaint); return; } if (StringUtil.isEqualNotIgnoreNull(referencedTableName, erTable.getName())) {// self reference FK @@ -238,10 +238,10 @@ public void addFKShip(ERTable erTable, SchemaInfo schemaInfo, Constraint fkConst if (referenceNames.size() != referredPkColumnNames.size()) { throw new ERException(Messages.bind(Messages.errFKColumnMatch, new String[] { - schemaInfo.getClassname(), fkConstaint.getName() })); + schemaInfo.getUniqueName(), fkConstaint.getName() })); } - ERTable referencedT = erSchema.getTable(referencedTable.getClassname()); + ERTable referencedT = erSchema.getTable(referencedTable.getUniqueName()); boolean needBuildRefedTable = false; if (referencedT == null && !isSelfRef) { referencedT = new ERTable(referencedTable, erSchema); @@ -307,7 +307,7 @@ private List getReferredColumns(SchemaInfo schemaInfo, Constraint fkCons Constraint pkConstaint = referedSchemaInfo.getPK(); if (pkConstaint == null) { throw new ERException(Messages.bind(Messages.errFKColumnMatch, new String[] { - schemaInfo.getClassname(), fkConstaint.getName() })); + schemaInfo.getUniqueName(), fkConstaint.getName() })); } List pklist = pkConstaint.getAttributes(); for (int i = 0; i < pklist.size(); i++) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/ERTable.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/ERTable.java index ca2e1223..1390fbbd 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/ERTable.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/er/model/ERTable.java @@ -84,7 +84,7 @@ public ERTable() { public ERTable(SchemaInfo schemaInfo, ERSchema erSchema) { super(); - this.name = schemaInfo.getClassname(); + this.name = schemaInfo.getUniqueName(); this.schemaInfo = schemaInfo; this.erSchema = erSchema; initDefaultLogicalInfo(schemaInfo); @@ -95,7 +95,7 @@ private void initDefaultLogicalInfo(SchemaInfo schemaInfo) { if (StringUtil.isNotEmpty(desc)) { logicalName = desc; } else { - logicalName = schemaInfo.getClassname(); + logicalName = schemaInfo.getUniqueName(); } } @@ -153,6 +153,7 @@ public static SchemaInfo createEmptySchemaInfo(String tableName, String dbName) SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.setType("user"); schemaInfo.setClassname(tableName); + schemaInfo.setUniqueName(tableName); schemaInfo.setDbname(dbName); schemaInfo.setVirtual(ClassType.NORMAL.getText()); schemaInfo.setReuseOid(false); @@ -635,6 +636,7 @@ public void modifyNameAndFire(String name) { if (!name.equals(oldName)) { this.name = name; schemaInfo.setClassname(name); + schemaInfo.setUniqueName(name); updateSourceTableConstraint(oldName, name); firePropertyChange(TEXT_CHANGE, null, name); } @@ -924,6 +926,7 @@ public void setName(String name) { if (!name.equals(oldName)) { this.name = name; this.schemaInfo.setClassname(name); + this.schemaInfo.setUniqueName(name); } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/control/QueryPlanCompositeWithHistory.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/control/QueryPlanCompositeWithHistory.java index 51501d82..aa44bfd7 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/control/QueryPlanCompositeWithHistory.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/control/QueryPlanCompositeWithHistory.java @@ -514,7 +514,7 @@ public void widgetSelected(SelectionEvent event) { CommonUITool.openErrorBox(Messages.msgPlanEditTable); return; } - ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null); + ISchemaNode node = new DefaultSchemaNode(tableName, tableName, tableName, null); node.setDatabase(editor.getSelectedDatabase()); EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID); if (action == null) { @@ -537,7 +537,7 @@ public void widgetSelected(SelectionEvent event) { CommonUITool.openErrorBox(Messages.msgPlanEditIndex); return; } - ISchemaNode node = new DefaultSchemaNode(tableName, tableName, null); + ISchemaNode node = new DefaultSchemaNode(tableName, tableName, tableName, null); node.setDatabase(editor.getSelectedDatabase()); EditTableAction action = (EditTableAction) ActionManager.getInstance().getAction(EditTableAction.ID); if (action == null) { diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalAdvisor.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalAdvisor.java index 15cfca18..d51e9393 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalAdvisor.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalAdvisor.java @@ -171,7 +171,7 @@ protected IStatus run(IProgressMonitor monitor) { continue; } - String tableName = schemaInfo.getClassname(); + String tableName = schemaInfo.getUniqueName(); if (ConstantsUtil.isExtensionalSystemTable(tableName)) { continue; } @@ -216,7 +216,7 @@ protected IStatus run(IProgressMonitor monitor) { schemaInfo, attr); colInfoList.add(colInfo); } - columns.put(schemaInfo.getClassname(), colInfoList); + columns.put(schemaInfo.getUniqueName(), colInfoList); } /*Cache the data*/ ColumnProposal proposal = new ColumnProposal(); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalDetailInfo.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalDetailInfo.java index 196cfaac..572eaf6d 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalDetailInfo.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/query/editor/ColumnProposalDetailInfo.java @@ -196,7 +196,7 @@ public static void fillInTableColumnInfo(DatabaseInfo dbInfo, List fetchedTableNames = new ArrayList(); for (SchemaInfo schemaInfo : schemas.values()) { - String tableName = schemaInfo.getClassname(); + String tableName = schemaInfo.getUniqueName(); fetchedTableNames.add(tableName); } @@ -231,7 +231,7 @@ public static void fillInTableColumnInfo(DatabaseInfo dbInfo, colInfoList.add(colInfo); } - columns.put(schemaInfo.getClassname(), colInfoList); + columns.put(schemaInfo.getUniqueName(), colInfoList); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/CubridDatabase.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/CubridDatabase.java index e909d2a8..ed3b655a 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/CubridDatabase.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/CubridDatabase.java @@ -57,7 +57,7 @@ public class CubridDatabase extends * @param label */ public CubridDatabase(String id, String label) { - super(id, label, ""); + super(id, label, label, ""); setType(NodeType.DATABASE); setDatabase(this); setContainer(true); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultCubridNode.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultCubridNode.java index 57dde2ef..3c1ceb33 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultCubridNode.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultCubridNode.java @@ -59,6 +59,7 @@ public class DefaultCubridNode implements private String editorId = null; private String viewId = null; private String label = ""; + private String schemaName = ""; private ICubridNode parent = null; private boolean isRoot = false; private String iconPath = ""; @@ -83,8 +84,19 @@ public DefaultCubridNode(String id, String label, String iconPath) { isRoot = false; childList = new ArrayList(); objMap = new HashMap(); + this.schemaName = label; } + public DefaultCubridNode(String id, String label, String schemaName, String iconPath) { + this.id = id; + this.label = label; + this.iconPath = iconPath; + isRoot = false; + childList = new ArrayList(); + objMap = new HashMap(); + this.schemaName = schemaName; + } + /** * Get whether it is container node * @@ -518,7 +530,7 @@ public IPersistableElement getPersistable() { * @return the name string; never null; */ public String getName() { - return getLabel(); + return schemaName; } /** @@ -533,7 +545,7 @@ public String getToolTipText() { String tipText = getLabel(); ICubridNode parent = getParent(); while (parent != null) { - tipText = parent.getLabel() + "/" + tipText; + tipText = parent.getName() + "/" + tipText; parent = parent.getParent(); } return tipText; @@ -639,4 +651,8 @@ public DefaultCubridNode clone() throws CloneNotSupportedException { DefaultCubridNode obj = (DefaultCubridNode) super.clone();; return obj; } + + public void setUniqueName(String tableName) { + this.schemaName = tableName; + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultSchemaNode.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultSchemaNode.java index 334308c8..e4c81fac 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultSchemaNode.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/DefaultSchemaNode.java @@ -39,6 +39,7 @@ public class DefaultSchemaNode extends ISchemaNode { private CubridDatabase cubridDatabase = null; + private String UniqueName = null; /** * The constructor @@ -49,6 +50,13 @@ public class DefaultSchemaNode extends */ public DefaultSchemaNode(String id, String label, String iconPath) { super(id, label, iconPath); + this.UniqueName = label; + } + + + public DefaultSchemaNode(String id, String label, String UniqueName, String iconPath) { + super(id, label, UniqueName, iconPath); + this.UniqueName = UniqueName; } /** @@ -133,5 +141,12 @@ public DefaultSchemaNode clone() throws CloneNotSupportedException{ return obj; } + @Override + public String getName() { + return this.UniqueName; + } + public void setUniqueName(String UniqueName) { + this.UniqueName = UniqueName; + } } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/ICubridNode.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/ICubridNode.java index 05301dfd..9446a3f8 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/ICubridNode.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/ICubridNode.java @@ -310,4 +310,6 @@ public interface ICubridNode extends * @return Object */ public Object getData(String key); + + public void setUniqueName(String tableName); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/MoreTablesNode.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/MoreTablesNode.java index ae5a407f..e38242ce 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/MoreTablesNode.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/MoreTablesNode.java @@ -82,7 +82,7 @@ private void makeChildren() { for (int i = currentIndex, j = 0; i < nextIndex; i++, j++) { ClassInfo classInfo = userTableInfoList.get(i); String id = moreNode.getId() + ICubridNodeLoader - .NODE_SEPARATOR + classInfo.getClassName(); + .NODE_SEPARATOR + classInfo.getUniqueName(); ICubridNode child = CubridTablesFolderLoader .createClassNode(id, classInfo, 1); children[j] = child; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridSerialFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridSerialFolderLoader.java index 943a9ec5..81201c36 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridSerialFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridSerialFolderLoader.java @@ -59,7 +59,7 @@ public class CubridSerialFolderLoader extends CubridNodeLoader { public static final String SERIAL_FOLDER_ID = "Serials"; - + /** * * Load children object for parent @@ -108,8 +108,8 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { for (SerialInfo serialInfo : serialInfoList) { authSerialInfoList.add(serialInfo); String id = parent.getId() + NODE_SEPARATOR - + serialInfo.getName(); - ICubridNode serialNode = createSerialNode(id, serialInfo); + + serialInfo.getOwner() + "." + serialInfo.getName(); + ICubridNode serialNode = createSerialNode(databaseInfo, id, serialInfo); parent.addChild(serialNode); } } @@ -130,13 +130,24 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { * @param serialInfo The model object * @return ICubridNode */ - public static ICubridNode createSerialNode(String id, SerialInfo serialInfo) { - ICubridNode serialNode = new DefaultSchemaNode(id, - serialInfo.getName(), "icons/navigator/serial_item.png"); + public static ICubridNode createSerialNode(DatabaseInfo databaseInfo, String id, SerialInfo serialInfo) { + ICubridNode serialNode; + if (databaseInfo.isSupportUserSchema()) { + serialNode= new DefaultSchemaNode(id, + "[" + serialInfo.getOwner() + "] " + serialInfo.getName(), + serialInfo.getOwner() + "." + serialInfo.getName(), + "icons/navigator/serial_item.png"); + } else { + serialNode= new DefaultSchemaNode(id, + serialInfo.getName(), + serialInfo.getName(), "icons/navigator/serial_item.png"); + } serialNode.setId(id); serialNode.setType(NodeType.SERIAL); serialNode.setModelObj(serialInfo); serialNode.setContainer(false); return serialNode; } + + } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridTriggerFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridTriggerFolderLoader.java index 50739491..54e4f6d8 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridTriggerFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/CubridTriggerFolderLoader.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.List; +import java.util.Locale; import org.eclipse.core.runtime.IProgressMonitor; @@ -121,9 +122,23 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { } if (triggerList != null && !triggerList.isEmpty()) { for (Trigger trigger : triggerList) { - String id = parent.getId() + NODE_SEPARATOR + if (databaseInfo.isSupportUserSchema()) { + int idx = trigger.getName().indexOf("."); + if (idx > 0) { + String triggerName = trigger.getName(); + trigger.setOwner(triggerName.substring(0, idx)); + trigger.setName(triggerName.substring(idx+1)); + } + } + String id; + if (trigger.getOwner() != null && !trigger.getOwner().isEmpty()) { + id = parent.getId() + NODE_SEPARATOR + + trigger.getOwner()+ "." + trigger.getName(); + } else { + id = parent.getId() + NODE_SEPARATOR + trigger.getName(); - ICubridNode triggerNode = createTriggerNode(id, trigger); + } + ICubridNode triggerNode = createTriggerNode(databaseInfo, id, trigger); parent.addChild(triggerNode); } } @@ -144,9 +159,17 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { * @param trigger The model object * @return ICubridNode */ - public static ICubridNode createTriggerNode(String id, Trigger trigger) { - ICubridNode triggerNode = new DefaultSchemaNode(id, trigger.getName(), - "icons/navigator/trigger_item.png"); + public static ICubridNode createTriggerNode(DatabaseInfo databaseInfo, String id, Trigger trigger) { + ICubridNode triggerNode; + if (databaseInfo.isSupportUserSchema()) { + triggerNode = new DefaultSchemaNode(id, + "[" + trigger.getOwner().toUpperCase(Locale.getDefault()) + "] " + trigger.getName(), + trigger.getOwner() + "." + trigger.getName(), + "icons/navigator/trigger_item.png"); + } else { + triggerNode = new DefaultSchemaNode(id, trigger.getName(),trigger.getName(), + "icons/navigator/trigger_item.png"); + } triggerNode.setType(NodeType.TRIGGER); triggerNode.setModelObj(trigger); triggerNode.setContainer(false); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridPartitionedTableLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridPartitionedTableLoader.java index d469b287..ec081063 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridPartitionedTableLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridPartitionedTableLoader.java @@ -88,7 +88,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { monitorCancel(monitor, new ITask[] {task}); - List classInfoList = task.getAllPartitionedClassInfoList(parent.getLabel()); + List classInfoList = task.getAllPartitionedClassInfoList(parent.getName()); final String errorMsg = task.getErrorMsg(); if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) { @@ -110,14 +110,23 @@ public void run() { parent.removeAllChild(); if (classInfoList != null && !classInfoList.isEmpty()) { - for (ClassInfo clasInfo : classInfoList) { + for (ClassInfo classInfo : classInfoList) { String id = parent.getId() + NODE_SEPARATOR - + clasInfo.getClassName(); - ICubridNode partitionedClassNode = new DefaultSchemaNode( - id, clasInfo.getClassName(), + + classInfo.getUniqueName(); + + ICubridNode partitionedClassNode; + if (databaseInfo.isSupportUserSchema()) { + partitionedClassNode = new DefaultSchemaNode( + id, classInfo.getClassName() + " (" + classInfo.getOwnerName() + ")", + classInfo.getUniqueName(), "icons/navigator/schema_table_item.png"); + } else { + partitionedClassNode = new DefaultSchemaNode( + id, classInfo.getClassName(), classInfo.getClassName(), + "icons/navigator/schema_table_item.png"); + } partitionedClassNode.setType(NodeType.USER_PARTITIONED_TABLE); - partitionedClassNode.setModelObj(clasInfo); + partitionedClassNode.setModelObj(classInfo); partitionedClassNode.setContainer(false); partitionedClassNode.setEditorId(SchemaInfoEditorPart.ID); parent.addChild(partitionedClassNode); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemTableFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemTableFolderLoader.java index 260093f1..82eb3d31 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemTableFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemTableFolderLoader.java @@ -102,9 +102,9 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { if (allClassInfoList != null) { for (ClassInfo classInfo : allClassInfoList) { String id = parent.getId() + NODE_SEPARATOR - + classInfo.getClassName(); + + classInfo.getUniqueName(); ICubridNode classNode = new DefaultSchemaNode(id, - classInfo.getClassName(), + classInfo.getUniqueName(), classInfo.getUniqueName(), "icons/navigator/schema_table_item.png"); classNode.setType(NodeType.SYSTEM_TABLE); classNode.setEditorId(SchemaInfoEditorPart.ID); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemViewFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemViewFolderLoader.java index 6a740bea..74be4f89 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemViewFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridSystemViewFolderLoader.java @@ -27,6 +27,7 @@ */ package com.cubrid.common.ui.spi.model.loader.schema; +import java.security.acl.Owner; import java.util.Collections; import java.util.List; @@ -102,9 +103,9 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { if (allClassInfoList != null) { for (ClassInfo classInfo : allClassInfoList) { String id = parent.getId() + NODE_SEPARATOR - + classInfo.getClassName(); + + classInfo.getUniqueName(); ICubridNode classNode = new DefaultSchemaNode(id, - classInfo.getClassName(), + classInfo.getUniqueName(), classInfo.getUniqueName(), "icons/navigator/schema_view_item.png"); classNode.setType(NodeType.SYSTEM_VIEW); classNode.setEditorId(SchemaInfoEditorPart.ID); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridTablesFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridTablesFolderLoader.java index e61f2292..60169419 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridTablesFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridTablesFolderLoader.java @@ -123,7 +123,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { parent.removeAllChild(); if (systemTableFolder == null) { systemTableFolder = new DefaultSchemaNode(systemTableFolderId, - SYSTEM_TABLE_FOLDER_NAME, "icons/navigator/folder_sys.png"); + SYSTEM_TABLE_FOLDER_NAME, SYSTEM_TABLE_FOLDER_NAME, "icons/navigator/folder_sys.png"); systemTableFolder.setType(NodeType.SYSTEM_TABLE_FOLDER); systemTableFolder.setContainer(true); ICubridNodeLoader loader = new CubridSystemTableFolderLoader(); @@ -171,10 +171,10 @@ private void createUserTableNodes(ICubridNode parent, for (int i = 0; i < TABLE_COUNT; i++) { ClassInfo classInfo = allClassInfoList.get(i); String id = parent.getId() + NODE_SEPARATOR - + classInfo.getClassName(); + + classInfo.getUniqueName(); ICubridNode classNode = createClassNode(id, classInfo, level); parent.addChild(classNode); - tables.add(classInfo.getClassName()); + tables.add(classInfo.getUniqueName()); } if (allClassInfoList.size() > TABLE_COUNT) { parent.addChild(createMoreNode(parent, TABLE_COUNT)); @@ -207,10 +207,10 @@ public void run() { } for (ClassInfo classInfo : allClassInfoList) { String tableId = parent.getId() + NODE_SEPARATOR - + classInfo.getClassName(); + + classInfo.getUniqueName(); ICubridNode node = parent.getChild(tableId); CubridUserTableLoader tableLoader = (CubridUserTableLoader) node.getLoader(); - tableLoader.setColumns(columnsOfTable.get(classInfo.getClassName())); + tableLoader.setColumns(columnsOfTable.get(classInfo.getUniqueName())); node.getChildren(monitor); tableLoader.setLoaded(true); } @@ -219,9 +219,17 @@ public void run() { } public static ICubridNode createClassNode(String id, ClassInfo classInfo, int level) { - ICubridNode classNode = new DefaultSchemaNode(id, - classInfo.getClassName(), + String tableName = classInfo.getUniqueName(); + ICubridNode classNode; + if (classInfo.isSupportUserSchema()) { + classNode = new DefaultSchemaNode(id, + "[" + classInfo.getOwnerName() + "] " + classInfo.getClassName(), + tableName, "icons/navigator/schema_table_item.png"); + } else { + classNode = new DefaultSchemaNode(id, + tableName, tableName, "icons/navigator/schema_table_item.png"); + } classNode.setEditorId(SchemaInfoEditorPart.ID); classNode.setContainer(true); classNode.setModelObj(classInfo); @@ -245,7 +253,7 @@ public static ICubridNode createClassNode(String id, ClassInfo classInfo, int le public static ICubridNode createMoreNode(ICubridNode parent, int endOfNodePosition) { String id = parent.getId() + NODE_SEPARATOR + endOfNodePosition; ICubridNode classNode = new DefaultSchemaNode(id, - Messages.moreNodeLabel, "icons/navigator/schema_table_item.png"); + Messages.moreNodeLabel, Messages.moreNodeLabel, "icons/navigator/schema_table_item.png"); classNode.setEditorId(SchemaInfoEditorPart.ID); classNode.setType(NodeType.MORE); classNode.setContainer(true); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableColumnLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableColumnLoader.java index aab29b18..c90c4063 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableColumnLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableColumnLoader.java @@ -102,7 +102,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { column.getPrecision(), column.getScale()); String nodeId = parentId + NODE_SEPARATOR + column.getColumnName(); - ICubridNode node = new DefaultSchemaNode(nodeId, label, + ICubridNode node = new DefaultSchemaNode(nodeId, label, label, "icons/navigator/table_column_item.png"); if (column.isPrimaryKey()) { node.setIconPath("icons/primary_key.png"); @@ -136,7 +136,7 @@ private boolean getColumns(ICubridNode parent, final GetUserClassColumnsTask task = new GetUserClassColumnsTask( databaseInfo); monitorCancel(monitor, new ITask[] {task}); - String tableName = parent.getParent().getLabel(); + String tableName = parent.getParent().getName(); columns = task.getColumns(tableName); final String errorMsg = task.getErrorMsg(); if (!monitor.isCanceled() && errorMsg != null diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableIndexLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableIndexLoader.java index 0e36595f..29a088cf 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableIndexLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableIndexLoader.java @@ -87,7 +87,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { monitorCancel(monitor, new ITask[] {task}); - String tableName = parent.getParent().getLabel(); + String tableName = parent.getParent().getName(); List indexes = task.getIndexesNames(tableName); final String errorMsg = task.getErrorMsg(); if (!monitor.isCanceled() && errorMsg != null @@ -111,6 +111,7 @@ public void run() { if (indexes != null && !indexes.isEmpty()) { for (TableIndex index : indexes) { String indexName = index.getIndexName(); + String ownerName = index.getOwnerName(); String nodeId = parentId + NODE_SEPARATOR + indexName; String label = indexName; @@ -120,7 +121,7 @@ public void run() { label += keyAttrName.replace('[', '(').replace(']', ')'); } - ICubridNode node = new DefaultSchemaNode(nodeId, label, + ICubridNode node = new DefaultSchemaNode(nodeId, label, label, "icons/navigator/table_index_item.png"); if (index.isPrimaryKey()) { node.setIconPath("icons/primary_key.png"); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableLoader.java index 927a7456..321fdc44 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridUserTableLoader.java @@ -103,7 +103,7 @@ protected void loadIndexes(ICubridNode parent, int level, ICubridNode indexFolder = parent.getChild(indexFolderId); if (indexFolder == null) { indexFolder = new DefaultSchemaNode(indexFolderId, - INDEX_FOLDER_NAME, "icons/navigator/folder.png"); + INDEX_FOLDER_NAME, INDEX_FOLDER_NAME, "icons/navigator/folder.png"); indexFolder.setType(NodeType.TABLE_INDEX_FOLDER); indexFolder.setContainer(true); parent.addChild(indexFolder); @@ -134,7 +134,7 @@ protected void loadColumns(ICubridNode parent, int level, ICubridNode columnFolder = parent.getChild(columnFolderId); if (columnFolder == null) { columnFolder = new DefaultSchemaNode(columnFolderId, - COLUMN_FOLDER_NAME, "icons/navigator/folder.png"); + COLUMN_FOLDER_NAME, COLUMN_FOLDER_NAME, "icons/navigator/folder.png"); columnFolder.setType(NodeType.TABLE_COLUMN_FOLDER); columnFolder.setContainer(true); parent.addChild(columnFolder); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridViewsFolderLoader.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridViewsFolderLoader.java index 0d3057f7..5d2b1207 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridViewsFolderLoader.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/model/loader/schema/CubridViewsFolderLoader.java @@ -112,7 +112,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { parent.removeAllChild(); if (systemViewFolder == null) { systemViewFolder = new DefaultSchemaNode(systemViewFolderId, - SYSTEM_VIEW_FOLDER_NAME, "icons/navigator/folder_sys.png"); + SYSTEM_VIEW_FOLDER_NAME, SYSTEM_VIEW_FOLDER_NAME, "icons/navigator/folder_sys.png"); systemViewFolder.setType(NodeType.SYSTEM_VIEW_FOLDER); systemViewFolder.setContainer(true); ICubridNodeLoader loader = new CubridSystemViewFolderLoader(); @@ -133,7 +133,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { if (allClassInfoList != null) { for (ClassInfo classInfo : allClassInfoList) { String id = parent.getId() + NODE_SEPARATOR - + classInfo.getClassName(); + + classInfo.getUniqueName(); ICubridNode classNode = createUserViewNode(id, classInfo); parent.addChild(classNode); } @@ -156,9 +156,18 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { * @return ICubridNode */ public static ICubridNode createUserViewNode(String id, ClassInfo classInfo) { - ICubridNode classNode = new DefaultSchemaNode(id, - classInfo.getClassName(), + String viewName = classInfo.getUniqueName(); + String viewClassName = classInfo.getClassName(); + ICubridNode classNode; + if (classInfo.isSupportUserSchema()) { + classNode = new DefaultSchemaNode(id, + "[" + classInfo.getOwnerName() + "] " + viewClassName, viewName, "icons/navigator/schema_view_item.png"); + } else { + classNode = new DefaultSchemaNode(id, + viewClassName, viewName, + "icons/navigator/schema_view_item.png"); + } classNode.setType(NodeType.USER_VIEW); classNode.setEditorId(SchemaInfoEditorPart.ID); classNode.setContainer(false); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/LoadTableDetailInfoTask.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/LoadTableDetailInfoTask.java index 10c779c1..7188d860 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/LoadTableDetailInfoTask.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/LoadTableDetailInfoTask.java @@ -231,7 +231,7 @@ public void execute() { // FIXME move this logic to core module } } try{ - Map commentMap = SchemaCommentHandler.loadTableDescriptions(database.getDatabaseInfo(), connection); + Map commentMap = SchemaCommentHandler.loadTableDescriptions(database.getDatabaseInfo(), connection, database.getDatabaseInfo().isSupportUserSchema()); SchemaComment schemaComment = SchemaCommentHandler.find(commentMap, tableInfo.getTableName(), null); if(schemaComment != null) { tableInfo.setTableDesc(schemaComment.getDescription()); diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenTablesDetailInfoPartProgress.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenTablesDetailInfoPartProgress.java index 9a9103a1..8ccf2426 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenTablesDetailInfoPartProgress.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenTablesDetailInfoPartProgress.java @@ -44,16 +44,28 @@ public OpenTablesDetailInfoPartProgress (CubridDatabase database) { public boolean loadUserSchemaList(Connection conn, Map tablesMap) { // FIXME move this logic to core module final int LIMIT_TABLE_COUNT = 500; - StringBuilder sql = new StringBuilder() - .append("SELECT \n") - .append(" class_name, \n") - .append(" class_type, \n") - .append(" partitioned \n") - .append("FROM \n") - .append(" db_class \n") - .append("WHERE \n") - .append(" is_system_class = 'NO'"); - + StringBuilder sql = new StringBuilder(); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append("SELECT \n"); + sql.append(" class_name, \n"); + sql.append(" class_type, \n"); + sql.append(" partitioned, \n"); + sql.append(" owner_name \n"); + sql.append("FROM \n"); + sql.append(" db_class \n"); + sql.append("WHERE \n"); + sql.append(" is_system_class = 'NO'"); + } else { + sql.append("SELECT \n"); + sql.append(" class_name, \n"); + sql.append(" class_type, \n"); + sql.append(" partitioned \n"); + sql.append("FROM \n"); + sql.append(" db_class \n"); + sql.append("WHERE \n"); + sql.append(" is_system_class = 'NO'"); + } + String query = sql.toString(); // [TOOLS-2425]Support shard broker @@ -76,6 +88,10 @@ public boolean loadUserSchemaList(Connection conn, Map String tableName = rs.getString(1); String classType = rs.getString(2); String partitioned = rs.getString(3); + if (database.getDatabaseInfo().isSupportUserSchema()) { + String OwnerName = rs.getString(4); + tableName = OwnerName + "." + tableName; + } TableDetailInfo info = new TableDetailInfo(); tablesMap.put(tableName, info); @@ -154,9 +170,14 @@ public boolean loadUserSchemaList(Connection conn, Map .append(" \"data_type\" = 'BIT VARYING' THEN 1 \n") .append(" ELSE 0 \n") .append(" END ) AS size_over_column, \n") - .append(" MAX(c.class_type) AS class_type, \n") - .append(" MAX(c.partitioned) AS partitioned \n") - .append("FROM \n") + .append(" MAX(c.class_type) AS class_type, \n"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append(" MAX(c.partitioned) AS partitioned, \n") + .append(" c.owner_name \n"); + } else { + sql.append(" MAX(c.partitioned) AS partitioned \n"); + } + sql.append("FROM \n") .append(" db_class c, \n") .append(" db_attribute a \n") .append("WHERE \n") @@ -166,8 +187,14 @@ public boolean loadUserSchemaList(Connection conn, Map .append(" AND \n") .append(" c.class_type = 'CLASS' \n") .append(" AND \n") - .append(" a.from_class_name IS NULL \n") - .append("GROUP BY c.class_name\n"); + .append(" a.from_class_name IS NULL \n"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append(" AND \n") + .append(" c.owner_name = a.owner_name \n") + .append("GROUP BY c.owner_name, c.class_name\n"); + } else { + sql.append("GROUP BY c.class_name\n"); + } query = sql.toString(); @@ -188,7 +215,11 @@ public boolean loadUserSchemaList(Connection conn, Map boolean columnOverSize = rs.getInt(4) > 0; String classType = rs.getString(5); String partitioned = rs.getString(6); - + if (database.getDatabaseInfo().isSupportUserSchema()) { + String OwnerName = rs.getString(7); + tableName = OwnerName + "." + tableName; + } + TableDetailInfo info = null; if (tablesMap.containsKey(tableName)) { info = tablesMap.get(tableName); @@ -237,9 +268,14 @@ public boolean loadUserSchemaList(Connection conn, Map .append(" i.is_unique = 'NO' \n") .append(" AND \n") .append(" i.is_primary_key = 'NO' THEN 1 \n") - .append(" ELSE 0 \n") - .append(" END ) AS count_index \n") - .append("FROM \n") + .append(" ELSE 0 \n"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append(" END ) AS count_index, \n") + .append(" c.owner_name \n"); + } else { + sql.append(" END ) AS count_index \n"); + } + sql.append("FROM \n") .append(" db_class c, \n") .append(" db_index_key k, \n") .append(" db_index i \n") @@ -248,16 +284,26 @@ public boolean loadUserSchemaList(Connection conn, Map .append(" AND \n") .append(" k.class_name = i.class_name \n") .append(" AND \n") - .append(" k.index_name = i.index_name \n") - .append(" AND \n") + .append(" k.index_name = i.index_name \n"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append(" AND \n") + .append(" c.owner_name = k.owner_name \n") + .append(" AND \n") + .append(" k.owner_name = i.owner_name \n"); + } + sql.append(" AND \n") .append(" c.class_type = 'CLASS' \n") .append(" AND \n") .append(" c.is_system_class = 'NO' \n") .append(" AND \n") .append(" i.key_count >= 1 \n") .append(" AND \n") - .append(" NOT EXISTS (SELECT 1 FROM db_partition p WHERE c.class_name = LOWER(p.partition_class_name)) \n") - .append("GROUP BY c.class_name;\n"); + .append(" NOT EXISTS (SELECT 1 FROM db_partition p WHERE c.class_name = LOWER(p.partition_class_name)) \n"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sql.append("GROUP BY c.owner_name, c.class_name;\n"); + } else { + sql.append("GROUP BY c.class_name;\n"); + } query = sql.toString(); // [TOOLS-2425]Support shard broker @@ -277,7 +323,11 @@ public boolean loadUserSchemaList(Connection conn, Map int pkCount = rs.getInt(3); int fkCount = rs.getInt(4); int indexCount = rs.getInt(5); - + if (database.getDatabaseInfo().isSupportUserSchema()) { + String OwnerName = rs.getString(6); + tableName = OwnerName + "." + tableName; + } + TableDetailInfo info = null; if (tablesMap.containsKey(tableName)) { info = tablesMap.get(tableName); @@ -291,6 +341,7 @@ public boolean loadUserSchemaList(Connection conn, Map info.setPkCount(pkCount); info.setFkCount(fkCount); info.setIndexCount(indexCount); + info.setClassType("CLASS"); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); @@ -330,7 +381,7 @@ public void run(IProgressMonitor monitor) Map comments = null; if (SchemaCommentHandler.isInstalledMetaTable(databaseInfo, conn)) { try { - comments = SchemaCommentHandler.loadTableDescriptions(databaseInfo, conn); + comments = SchemaCommentHandler.loadTableDescriptions(databaseInfo, conn, databaseInfo.isSupportUserSchema()); } catch (SQLException e) { LOGGER.error(e.getMessage(), e); } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenViewsDetailInfoPartProgress.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenViewsDetailInfoPartProgress.java index ccdc03c3..6b05ab05 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenViewsDetailInfoPartProgress.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/progress/OpenViewsDetailInfoPartProgress.java @@ -78,24 +78,41 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, database.getDatabaseInfo(), true); StringBuilder sb = new StringBuilder(); - sb.append("SELECT c.class_name, v.vclass_def, c.owner_name \n"); - sb.append("FROM db_class c, db_attribute a, db_vclass v \n"); - sb.append("WHERE c.class_name=a.class_name \n"); - sb.append("AND c.class_name=v.vclass_name \n"); - sb.append("AND c.is_system_class='NO' \n"); - sb.append("AND a.from_class_name IS NULL \n"); - sb.append("AND c.class_type='VCLASS' \n"); - sb.append("GROUP BY c.class_name, c.class_type, \n"); - //8.2.2 need to group by these 2 column - sb.append("v.vclass_def ,c.owner_name \n"); - sb.append("ORDER BY c.class_type, c.class_name"); + if (database.getDatabaseInfo().isSupportUserSchema()) { + sb.append("SELECT c.class_name, v.vclass_def, c.owner_name \n"); + sb.append("FROM db_class c, db_attribute a, db_vclass v \n"); + sb.append("WHERE c.class_name=a.class_name \n"); + sb.append("AND c.class_name=v.vclass_name \n"); + sb.append("AND c.owner_name=v.owner_name \n"); + sb.append("AND c.is_system_class='NO' \n"); + sb.append("AND a.from_class_name IS NULL \n"); + sb.append("AND c.class_type='VCLASS' \n"); + sb.append("GROUP BY c.class_name, c.class_type, \n"); + //8.2.2 need to group by these 2 column + sb.append("v.vclass_def ,c.owner_name \n"); + sb.append("ORDER BY c.owner_name, c.class_type, c.class_name"); + } else { + sb.append("SELECT c.class_name, v.vclass_def, c.owner_name \n"); + sb.append("FROM db_class c, db_attribute a, db_vclass v \n"); + sb.append("WHERE c.class_name=a.class_name \n"); + sb.append("AND c.class_name=v.vclass_name \n"); + sb.append("AND c.is_system_class='NO' \n"); + sb.append("AND a.from_class_name IS NULL \n"); + sb.append("AND c.class_type='VCLASS' \n"); + sb.append("GROUP BY c.class_name, c.class_type, \n"); + //8.2.2 need to group by these 2 column + sb.append("v.vclass_def ,c.owner_name \n"); + sb.append("ORDER BY c.class_type, c.class_name"); + } stmt = conn.createStatement(); rs = stmt.executeQuery(sb.toString()); while (rs.next()) { - ViewDetailInfo view = new ViewDetailInfo(rs.getString(1)); + String className = rs.getString(1); + String ownerName = rs.getString(3); + ViewDetailInfo view = new ViewDetailInfo(className); view.setViewDef(rs.getString(2)); - view.setViewOwnerName(rs.getString(3)); + view.setViewOwnerName(ownerName); viewList.add(view); } success = true; diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/ActionSupportUtil.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/ActionSupportUtil.java index 3db751bd..8a7c6502 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/ActionSupportUtil.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/ActionSupportUtil.java @@ -216,6 +216,16 @@ public static boolean isSupportSinSelCheckDbUser(Object obj, String type) { } boolean isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), getOwner(schemaNode)); + if (!isSameUser && type == NodeType.TRIGGER) { + if (dbInfo.isSupportUserSchema()) { + int idx = schemaNode.getName().indexOf("."); + if (idx > 0) { + String ownerName = schemaNode.getName().substring(0, idx); + isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), ownerName); + } + } + } + if (isSameUser) { return true; } diff --git a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/GetInfoDataUtil.java b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/GetInfoDataUtil.java index 2433e74f..15de1a3e 100644 --- a/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/GetInfoDataUtil.java +++ b/com.cubrid.common.ui/src/com/cubrid/common/ui/spi/util/GetInfoDataUtil.java @@ -120,7 +120,7 @@ public static String getViewCreateSQLScript(boolean newFlag, sb.append("CREATE VIEW "); } else { if (CompatibleUtil.isSupportReplaceView(database) - && classInfo.getClassName().equalsIgnoreCase(viewName)) { + && classInfo.getUniqueName().equalsIgnoreCase(viewName)) { sb.append("CREATE OR REPLACE VIEW "); } else { sb.append("CREATE VIEW "); diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/serial/task/SerialTaskTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/serial/task/SerialTaskTest.java index cb3c7123..b8b8031c 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/serial/task/SerialTaskTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/serial/task/SerialTaskTest.java @@ -37,7 +37,7 @@ public void testSerialTask() { //test create serial CreateOrEditSerialTask createOrEditSerialTask = new CreateOrEditSerialTask( databaseInfo); - createOrEditSerialTask.createSerial("serial1", "1", "1", "100", "1", + createOrEditSerialTask.createSerial("", "serial1", "1", "1", "100", "1", true, false, false, "10", false, null); assertTrue(createOrEditSerialTask.getErrorMsg() == null || createOrEditSerialTask.getErrorMsg().trim().length() <= 0); @@ -56,28 +56,28 @@ public void testSerialTask() { CreateOrEditSerialTask createOrEditSerialTask2 = new CreateOrEditSerialTask( databaseInfo); - createOrEditSerialTask2.createSerial("serial2", null, null, "100", "1", + createOrEditSerialTask2.createSerial("", "serial2", null, null, "100", "1", true, false, false, "100", true, null); CreateOrEditSerialTask createOrEditSerialTask3 = new CreateOrEditSerialTask( databaseInfo); - createOrEditSerialTask3.createSerial("serial3", null, null, "100", "1", + createOrEditSerialTask3.createSerial("", "serial3", null, null, "100", "1", true, true, true, "100", true, null); CreateOrEditSerialTask createOrEditSerialTask4 = new CreateOrEditSerialTask( databaseInfo); - createOrEditSerialTask4.createSerial("serial4", "1", "1", "100", "1", + createOrEditSerialTask4.createSerial("", "serial4", "1", "1", "100", "1", true, true, true, "100", true, null); CreateOrEditSerialTask createOrEditSerialTask5 = new CreateOrEditSerialTask( databaseInfo); - createOrEditSerialTask5.createSerial("serial5", null, null, null, null, + createOrEditSerialTask5.createSerial("", "serial5", null, null, null, null, false, false, false, "100", true, null); - createOrEditSerialTask5.createSerial("serial6", null, null, null, null, + createOrEditSerialTask5.createSerial("", "serial6", null, null, null, null, false, false, false, "100", true, null); - createOrEditSerialTask5.createSerial("serial6", null, null, null, null, + createOrEditSerialTask5.createSerial("", "serial6", null, null, null, null, false, false, false, "100", true, null); //test edit serial createOrEditSerialTask = new CreateOrEditSerialTask(databaseInfo); - createOrEditSerialTask.editSerial("serial1", "2", "2", "102", "2", + createOrEditSerialTask.editSerial("", "serial1", "2", "2", "102", "2", false, false, false, "10", false, null); assertTrue(createOrEditSerialTask.getErrorMsg() == null || createOrEditSerialTask.getErrorMsg().trim().length() <= 0); @@ -91,20 +91,20 @@ public void testSerialTask() { && !serialInfo.isCyclic(); assertTrue(isOk); createOrEditSerialTask2 = new CreateOrEditSerialTask(databaseInfo); - createOrEditSerialTask2.editSerial("serial2", null, null, "100", "1", + createOrEditSerialTask2.editSerial("", "serial2", null, null, "100", "1", true, false, false, "100", true, null); createOrEditSerialTask3 = new CreateOrEditSerialTask(databaseInfo); - createOrEditSerialTask3.editSerial("serial3", null, null, "100", "1", + createOrEditSerialTask3.editSerial("", "serial3", null, null, "100", "1", true, true, true, "100", true, null); createOrEditSerialTask4 = new CreateOrEditSerialTask(databaseInfo); - createOrEditSerialTask4.editSerial("serial4", "1", "1", "100", "1", + createOrEditSerialTask4.editSerial("", "serial4", "1", "1", "100", "1", true, true, true, "100", true, null); createOrEditSerialTask5 = new CreateOrEditSerialTask(databaseInfo); - createOrEditSerialTask5.editSerial("serial5", null, null, null, null, + createOrEditSerialTask5.editSerial("", "serial5", null, null, null, null, false, false, false, "100", true, null); - createOrEditSerialTask5.editSerial("serial6", null, null, null, null, + createOrEditSerialTask5.editSerial("", "serial6", null, null, null, null, false, false, false, "100", true, null); - createOrEditSerialTask5.editSerial("serial6", null, null, null, null, + createOrEditSerialTask5.editSerial("", "serial6", null, null, null, null, false, false, false, "100", true, null); //test get serial information list diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfoTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfoTest.java index 2b15e1da..d653326a 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfoTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfoTest.java @@ -53,9 +53,10 @@ public void testClassInfo() { ; boolean isSystemClass = true; boolean isPartitionedClass = true; + boolean isSupportUserSchema = true; //test constructor ClassInfo classInfo = new ClassInfo(className, ownerName, classType, - isSystemClass, isPartitionedClass); + isSystemClass, isPartitionedClass, isSupportUserSchema); assertNotNull(classInfo); //test getters and setters @@ -64,11 +65,13 @@ public void testClassInfo() { classInfo.setClassType(classType); classInfo.setSystemClass(isSystemClass); classInfo.setPartitionedClass(isPartitionedClass); + classInfo.setSupportUserSchema(isSupportUserSchema); assertEquals(classInfo.getClassName(), className); assertEquals(classInfo.getOwnerName(), ownerName); assertEquals(classInfo.getClassType(), classType); assertTrue(classInfo.isSystemClass()); assertTrue(classInfo.isPartitionedClass()); + assertTrue(classInfo.isSupportUserSchema()); } } diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/DBResolutionTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/DBResolutionTest.java index 1c911a54..ea328ee4 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/DBResolutionTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/DBResolutionTest.java @@ -46,18 +46,18 @@ public class DBResolutionTest extends TestCase { public final void testDBResolution() { String name = "name"; - String className = "className"; + String tableName = "tableName"; String alias = "alias"; boolean isClassResolution = true; // test getters and setters - DBResolution dbResolution = new DBResolution(name, className, alias); + DBResolution dbResolution = new DBResolution(name, tableName, alias); dbResolution.getAlias(); dbResolution.setName(name); - dbResolution.setClassName(className); + dbResolution.setTableName(tableName); dbResolution.setAlias(alias); dbResolution.setClassResolution(isClassResolution); assertEquals(dbResolution.getName(), name); - assertEquals(dbResolution.getClassName(), className); + assertEquals(dbResolution.getTableName(), tableName); assertEquals(dbResolution.getAlias(), alias); assertTrue(dbResolution.isClassResolution()); diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/PartitionInfoTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/PartitionInfoTest.java index 8d862a04..e20477f8 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/PartitionInfoTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/PartitionInfoTest.java @@ -50,7 +50,7 @@ public class PartitionInfoTest extends */ public final void testPartitionInfo() { - String className = "className"; + String tableName = "tableName"; String partitionName = "partitionName"; String partitionClassName = "partitionClassName"; PartitionType partitionType = PartitionType.HASH; @@ -59,21 +59,21 @@ public final void testPartitionInfo() { int rows = -1; // test getters and setters PartitionInfo partitionInfo1 = new PartitionInfo(); - PartitionInfo partitionInfo2 = new PartitionInfo(className, + PartitionInfo partitionInfo2 = new PartitionInfo(tableName, partitionType); - PartitionInfo partitionInfo3 = new PartitionInfo(className, + PartitionInfo partitionInfo3 = new PartitionInfo(tableName, partitionName, partitionType, partitionExpr, partitionValues, rows); - PartitionInfo partitionInfo4 = new PartitionInfo(className, + PartitionInfo partitionInfo4 = new PartitionInfo(tableName, partitionName, partitionClassName, partitionType, partitionExpr, partitionValues, rows); partitionInfo4.setPartitionValues(partitionValues); - partitionInfo4.setClassName(className); + partitionInfo4.setTableName(tableName); partitionInfo4.setPartitionName(partitionName); partitionInfo4.setPartitionType(partitionType); partitionInfo4.setPartitionExpr(partitionExpr); partitionInfo4.setRows(rows); - assertEquals(partitionInfo4.getClassName(), className); + assertEquals(partitionInfo4.getTableName(), tableName); assertEquals(partitionInfo4.getPartitionName(), partitionName); assertNotSame(partitionInfo4.getPartitionClassName(), partitionClassName); @@ -104,11 +104,11 @@ public final void testPartitionInfo() { partitionInfo4.removePartitionValue("value"); partitionInfo4.equals(partitionInfo4); partitionInfo4.equals("aaa"); - PartitionInfo partitionInfo5 = new PartitionInfo(className, + PartitionInfo partitionInfo5 = new PartitionInfo(tableName, partitionName, partitionClassName, partitionType, partitionExpr, partitionValues, rows); partitionInfo5.setPartitionValues(partitionValues); - partitionInfo5.setClassName(className); + partitionInfo5.setTableName(tableName); partitionInfo5.setPartitionName(partitionName); partitionInfo5.setPartitionType(partitionType); partitionInfo5.setPartitionExpr(partitionExpr); @@ -116,42 +116,42 @@ public final void testPartitionInfo() { partitionInfo4.equals(partitionInfo5); partitionInfo5.addPartitionValue("value5"); partitionInfo5.setPartitionValues(partitionValues); - partitionInfo5.setClassName("className5"); + partitionInfo5.setTableName("className5"); partitionInfo5.setPartitionName("partitionName5"); partitionInfo5.setPartitionType(PartitionType.LIST); partitionInfo5.setPartitionExpr("partitionExpr5"); partitionInfo5.setRows(5); partitionInfo4.equals(partitionInfo5); partitionInfo5.setPartitionType(partitionType); - partitionInfo5.setClassName(className); + partitionInfo5.setTableName(tableName); partitionInfo4.equals(partitionInfo5); partitionInfo5.setPartitionType(partitionType); - partitionInfo5.setClassName(className); + partitionInfo5.setTableName(tableName); partitionInfo5.setPartitionName(partitionName); partitionInfo4.equals(partitionInfo5); partitionInfo5.setPartitionType(partitionType); - partitionInfo5.setClassName(className); + partitionInfo5.setTableName(tableName); partitionInfo5.setPartitionName(partitionName); partitionInfo4.setPartitionType(PartitionType.LIST); partitionInfo5.setPartitionType(PartitionType.RANGE); partitionInfo4.equals(partitionInfo5); partitionInfo4.setPartitionType(PartitionType.LIST); partitionInfo5.setPartitionType(PartitionType.LIST); - partitionInfo5.setClassName(className); + partitionInfo5.setTableName(tableName); partitionInfo5.setPartitionName(partitionName); partitionInfo5.setPartitionExpr(partitionExpr); partitionInfo4.equals(partitionInfo5); partitionInfo1.setPartitionType(PartitionType.HASH); partitionInfo2.setPartitionType(PartitionType.HASH); - partitionInfo1.setClassName(null); - partitionInfo2.setClassName(null); + partitionInfo1.setTableName(null); + partitionInfo2.setTableName(null); partitionInfo1.equals(partitionInfo2); - partitionInfo1.setClassName("a"); - partitionInfo2.setClassName(null); + partitionInfo1.setTableName("a"); + partitionInfo2.setTableName(null); partitionInfo1.equals(partitionInfo2); - partitionInfo1.setClassName(null); - partitionInfo2.setClassName("b"); + partitionInfo1.setTableName(null); + partitionInfo2.setTableName("b"); partitionInfo1.equals(partitionInfo2); } } diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaAlterDDLTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaAlterDDLTest.java index 77ed6218..7b06ffd6 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaAlterDDLTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaAlterDDLTest.java @@ -157,7 +157,7 @@ private void indexTest1() { Constraint constraint = null; String indexType = null; String indexName = ""; - String tableName = newSchema.getClassname(); + String tableName = newSchema.getUniqueName(); //add unique constraint = new Constraint(false); @@ -177,7 +177,7 @@ private void indexTest1() { newSchema.addConstraint(constraint); changeList.addSchemeChangeLog(new SchemaChangeLog(null, - constraint.getDefaultName(newSchema.getClassname()) + constraint.getDefaultName(newSchema.getUniqueName()) + "$" + constraint.getName(), //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -200,7 +200,7 @@ private void indexTest1() { newSchema.addConstraint(constraint); changeList.addSchemeChangeLog(new SchemaChangeLog(null, - constraint.getDefaultName(newSchema.getClassname()) + constraint.getDefaultName(newSchema.getUniqueName()) + "$" + constraint.getName(), //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -223,7 +223,7 @@ private void indexTest1() { newSchema.addConstraint(constraint); changeList.addSchemeChangeLog(new SchemaChangeLog(null, - constraint.getDefaultName(newSchema.getClassname()) + constraint.getDefaultName(newSchema.getUniqueName()) + "$" + constraint.getName(), //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -243,7 +243,7 @@ private void indexTest1() { newSchema.addConstraint(constraint); changeList.addSchemeChangeLog(new SchemaChangeLog(null, - constraint.getDefaultName(newSchema.getClassname()) + constraint.getDefaultName(newSchema.getUniqueName()) + "$" + constraint.getName(), //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -274,7 +274,7 @@ private void indexTest2() { Constraint index = newSchema.getConstraintByName(indexName, indexType); newSchema.removeConstraintByName(indexName, indexType); changeList.addSchemeChangeLog(new SchemaChangeLog( - index.getDefaultName(newSchema.getClassname()) + index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(), null, //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -283,7 +283,7 @@ private void indexTest2() { index = newSchema.getConstraintByName(indexName, indexType); newSchema.removeConstraintByName(indexName, indexType); changeList.addSchemeChangeLog(new SchemaChangeLog( - index.getDefaultName(newSchema.getClassname()) + index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(), null, //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -292,7 +292,7 @@ private void indexTest2() { index = newSchema.getConstraintByName(indexName, indexType); newSchema.removeConstraintByName(indexName, indexType); changeList.addSchemeChangeLog(new SchemaChangeLog( - index.getDefaultName(newSchema.getClassname()) + index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(), null, //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -301,7 +301,7 @@ private void indexTest2() { index = newSchema.getConstraintByName(indexName, indexType); newSchema.removeConstraintByName(indexName, indexType); changeList.addSchemeChangeLog(new SchemaChangeLog( - index.getDefaultName(newSchema.getClassname()) + index.getDefaultName(newSchema.getUniqueName()) + "$" + index.getName(), null, //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); @@ -336,7 +336,7 @@ private void fkTest1() { String fkName = ""; if (fkName.equals("")) { //$NON-NLS-1$ - fkName = ConstraintNamingUtil.getFKName(newSchema.getClassname(), + fkName = ConstraintNamingUtil.getFKName(newSchema.getUniqueName(), fk.getAttributes()); } fk.setName(fkName); @@ -413,7 +413,7 @@ private void pkTest() { DBAttribute attr = new DBAttribute(); attr.setName(testColumn); attr.setType("smallint"); - attr.setInherit(newSchema.getClassname()); + attr.setInherit(newSchema.getUniqueName()); addColumn(newSchema, isClassAttribute, attr); Constraint oldPK = newSchema.getPK(superList); @@ -507,7 +507,7 @@ private void columnTest() { attr.setType("smallint"); attr.setUnique(false); - attr.setInherit(newSchema.getClassname()); + attr.setInherit(newSchema.getUniqueName()); addColumn(newSchema, isClassAttribute, attr); @@ -593,7 +593,7 @@ private void columnTest() { attr = new DBAttribute(); attr.setName(testColumn); attr.setType("smallint"); - attr.setInherit(newSchema.getClassname()); + attr.setInherit(newSchema.getUniqueName()); addColumn(newSchema, isClassAttribute, attr); @@ -675,7 +675,7 @@ private void dropColumn(SchemaInfo newSchema, boolean isClassAttribute, private void editColumn(SchemaInfo newSchema, DBAttribute editAttribute, DBAttribute oldAttribute, boolean isEditAll) { if (editAttribute != null) { - editAttribute.setInherit(newSchema.getClassname()); + editAttribute.setInherit(newSchema.getUniqueName()); } else { return; } @@ -683,7 +683,7 @@ private void editColumn(SchemaInfo newSchema, DBAttribute editAttribute, boolean isNewAttrClass = editAttribute.isClassAttribute(); boolean isOldAttrClass = oldAttribute.isClassAttribute(); String attrName = oldAttribute.getName(); - String tableName = newSchema.getClassname(); + String tableName = newSchema.getUniqueName(); if (isEditAll) { if (isOldAttrClass != isNewAttrClass) { // attribute @@ -733,7 +733,7 @@ private void editColumn(SchemaInfo newSchema, DBAttribute editAttribute, private void addColumn(SchemaInfo newSchema, boolean isClassAttribute, DBAttribute addAttribute) { String newAttrName = addAttribute.getName(); - String tableName = newSchema.getClassname(); + String tableName = newSchema.getUniqueName(); if (addAttribute != null) { addAttribute.setInherit(tableName); } else { @@ -916,7 +916,7 @@ private void addResolution(SchemaInfo newSchema, String column, String superTable, String alias, boolean isClassType) { DBResolution newResolution = new DBResolution(column, superTable, alias); newResolution.setClassResolution(isClassType); - String tbl = newResolution.getClassName(); + String tbl = newResolution.getTableName(); if (newResolution != null) { List resolutions = null; if (isClassType) { @@ -939,7 +939,7 @@ private void addResolution(SchemaInfo newSchema, String column, DBResolution r = resolutions.get(i); // remove resolution if (r.getName().equals(column) - && r.getClassName().equals(tbl)) { + && r.getTableName().equals(tbl)) { resolutions.remove(i); } } @@ -977,7 +977,7 @@ private void removeResolution(SchemaInfo newSchema, String type, for (int i = 0; i < resolutions.size(); i++) { DBResolution r = resolutions.get(i); if (r.getName().equals(column) - && r.getClassName().equals(superTable)) { + && r.getTableName().equals(superTable)) { removedResolution = resolutions.remove(i); } } diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaChangeManagerTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaChangeManagerTest.java index adf1b16a..6eed36d5 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaChangeManagerTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaChangeManagerTest.java @@ -87,6 +87,7 @@ public void testGetDDL() { schema1.setClassname(tableName); schema1.setOwner(owner); + schema1.setUniqueName(tableName); schema1.setVirtual(virtual); schema1.setType(type); diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDLTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDLTest.java index 5533c9d6..e5165995 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDLTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDLTest.java @@ -136,11 +136,11 @@ private boolean createTestTable() throws Exception { * Check CheckSubClassTask */ CheckSubClassTask task = new CheckSubClassTask(databaseInfo); - assertTrue(task.checkSubClass("sup1")); + assertTrue(task.checkSubClass("owner", "sup1")); // assertFalse(task.checkSubClass("sup1")); task.setErrorMsg("Error"); - assertFalse(task.checkSubClass("sup1")); + assertFalse(task.checkSubClass("owner", "sup1")); return success; } @@ -304,7 +304,7 @@ public void testdata() throws Exception { SchemeInnerType.TYPE_FK)); Constraint index = testTableName.getConstraintByName("index", "UNIQUE"); changeList.addSchemeChangeLog(new SchemaChangeLog( - index.getDefaultName(testTableName.getClassname()) + index.getDefaultName(testTableName.getUniqueName()) + "$" + index.getName(), null, //$NON-NLS-1$ SchemeInnerType.TYPE_INDEX)); changeList.addSchemeChangeLog(new SchemaChangeLog("a", "a", @@ -352,12 +352,12 @@ public void testdata() throws Exception { boolean isClassResolution = true; DBResolution oldResolutions = new DBResolution(name, className, alias); oldResolutions.setName(name); - oldResolutions.setClassName(className); + oldResolutions.setTableName(className); oldResolutions.setAlias(alias); oldResolutions.setClassResolution(isClassResolution); DBResolution newResolutions = new DBResolution(name, className, alias); newResolutions.setName(name); - newResolutions.setClassName(className); + newResolutions.setTableName(className); newResolutions.setAlias(alias); newResolutions.setClassResolution(isClassResolution); List oldResolution = new ArrayList(); @@ -463,14 +463,15 @@ public void testGetAlterDDL2() throws Exception { SchemaInfo alteredschema = schema.clone(); alteredschema.setClassname("alteredName"); + alteredschema.setUniqueName("alteredName"); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog( - schema.getClassname(), alteredschema.getClassname(), + schema.getUniqueName(), alteredschema.getUniqueName(), SchemeInnerType.TYPE_SCHEMA)); /*Change supper*/ schema.setSuperClasses(new ArrayList()); alteredschema.setSuperClasses(new ArrayList()); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog( - schema.getClassname(), alteredschema.getClassname(), + schema.getUniqueName(), alteredschema.getUniqueName(), SchemeInnerType.TYPE_SUPER_TABLE)); /*Remove attr*/ alteredschema.removeDBAttributeByName("gender", false); @@ -503,16 +504,16 @@ public void testGetAlterDDL2() throws Exception { newAttr.setNotNull(false); newAttr.setType("String"); newAttr.setUnique(false); - newAttr.setInherit(alteredschema.getClassname()); + newAttr.setInherit(alteredschema.getUniqueName()); /*Add pk attr*/ DBAttribute pkAttr = new DBAttribute(); pkAttr.setName("pkAttr"); pkAttr.setNotNull(true); pkAttr.setType("Integer"); pkAttr.setUnique(true); - pkAttr.setInherit(alteredschema.getClassname()); + pkAttr.setInherit(alteredschema.getUniqueName()); pkAttr.setAutoIncrement(new SerialInfo("pk", "dba", "0", "1", "999999", - "0", true, "0", "0", alteredschema.getClassname(), + "0", true, "0", "0", alteredschema.getUniqueName(), pkAttr.getName())); alteredschema.addAttribute(newAttr); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog(null, @@ -523,27 +524,27 @@ public void testGetAlterDDL2() throws Exception { index.addAttribute("newAttr"); index.addRule("newAttr_index DESC"); index.setName(ConstraintNamingUtil.getIndexName( - alteredschema.getClassname(), index.getRules())); + alteredschema.getUniqueName(), index.getRules())); alteredschema.addConstraint(index); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog(null, - index.getDefaultName(alteredschema.getClassname()) + "$" + index.getDefaultName(alteredschema.getUniqueName()) + "$" + index.getName(), SchemeInnerType.TYPE_INDEX)); /*Remove index*/ Constraint removeConstraint = alteredschema.getConstraints().get(0); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog( - removeConstraint.getDefaultName(alteredschema.getClassname()) + removeConstraint.getDefaultName(alteredschema.getUniqueName()) + "$" + removeConstraint.getName(), null, SchemeInnerType.TYPE_INDEX)); /*Add pk*/ Constraint pk = new Constraint(false); pk.addAttribute(pkAttr.getName()); - pk.setName(ConstraintNamingUtil.getPKName(alteredschema.getClassname(), + pk.setName(ConstraintNamingUtil.getPKName(alteredschema.getUniqueName(), pk.getAttributes())); pk.setType(Constraint.ConstraintType.PRIMARYKEY.getText()); pk.addRule("pkAttr_pk ASC"); alteredschema.addConstraint(pk); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog(null, - pk.getDefaultName(alteredschema.getClassname()) + "$" + pk.getDefaultName(alteredschema.getUniqueName()) + "$" + pk.getName(), SchemeInnerType.TYPE_INDEX)); /*Remove fk*/ Constraint fk2 = new Constraint(false); @@ -551,7 +552,7 @@ public void testGetAlterDDL2() throws Exception { fk2.addAttribute(pkAttr.getName()); fk2.addRule("REFERENCES " + testTableName); fk2.addRule("ON DELETE RESTRICT ON UPDATE RESTRICT"); - String fkName2 = ConstraintNamingUtil.getFKName(schema.getClassname(), + String fkName2 = ConstraintNamingUtil.getFKName(schema.getUniqueName(), fk2.getAttributes()); fk2.setName(fkName2); schema.addConstraint(fk2); @@ -560,7 +561,7 @@ public void testGetAlterDDL2() throws Exception { /*Alter fk*/ Constraint alterFK = alteredschema.getFKConstraints().get(0); String oldFKName = alterFK.getName(); - alterFK.setName(ConstraintNamingUtil.getFKName(schema.getClassname(), + alterFK.setName(ConstraintNamingUtil.getFKName(schema.getUniqueName(), fk2.getAttributes()) + "temp"); changeLogMgr.addSchemeChangeLog(new SchemaChangeLog(oldFKName, diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaInfoTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaInfoTest.java index 7af090ac..90ff6756 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaInfoTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaInfoTest.java @@ -260,7 +260,7 @@ public void testGetDDL() throws Exception { */ Constraint pk = schema.getPK(supers); assertNotNull(pk); - String pkName = ConstraintNamingUtil.getPKName(schema.getClassname(), + String pkName = ConstraintNamingUtil.getPKName(schema.getUniqueName(), pk.getAttributes()); assertEquals(pkName, pk.getName()); @@ -347,6 +347,7 @@ public void testData() { schemaInfo.setType("system"); schemaInfo.isSystemClass(); schemaInfo.setClassname("classname"); + schemaInfo.setUniqueName("classname"); schemaInfo.compareTo(schemaInfo); schemaInfo.hashCode(); //+test the equal() @@ -448,12 +449,12 @@ public void testData() { boolean isClassResolution = true; DBResolution dbResolution = new DBResolution(rname, rclassName, alias); dbResolution.setName(rname); - dbResolution.setClassName(rclassName); + dbResolution.setTableName(rclassName); dbResolution.setAlias(alias); dbResolution.setClassResolution(isClassResolution); DBResolution dbResolution3 = new DBResolution(rname, rclassName, alias); dbResolution3.setName("notsame"); - dbResolution3.setClassName(rclassName); + dbResolution3.setTableName(rclassName); dbResolution3.setAlias(alias); dbResolution3.setClassResolution(isClassResolution); schemaInfo1.addClassResolution(dbResolution); @@ -465,18 +466,27 @@ public void testData() { schemaInfo2.addClassResolution(dbResolution); schemaInfo1.setClassname("classname"); + schemaInfo1.setUniqueName("classname"); schemaInfo2.setClassname("notsame"); + schemaInfo2.setUniqueName("notsame"); schemaInfoOld.equals(schemaInfo1); schemaInfo2.equals(schemaInfo1); schemaInfoOld.setClassname("classname"); + schemaInfoOld.setUniqueName("classname"); schemaInfo2.setClassname("classname"); - + schemaInfo2.setUniqueName("classname"); + schemaInfo1.setClassname("classname"); + schemaInfo1.setUniqueName("classname"); schemaInfo2.setClassname("notsame"); + schemaInfo2.setUniqueName("notsame"); + schemaInfoOld.equals(schemaInfo1); schemaInfo2.equals(schemaInfo1); schemaInfoOld.setClassname("classname"); + schemaInfoOld.setUniqueName("classname"); schemaInfo2.setClassname("classname"); + schemaInfo2.setUniqueName("classname"); schemaInfo2.addConstraint(new Constraint(false)); schemaInfoOld.equals(schemaInfo1); @@ -545,6 +555,7 @@ public void testData() { schemaInfo.replaceDBAttributeByName(dbAttribute1, dbAttribute2, false, supers); schemaInfo.setClassname("inherit"); + schemaInfo.setUniqueName("inherit"); schemaInfo.getLocalClassAttributes(); constraintYes.setType("UNIQUE"); List a = new ArrayList(); diff --git a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableModelTest.java b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableModelTest.java index d0abc4d8..baeafb25 100644 --- a/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableModelTest.java +++ b/com.cubrid.cubridmanager.core.testfragment/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableModelTest.java @@ -161,8 +161,8 @@ public void testModelDBResolution() { DBResolution bean = new DBResolution(); bean.setName("name"); assertEquals(bean.getName(), "name"); - bean.setClassName("className"); - assertEquals(bean.getClassName(), "className"); + bean.setTableName("className"); + assertEquals(bean.getTableName(), "className"); bean.setAlias("alias"); assertEquals(bean.getAlias(), "alias"); bean.isClassResolution(); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/model/CubridBrokerConfParaConstants.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/model/CubridBrokerConfParaConstants.java index ed6c2cea..00cbcc5d 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/model/CubridBrokerConfParaConstants.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/model/CubridBrokerConfParaConstants.java @@ -41,7 +41,7 @@ public interface CubridBrokerConfParaConstants { // NOPMD public static final String MASTER_SHM_ID = "MASTER_SHM_ID"; public static final String ADMIN_LOG_FILE = "ADMIN_LOG_FILE"; - public static final String ENABLE_ACCESS_CONTROL = "ENABLE_ACCESS_CONTROL"; + public static final String ENABLE_ACCESS_CONTROL = "ACCESS_CONTROL"; public static final String ACCESS_CONTROL_FILE = "ACCESS_CONTROL_FILE"; public static final String SERVICE = "SERVICE"; public static final String BROKER_PORT = "BROKER_PORT"; diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/socket/SocketTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/socket/SocketTask.java index ce8ae32d..e81d5ba3 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/socket/SocketTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/socket/SocketTask.java @@ -72,6 +72,7 @@ public abstract class SocketTask extends AbstractTask { protected boolean isNeedMultiSend = false; // Before send message,whether need server connected status protected boolean isNeedServerConnected = true; + protected String appendSendMsg = null; //for unit test,add it private TreeNode responseNode = null; diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/task/CommonSQLExcuterTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/task/CommonSQLExcuterTask.java index 699b9594..bbe56d8f 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/task/CommonSQLExcuterTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/common/task/CommonSQLExcuterTask.java @@ -71,7 +71,7 @@ public void execute() { if (sqls != null) { for (String sql : sqls) { currentDDL = sql; - stmt.executeUpdate(sql); + stmt.executeUpdate(sql); } } stmt.close(); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/database/model/DatabaseInfo.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/database/model/DatabaseInfo.java index b4eada56..002465d2 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/database/model/DatabaseInfo.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/database/model/DatabaseInfo.java @@ -108,7 +108,9 @@ public class DatabaseInfo implements IDatabaseSpec { private String version = null; private boolean isSupportTableComment; private boolean isShard = false; - + private boolean isSupportUserSchema = false;; + private boolean isSupportSynonym = false; + public static final int SHARD_QUERY_TYPE_VAL = 0; public static final int SHARD_QUERY_TYPE_ID = 1; private int shardQueryType = SHARD_QUERY_TYPE_VAL; @@ -851,7 +853,7 @@ public SchemaInfo getSchemaInfo(String tableName) { if (null == schemaInfo) { SchemaProvider schemaProvider = new SchemaProvider(this, tableName); schemaInfo = schemaProvider.getSchema(); - if (schemaInfo == null && StringUtil.isNotEmpty(schemaProvider.getErrorMessage())) { + if (schemaInfo == null || StringUtil.isNotEmpty(schemaProvider.getErrorMessage())) { errorMessage = schemaProvider.getErrorMessage(); return null; } else { @@ -908,7 +910,7 @@ public void putSchemaInfo(SchemaInfo schema) { if (null == schemaMap) { schemaMap = new HashMap(); } - String key = schema.getClassname(); + String key = schema.getUniqueName(); schemaMap.put(key, schema); } @@ -1041,6 +1043,39 @@ public void setSupportTableComment(boolean isSupportTableComment) { this.isSupportTableComment = isSupportTableComment; } + /** + * return whether it has the UserSchema or not + * @return + */ + public boolean isSupportUserSchema() { + return isSupportUserSchema; + } + + /** + * set the UserSchema support + * @param isSupportUserSchema + */ + public void setSupportUserSchema(boolean isSupportUserSchema) { + this.isSupportUserSchema = isSupportUserSchema; + setSupportSynonym(isSupportUserSchema); + } + + /** + * return whether it has the Synonym or not + * @return + */ + public boolean isSupportSynonym() { + return isSupportSynonym; + } + + /** + * set the Synonym support + * @param isSupportSynonym + */ + public void setSupportSynonym(boolean isSupportSynonym) { + this.isSupportSynonym = isSupportSynonym; + } + public boolean isShard() { // [TOOLS-2425]Support shard broker return isShard; diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/CreateOrEditSerialTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/CreateOrEditSerialTask.java index 99c68817..667bbb1d 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/CreateOrEditSerialTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/CreateOrEditSerialTask.java @@ -62,6 +62,7 @@ public CreateOrEditSerialTask(DatabaseInfo dbInfo) { /** * Create serial by JDBC * + * @param ownerName String The given owner name * @param serialName String The given serial name * @param startVal String The given start value * @param incrementVal String The given incremental vlaue @@ -74,18 +75,29 @@ public CreateOrEditSerialTask(DatabaseInfo dbInfo) { * @param isNoCache boolean whether is NOCACHE * @param description string the Serial's comment */ - public void createSerial(String serialName, String startVal, + public void createSerial(String OwnerName, String serialName, String startVal, String incrementVal, String maxVal, String minVal, boolean isCycle, boolean isNoMinVal, boolean isNoMaxVal, String cacheCount, boolean isNoCache, String description) { if (StringUtil.isNotEmpty(errorMsg)) { return; } + + String uniqueName; + if (databaseInfo.isSupportUserSchema()) { + if (OwnerName != null && !OwnerName.isEmpty()) { + uniqueName = QuerySyntax.escapeKeyword(OwnerName) + "." + QuerySyntax.escapeKeyword(serialName); + } else { + uniqueName = QuerySyntax.escapeKeyword(serialName); + } + } else { + uniqueName = QuerySyntax.escapeKeyword(serialName); + } //databaseInfo.getServerInfo().compareVersionKey("8.2.2") >= 0; boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); - String sql = "CREATE SERIAL " + QuerySyntax.escapeKeyword(serialName); + String sql = "CREATE SERIAL " + uniqueName; if (StringUtil.isNotEmpty(startVal)) { sql += " START WITH " + startVal; } @@ -148,6 +160,7 @@ public void createSerial(String serialName, String startVal, /** * Edit serial by JDBC * + * @param OwnerName String The given owner name * @param serialName String The given serial name * @param startVal String The given start value * @param incrementVal String The given incremental value @@ -160,7 +173,7 @@ public void createSerial(String serialName, String startVal, * @param isNoCache boolean whether is NOCACHE * @param description String Serial's comment */ - public void editSerial(String serialName, String startVal, + public void editSerial(String OwnerName, String serialName, String startVal, String incrementVal, String maxVal, String minVal, boolean isCycle, boolean isNoMinVal, boolean isNoMaxVal, String cacheCount, boolean isNoCache, String description) { @@ -168,12 +181,23 @@ public void editSerial(String serialName, String startVal, return; } + String uniqueName; + if (databaseInfo.isSupportUserSchema()) { + if (OwnerName != null && !OwnerName.isEmpty()) { + uniqueName = "[" + OwnerName + "]." + QuerySyntax.escapeKeyword(serialName); + } else { + uniqueName = QuerySyntax.escapeKeyword(serialName); + } + } else { + uniqueName = QuerySyntax.escapeKeyword(serialName); + } + //databaseInfo.getServerInfo().compareVersionKey("8.2.2") >= 0; boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); - String dropSerialSql = "DROP SERIAL " + QuerySyntax.escapeKeyword(serialName); + String dropSerialSql = "DROP SERIAL " + uniqueName; - String sql = "CREATE SERIAL " + QuerySyntax.escapeKeyword(serialName); + String sql = "CREATE SERIAL " + uniqueName; if (StringUtil.isNotEmpty(startVal)) { sql += " START WITH " + startVal; } diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoListTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoListTask.java index 552256eb..0d4bdb3e 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoListTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoListTask.java @@ -77,7 +77,7 @@ public void execute() { // FIXME extract to utility class //databaseInfo.getServerInfo().compareVersionKey("8.2.2") >= 0; boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); - String sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE class_name IS NULL"; + String sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE class_name IS NULL ORDER BY owner.name, class_name"; // [TOOLS-2425]Support shard broker if (databaseInfo.isShard()) { diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoTask.java index 2de01180..d381de55 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/serial/task/GetSerialInfoTask.java @@ -80,7 +80,12 @@ public SerialInfo getSerialInfo(String serialName) { // FIXME extract to utility boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); - String sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE name=?"; + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE CONCAT(owner.name, '.' , name)=?"; + } else { + sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE name=?"; + } // [TOOLS-2425]Support shard broker if (databaseInfo.isShard()) { sql = databaseInfo.wrapShardQuery(sql); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfo.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfo.java index 71d84765..fe27bf20 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfo.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/ClassInfo.java @@ -27,6 +27,8 @@ */ package com.cubrid.cubridmanager.core.cubrid.table.model; +import java.util.Locale; + import com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType; /** @@ -43,21 +45,32 @@ public class ClassInfo { private ClassType classType; private boolean isSystemClass; private boolean isPartitionedClass; + private boolean isSupportUserSchema; + private boolean debugInputUserSchema = false; public ClassInfo(String className) { this.className = className; } public ClassInfo(String className, String ownerName, ClassType classType, - boolean isSystemClass, boolean isPartitionedClass) { + boolean isSystemClass, boolean isPartitionedClass, boolean isSupportUserSchema) { this.className = className; this.ownerName = ownerName; this.classType = classType; this.isSystemClass = isSystemClass; this.isPartitionedClass = isPartitionedClass; + this.isSupportUserSchema = isSupportUserSchema; + this.debugInputUserSchema = true; } public String getClassName() { + if (!debugInputUserSchema) { + try { + throw new Exception(); + } catch(Exception e) { + e.printStackTrace(); + } + } return className; } @@ -73,6 +86,26 @@ public void setOwnerName(String ownerName) { this.ownerName = ownerName; } + public String getUniqueName() { + if (!debugInputUserSchema) { + try { + throw new Exception(); + } catch(Exception e) { + e.printStackTrace(); + } + } + + if (isSupportUserSchema) { + if (isSystemClass) { + return className; + } else { + return ownerName + "." + className; + } + } else { + return className; + } + } + public ClassType getClassType() { return classType; } @@ -97,4 +130,13 @@ public void setPartitionedClass(boolean isPartitionedClass) { this.isPartitionedClass = isPartitionedClass; } + public boolean isSupportUserSchema() { + return isSupportUserSchema; + } + + public void setSupportUserSchema(boolean isSupportUserSchema) { + this.debugInputUserSchema = true; + this.isSupportUserSchema = isSupportUserSchema; + } + } diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDL.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDL.java index e5a4d477..586b7f0b 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDL.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SchemaDDL.java @@ -97,6 +97,10 @@ public String getSchemaDDL(SchemaInfo schemaInfo) { return getSchemaDDL(schemaInfo, true); } + public String getSchemaDDLForExport(SchemaInfo schemaInfo, boolean isContainIndex) { + return getSchemaDDL(schemaInfo, isContainIndex, false, true); + } + /** * Return DDL of a schema * @@ -108,6 +112,10 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex) { return getSchemaDDL(schemaInfo, isContainIndex, false); } + public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolean isVirtual) { + return getSchemaDDL(schemaInfo, isContainIndex, isVirtual, false); + } + /** * Return DDL of a schema * @@ -116,14 +124,28 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex) { * @param isVirtual boolean whether be a virtual table * @return String a string indicates a instance of SchemaInfo */ - public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolean isVirtual) { + public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolean isVirtual, boolean isExport) { StringBuffer ddlBuffer = new StringBuffer(); ddlBuffer.append("CREATE TABLE "); - final String tableName = schemaInfo.getClassname().toLowerCase(); - if (null == tableName || tableName.equals("")) { - ddlBuffer.append(""); + if (databaseInfo.isSupportUserSchema()) { + final String ownerName = schemaInfo.getOwner(); + final String className = schemaInfo.getClassname(); + if (ownerName == null || className == null || ownerName.isEmpty() || className.isEmpty()) { + ddlBuffer.append(""); + } else { + if (isExport) { + ddlBuffer.append(QuerySyntax.escapeKeyword(className)); + } else { + ddlBuffer.append(QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(className)); + } + } } else { - ddlBuffer.append(QuerySyntax.escapeKeyword(tableName)); + final String className = schemaInfo.getClassname(); + if (null == className || className.equals("")) { + ddlBuffer.append(""); + } else { + ddlBuffer.append(QuerySyntax.escapeKeyword(className)); + } } List slist = schemaInfo.getSuperClasses(); @@ -144,7 +166,7 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolea for (int i = 0; i < clist.size(); i++) { DBAttribute classAttr = clist.get(i); String inherit = classAttr.getInherit(); - if (inherit.equalsIgnoreCase(schemaInfo.getClassname())) { + if (inherit.equalsIgnoreCase(schemaInfo.getUniqueName())) { if (count == 0) { ddlBuffer.append(StringUtil.NEWLINE); attrBegin = true; @@ -171,8 +193,8 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolea for (int i = 0; i < nlist.size(); i++) { DBAttribute instanceAttr = nlist.get(i); String inherit = instanceAttr.getInherit(); - String className = schemaInfo.getClassname(); - if (StringUtil.isEqualIgnoreCase(inherit, className)) { + String tableName2 = schemaInfo.getUniqueName(); + if (StringUtil.isEqualIgnoreCase(inherit, tableName2)) { if (count == 0) { if (!attrBegin) { ddlBuffer.append("(").append(StringUtil.NEWLINE); @@ -193,7 +215,7 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolea constraintList = schemaInfo.getConstraints(); } /*Sort the constaints first*/ - Collections.sort(constraintList, new ConstraintComparator(tableName)); + Collections.sort(constraintList, new ConstraintComparator(schemaInfo.getUniqueName())); if (!constraintList.isEmpty()) { for (int i = 0; i < constraintList.size(); i++) { @@ -201,7 +223,7 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolea List superList = SuperClassUtil.getSuperClasses(databaseInfo, schemaInfo); if (!schemaInfo.isInSuperClasses(superList, constraint.getName())) { - String contraintDDL = getContraintDDL(tableName, constraint); + String contraintDDL = getContraintDDL(schemaInfo.getUniqueName(), constraint); if (StringUtil.isNotEmpty(contraintDDL)) { ddlBuffer.append(",").append(StringUtil.NEWLINE).append(contraintDDL); } @@ -237,7 +259,7 @@ public String getSchemaDDL(SchemaInfo schemaInfo, boolean isContainIndex, boolea String type = constraint.getType(); if ("UNIQUE".equals(type) || "INDEX".equals(type) || "REVERSE INDEX".equals(type) || "REVERSE UNIQUE".equals(type)) { - String indexDDL = getCreateIndexDDL(tableName, constraint); + String indexDDL = getCreateIndexDDL(schemaInfo.getUniqueName(), constraint); if (StringUtil.isNotEmpty(indexDDL)) { ddlBuffer.append(indexDDL); ddlBuffer.append(endLineChar).append(StringUtil.NEWLINE); @@ -291,14 +313,27 @@ public String getAlterSerialStartValueDDL(String serialName, String startValue) + startValue + endLineChar; } + + public String getPKsDDL(SchemaInfo schemaInfo) { + return getPKsDDL(schemaInfo, false); + } + + public String getPKsDDLForExport(SchemaInfo schemaInfo) { + return getPKsDDL(schemaInfo, true); + } + /** * get the pk DDL * * @param schemaInfo SchemaInfo * @return pk DDL */ - public String getPKsDDL(SchemaInfo schemaInfo) { - String tableName = schemaInfo.getClassname(); + public String getPKsDDL(SchemaInfo schemaInfo, boolean isExport) { + String tableName = schemaInfo.getUniqueName(); + // when 11.2 Or higher AND Export, using className. + if (databaseInfo.isSupportUserSchema() && isExport) { + tableName = schemaInfo.getClassname(); + } StringBuffer ddlBuffer = new StringBuffer(); //Get the PK @@ -315,14 +350,22 @@ public String getPKsDDL(SchemaInfo schemaInfo) { return ddlBuffer.toString(); } + public String getFKsDDL(SchemaInfo schemaInfo) { + return getFKsDDL(schemaInfo, false); + } + + public String getFKsDDLForExport(SchemaInfo schemaInfo) { + return getFKsDDL(schemaInfo, true); + } + /** * get the pk DDL * * @param schemaInfo SchemaInfo * @return pk DDL */ - public String getFKsDDL(SchemaInfo schemaInfo) { - String tableName = schemaInfo.getClassname(); + public String getFKsDDL(SchemaInfo schemaInfo, boolean isExport) { + String tableName = schemaInfo.getUniqueName(); StringBuffer ddlBuffer = new StringBuffer(); //Get the FK @@ -336,14 +379,26 @@ public String getFKsDDL(SchemaInfo schemaInfo) { return ddlBuffer.toString(); } + + public String getIndexsDDL(SchemaInfo schemaInfo) { + return getIndexsDDL(schemaInfo, false); + } + + public String getIndexsDDLForExport(SchemaInfo schemaInfo) { + return getIndexsDDL(schemaInfo, true); + } + /** * get the pk DDL * * @param schemaInfo SchemaInfo * @return pk DDL */ - public String getIndexsDDL(SchemaInfo schemaInfo) { - String tableName = schemaInfo.getClassname(); + public String getIndexsDDL(SchemaInfo schemaInfo, boolean isExport) { + String tableName = schemaInfo.getUniqueName(); + if (databaseInfo.isSupportUserSchema() && isExport) { + tableName = schemaInfo.getClassname(); + } StringBuffer ddlBuffer = new StringBuffer(); //Get the index @@ -378,7 +433,7 @@ public String getIndexsDDL(SchemaInfo schemaInfo) { * @return The index related DDL */ public String getIndexDDL(SchemaInfo schemaInfo) { - String tableName = schemaInfo.getClassname(); + String tableName = schemaInfo.getUniqueName(); StringBuffer ddlBuffer = new StringBuffer(); //Get the PK @@ -459,10 +514,12 @@ public String getAlterDDL(SchemaInfo oldSchemaInfo, SchemaInfo newSchemaInfo) { Map attrMap = new HashMap(); //Generate the DDL for rename table - String oldTableName = oldSchemaInfo.getClassname().toLowerCase(); - String newTableName = newSchemaInfo.getClassname().toLowerCase(); + String oldTableName = oldSchemaInfo.getUniqueName(); + String newTableName = newSchemaInfo.getUniqueName(); + String oldclassName = oldSchemaInfo.getClassname().toLowerCase(); + String newClassName = newSchemaInfo.getClassname().toLowerCase(); String tableName = oldTableName; - if (!oldTableName.equals(newTableName)) { + if (!oldclassName.equals(newClassName)) { String renameDDL = getRenameTableDDL(oldTableName, newTableName); generator.addSchemaDDLMode(DDLGenerator.TYPE_REBANE_TABLE, newSchemaInfo, renameDDL); tableName = newTableName; @@ -664,7 +721,7 @@ public List getResolutionChanges(List oldResolutions List list = new ArrayList(); for (DBResolution newResolution : newResolutions) { DBResolution r = SuperClassUtil.getResolution(oldResolutions, newResolution.getName(), - newResolution.getClassName()); + newResolution.getTableName()); if (r == null) { list.add(newResolution); } else { @@ -1364,7 +1421,7 @@ private String getReorderString(DBAttribute newAttr, SchemaInfo newSchemaInfo) { for (DBAttribute attr : newSchemaInfo.getAttributes()) { if (attr.getName().equals(newAttr.getName())) { break; - } else if (newSchemaInfo.getClassname().equals(attr.getInherit())) { + } else if (newSchemaInfo.getUniqueName().equals(attr.getInherit())) { lastName = attr.getName(); } } @@ -1648,7 +1705,7 @@ public String getChangeOwnerDDL(String tableName, String newOwner) { StringBuffer bf = new StringBuffer(); bf.append(StringUtil.NEWLINE); bf.append("CALL CHANGE_OWNER ("); - bf.append("'").append(tableName).append("',"); + bf.append("'").append(QuerySyntax.escapeKeyword(tableName)).append("',"); bf.append("'").append(newOwner).append("'"); bf.append(") ON CLASS db_authorizations"); bf.append(StringUtil.NEWLINE); @@ -1667,7 +1724,7 @@ public String getChangeOwnerDDLWithAlterStatement(String tableName, String newOw StringBuffer bf = new StringBuffer(); bf.append(StringUtil.NEWLINE); bf.append("ALTER TABLE "); - bf.append(tableName); + bf.append(QuerySyntax.escapeKeyword(tableName)); bf.append(" OWNER TO "); bf.append(newOwner); bf.append(StringUtil.NEWLINE); @@ -1911,7 +1968,7 @@ private String getAddReorderColumnDDL(SchemaInfo oldSchemaInfo, SchemaInfo newSc */ private String getAlterTableCollationDDL(SchemaInfo oldSchemaInfo, SchemaInfo newSchemaInfo) { StringBuffer bf = new StringBuffer(); - bf.append("ALTER CLASS ").append(QuerySyntax.escapeKeyword(newSchemaInfo.getClassname())); + bf.append("ALTER CLASS ").append(QuerySyntax.escapeKeyword(newSchemaInfo.getUniqueName())); bf.append(" COLLATE ").append( newSchemaInfo.getCollation() == null ? "" : newSchemaInfo.getCollation()); bf.append(endLineChar).append(StringUtil.NEWLINE); @@ -1947,7 +2004,7 @@ private String getDBResolutionDDL(DBResolution resolution, boolean isClass) { bf.append("CLASS "); } bf.append(QuerySyntax.escapeKeyword(resolution.getName())); - bf.append(" OF ").append(QuerySyntax.escapeKeyword(resolution.getClassName())); + bf.append(" OF ").append(QuerySyntax.escapeKeyword(resolution.getTableName())); if (StringUtil.isNotEmpty(resolution.getAlias())) { bf.append(" AS ").append(QuerySyntax.escapeKeyword(resolution.getAlias())); } @@ -2213,7 +2270,7 @@ public String getTransformToPartitionDDL(List partInfoList) { // Based on the first partition, determine the type of the partition information PartitionInfo inf = partInfoList.get(0); PartitionType partitionType = inf.getPartitionType(); - String tableName = inf.getClassName(); + String tableName = inf.getTableName(); String columnName = inf.getPartitionExpr(); ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(tableName)); @@ -2290,7 +2347,7 @@ public String getAddPartitionDDL(PartitionInfo inf) { StringBuilder ddl = new StringBuilder(); if (inf.getPartitionType() == PartitionType.RANGE) { - ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(inf.getClassName())).append( + ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(inf.getTableName())).append( " ADD PARTITION ("); ddl.append("PARTITION ").append(inf.getPartitionName()); ddl.append(" VALUES LESS THAN "); @@ -2335,12 +2392,12 @@ public String getCoalescePartitionDDL(List oldPartList, PartitionInfo newPart = newPartList.get(0); if (newPart.getPartitionType() == PartitionType.HASH) { int partCnt = oldPartList.size() - newPartList.size(); - return "ALTER TABLE " + QuerySyntax.escapeKeyword(newPart.getClassName()) + return "ALTER TABLE " + QuerySyntax.escapeKeyword(newPart.getTableName()) + " COALESCE PARTITION " + partCnt; } // TODO: HASH coalesce to merge as the number means that number is. UI and the means were different note ... StringBuilder ddl = new StringBuilder(); - ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(newPart.getClassName())).append( + ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(newPart.getTableName())).append( " REORGANIZE PARTITION "); for (int i = 0, len = oldPartList.size(); i < len; i++) { PartitionInfo inf = oldPartList.get(i); @@ -2384,12 +2441,12 @@ public String getSplitPartitionDDL(List oldPartList, if (oldPart.getPartitionType() == PartitionType.HASH) { int partCnt = newPartList.size() - oldPartList.size(); - return "ALTER TABLE " + QuerySyntax.escapeKeyword(oldPart.getClassName()) + return "ALTER TABLE " + QuerySyntax.escapeKeyword(oldPart.getTableName()) + " ADD PARTITION PARTITIONS " + partCnt; } StringBuilder ddl = new StringBuilder(); - ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(oldPart.getClassName())); + ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(oldPart.getTableName())); ddl.append(" REORGANIZE PARTITION ").append( QuerySyntax.escapeKeyword(oldPart.getPartitionName())).append(" INTO (").append( StringUtil.NEWLINE); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SuperClassUtil.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SuperClassUtil.java index 11ae8d82..099a6257 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SuperClassUtil.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/SuperClassUtil.java @@ -70,7 +70,7 @@ private SuperClassUtil() { public static boolean isInResolutions(List resolutions, String column, String table) { for (DBResolution r : resolutions) { - if (r.getName().equals(column) && r.getClassName().equals(table)) { + if (r.getName().equals(column) && r.getTableName().equals(table)) { return true; } } @@ -89,7 +89,7 @@ public static boolean isInResolutions(List resolutions, public static DBResolution getResolution(List resolutions, String column, String table) { for (DBResolution r : resolutions) { - if (r.getName().equals(column) && r.getClassName().equals(table)) { + if (r.getName().equals(column) && r.getTableName().equals(table)) { return r; } } @@ -112,7 +112,7 @@ public static DBResolution getNextResolution( List resolutions, DBResolution removedResolution, List conflicts) { String column = removedResolution.getName(); - String table = removedResolution.getClassName(); + String table = removedResolution.getTableName(); boolean started = false; boolean found = false; DBResolution firstResolution = null; @@ -439,7 +439,7 @@ private static void removeUnusedResolutionForConflict( DBResolution resolution = resolutions.get(j); boolean found = false; for (String[] conflict : conflicts) { - if (conflict[2].equals(resolution.getClassName()) + if (conflict[2].equals(resolution.getTableName()) && conflict[0].equals(resolution.getName())) { found = true; } @@ -569,7 +569,7 @@ private static void resetAttribute(SchemaInfo newSchemaInfo, if (list.contains(schema)) { newAttrList.add(attr); } else { - String tableName = schema.getClassname(); + String tableName = schema.getUniqueName(); DBResolution r = getResolution(resolutions, columnName, tableName); if (r != null && r.getAlias() != null @@ -622,7 +622,7 @@ public static boolean computingAttributeList(DatabaseInfo database, continue; } - if (attr.getInherit().equals(newSchemaInfo.getClassname())) { + if (attr.getInherit().equals(newSchemaInfo.getUniqueName())) { localAttr = new NewAttribute(attr, schema); } else { attrList.add(new NewAttribute(attr, schema)); @@ -653,7 +653,7 @@ public static boolean computingAttributeList(DatabaseInfo database, for (int j = size - 1; j >= 0; j--) { NewAttribute attr = lowestAttrList.get(j); String column = attr.attr.getName(); - String table = attr.schema.getClassname(); + String table = attr.schema.getUniqueName(); DBResolution r = getResolution(resolutions, column, table); @@ -684,7 +684,7 @@ public static void addDefaultResolution(List oldResolutions, List newResolutions, List conflicts, SchemaInfo newSchemaInfo) { List localAttrList = new ArrayList(); - String table = newSchemaInfo.getClassname(); + String table = newSchemaInfo.getUniqueName(); if (table == null) { table = ""; } @@ -708,7 +708,7 @@ public static void addDefaultResolution(List oldResolutions, if (r.getAlias().equals("")) { found = true; } else { - if (tbl.equals(r.getClassName())) { + if (tbl.equals(r.getTableName())) { hasAlias = true; } } @@ -798,7 +798,7 @@ private static void removeUnusedResolutionForSuper( DBResolution resolution = resolutions.get(j); boolean found = false; for (String superClassName : newSupers) { - if (superClassName.equals(resolution.getClassName())) { + if (superClassName.equals(resolution.getTableName())) { found = true; } } @@ -853,7 +853,7 @@ public static List getColumnConflicts(DatabaseInfo database, if (a == null) { continue; } - String[] strs = {columnName, a.getType(), s.getClassname() }; + String[] strs = {columnName, a.getType(), s.getUniqueName() }; retList.add(strs); } } diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableIndex.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableIndex.java index 742529ce..1198378a 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableIndex.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/model/TableIndex.java @@ -39,6 +39,7 @@ */ public class TableIndex { private String indexName; + private String ownerName = ""; private boolean isPrimaryKey; private boolean isForeignKey; private boolean isUnique; @@ -61,6 +62,17 @@ public void setIndexName(String indexName) { this.indexName = indexName; } + public String getOwnerName() { + return ownerName; + } + + /** + * @param indexName the indexName to set + */ + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } + /** * Whether is primary key * diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/CheckSubClassTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/CheckSubClassTask.java index 0774172c..cc9ed67b 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/CheckSubClassTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/CheckSubClassTask.java @@ -54,9 +54,20 @@ public CheckSubClassTask(DatabaseInfo dbInfo) { * @param className * @return */ - public boolean checkSubClass(String className) { + public boolean checkSubClass(String owner, String className) { boolean isHasSubClass = false; - String sql = "SELECT sub_classes FROM _db_class WHERE class_name='" + className + "'"; + + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + if (owner.isEmpty() || className.isEmpty()) { + errorMsg = Messages.msg_error; + return isHasSubClass; + } + sql = "SELECT c.sub_classes FROM _db_class as c, db_user as u " + + "WHERE u.name='" + owner + "' AND c.class_name='" + className + "' group by u.name"; + } else { + sql = "SELECT sub_classes FROM _db_class WHERE class_name='" + className + "'"; + } try { if (errorMsg != null && errorMsg.trim().length() > 0) { diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllAttrTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllAttrTask.java index 80443fb8..b08f37ea 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllAttrTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllAttrTask.java @@ -78,16 +78,22 @@ public List getAttrNameList(String className) { errorMsg = Messages.error_getConnection; return allAttrList; } - - String sql = "SELECT attr_name, def_order FROM db_attribute WHERE class_name=?" + + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT attr_name, def_order FROM db_attribute WHERE CONCAT(owner_name, '.', class_name)=?" + " ORDER BY def_order"; + } else { + sql = "SELECT attr_name, def_order FROM db_attribute WHERE class_name=?" + + " ORDER BY def_order"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); stmt = connection.prepareStatement(sql); ((PreparedStatement) stmt).setString(1, - className.toLowerCase(Locale.getDefault())); + className); rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String attrName = rs.getString("attr_name"); @@ -116,16 +122,22 @@ public void getAttrList() { errorMsg = Messages.error_getConnection; return; } - - String sql = "SELECT * FROM db_attribute WHERE class_name=?" + + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT * FROM db_attribute WHERE CONCAT(owner_name, '.', class_name)=?" + " ORDER BY def_order"; + } else { + sql = "SELECT * FROM db_attribute WHERE class_name=?" + + " ORDER BY def_order"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); stmt = connection.prepareStatement(sql); ((PreparedStatement) stmt).setString(1, - className.toLowerCase(Locale.getDefault())); + className); rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { DBAttribute dbAttribute = new DBAttribute(); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllClassListTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllClassListTask.java index 48bda2ca..9c5a0e01 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllClassListTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllClassListTask.java @@ -36,6 +36,7 @@ import org.slf4j.Logger; +import com.cubrid.common.core.util.CompatibleUtil; import com.cubrid.common.core.util.ConstantsUtil; import com.cubrid.common.core.util.LogUtil; import com.cubrid.cubridmanager.core.Messages; @@ -104,10 +105,20 @@ public List getSchema(boolean isUserSchema, boolean isTable) { sql += " OR class_name='" + ConstantsUtil.CUNITOR_HA_TABLE + "'"; } - sql += " ORDER BY class_name"; + if (databaseInfo.isSupportUserSchema()) { + sql += " ORDER BY owner_name, class_name"; + } else { + sql += " ORDER BY class_name"; + } sql = databaseInfo.wrapShardQuery(sql); boolean existSchemaCommentTable = false; + boolean isSupportUserSchema = false; + if (CompatibleUtil.isAfter112(databaseInfo)) { + isSupportUserSchema = true; + databaseInfo.setSupportUserSchema(isSupportUserSchema); + } + stmt = connection.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { @@ -137,8 +148,9 @@ public List getSchema(boolean isUserSchema, boolean isTable) { if (partitioned != null && partitioned.equalsIgnoreCase("YES")) { isPartitioned = true; } + ClassInfo classInfo = new ClassInfo(className, ownerName, type, - isSystemClass, isPartitioned); + isSystemClass, isPartitioned, isSupportUserSchema); allClassInfoList.add(classInfo); } @@ -212,7 +224,7 @@ public List getAllClassInfoList() { isPartitioned = true; } ClassInfo classInfo = new ClassInfo(className, ownerName, type, - isSystemClass, isPartitioned); + isSystemClass, isPartitioned, databaseInfo.isSupportUserSchema()); allClassInfoList.add(classInfo); } } catch (SQLException e) { @@ -244,8 +256,15 @@ public void getClassInfoTaskExcute() { return; } - String sql = "SELECT class_name, owner_name, class_type, is_system_class," + String sql = ""; + boolean isSupportUserSchema = databaseInfo.isSupportUserSchema(); + if (isSupportUserSchema) { + sql = "SELECT class_name, owner_name, class_type, is_system_class," + + " partitioned FROM db_class WHERE CONCAT(owner_name, '.', class_name)=?"; + } else { + sql = "SELECT class_name, owner_name, class_type, is_system_class," + " partitioned FROM db_class WHERE class_name=?"; + } // [TOOLS-2425]Support shard broker if (databaseInfo != null) { @@ -253,7 +272,7 @@ public void getClassInfoTaskExcute() { } stmt = connection.prepareStatement(sql); - ((PreparedStatement) stmt).setString(1, tableName.toLowerCase(Locale.getDefault())); + ((PreparedStatement) stmt).setString(1, tableName); rs = ((PreparedStatement) stmt).executeQuery(); if (rs.next()) { String className = rs.getString("class_name"); @@ -275,8 +294,9 @@ public void getClassInfoTaskExcute() { if (partitioned != null && partitioned.equalsIgnoreCase("YES")) { isPartitioned = true; } + classInfo = new ClassInfo(className, ownerName, type, - isSystemClass, isPartitioned); + isSystemClass, isPartitioned, isSupportUserSchema); } } catch (SQLException e) { errorMsg = e.getMessage(); @@ -286,7 +306,7 @@ public void getClassInfoTaskExcute() { } public void setTableName(String tableName) { - this.tableName = tableName.toLowerCase(Locale.getDefault()); + this.tableName = tableName; } /** @@ -298,4 +318,8 @@ public void setTableName(String tableName) { public ClassInfo getClassInfo() { return classInfo; } + + public boolean isSupportUserSchema() { + return databaseInfo.isSupportUserSchema(); + } } diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllPartitionClassTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllPartitionClassTask.java index 787aff07..c466661d 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllPartitionClassTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllPartitionClassTask.java @@ -77,8 +77,15 @@ public void execute() { rs = stmt.executeQuery(sql); while (rs.next()) { String partitionClassName = rs.getString("partition_class_name"); - if (!map.containsKey(partitionClassName)) { - map.put(partitionClassName, partitionClassName); + String partitionName; + if (databaseInfo.isSupportUserSchema()) { + String ownerName = rs.getString("owner_name"); + partitionName = ownerName + "." + partitionClassName; + } else { + partitionName = partitionClassName; + } + if (!map.containsKey(partitionName)) { + map.put(partitionName, partitionName); } } } catch (SQLException e) { diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllSchemaTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllSchemaTask.java index ad4dbe12..e199a58e 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllSchemaTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetAllSchemaTask.java @@ -156,7 +156,7 @@ public void execute() { getPartitionInfo(); if (SchemaCommentHandler.isInstalledMetaTable(databaseInfo, connection)) { - comments = SchemaCommentHandler.loadDescriptions(databaseInfo, connection); + comments = SchemaCommentHandler.loadDescriptions(databaseInfo, connection, isSupportUserSchema()); } } catch (SQLException e) { LOGGER.error(e.getMessage(), e); @@ -180,22 +180,39 @@ public void execute() { * @param schemaInfo SchemaInfo */ private void getPartitionInfo() throws SQLException { - final String sql = "SELECT class_name, partition_name, partition_class_name," + String sql = ""; + if (isSupportUserSchema()) { + sql = "SELECT owner_name, class_name, partition_name, partition_class_name," + " partition_type, partition_expr, partition_values" + " FROM db_partition" + " ORDER BY class_name"; + } else { + sql = "SELECT class_name, partition_name, partition_class_name," + + " partition_type, partition_expr, partition_values" + + " FROM db_partition" + + " ORDER BY class_name"; + } stmt = connection.createStatement(); rs = stmt.executeQuery(sql); String exprDataType = null; while (rs.next()) { String className = rs.getString("class_name"); + String ownerName = ""; + String tableName = ""; + if (isSupportUserSchema()) { + ownerName = rs.getString("owner_name"); + tableName = ownerName + "." + className; + } else { + tableName = className; + } + String partitionName = rs.getString("partition_name"); String partitionClassName = rs.getString("partition_class_name"); String partitionExpr = rs.getString("partition_expr"); - SchemaInfo schemaInfo = schemas.get(className); + SchemaInfo schemaInfo = schemas.get(tableName); if (schemaInfo == null) { - LOGGER.error("Table " + className + " not found on the schema info."); + LOGGER.error("Table " + tableName + " not found on the schema info."); continue; } @@ -226,7 +243,7 @@ private void getPartitionInfo() throws SQLException { } } - PartitionInfo partitionItem = new PartitionInfo(className, + PartitionInfo partitionItem = new PartitionInfo(tableName, partitionName, partitionClassName, partitionType, partitionExpr, partitionValues, -1); @@ -238,7 +255,7 @@ private void getPartitionInfo() throws SQLException { if (exprDataType == null && partitionExpr != null && partitionExpr.trim().length() > 0) { - exprDataType = getExprDataType(className, partitionExpr); + exprDataType = getExprDataType(tableName, partitionExpr); } partitionItem.setPartitionExprType(exprDataType); @@ -287,19 +304,30 @@ private void getTableInfo() throws SQLException { boolean isSupportComment = SchemaCommentHandler.isInstalledMetaTable(databaseInfo, connection); Map descriptions = null; if (isSupportComment) { - descriptions = SchemaCommentHandler.loadDescriptions(databaseInfo, connection); + descriptions = SchemaCommentHandler.loadDescriptions(databaseInfo, connection, isSupportUserSchema()); } - String sql = "SELECT a.attr_name, a.attr_type, a.from_class_name," - + " a.data_type, a.prec, a.scale, a.is_nullable," + String sql = ""; + if (isSupportUserSchema()) { + sql = "SELECT a.attr_name, a.attr_type, a.from_class_name, a.from_owner_name,"; + } else { + sql = "SELECT a.attr_name, a.attr_type, a.from_class_name,"; + } + sql = sql + " a.data_type, a.prec, a.scale, a.is_nullable," + " a.domain_class_name, a.default_value, a.def_order," + " c.is_system_class, c.class_type, c.partitioned, c.owner_name, c.class_name," + " a.from_attr_name" + reuseOidCoulmn - + " FROM db_attribute a, db_class c" - + " WHERE c.class_name=a.class_name" - + " ORDER BY a.class_name, a.def_order"; - + + " FROM db_attribute a, db_class c"; + if (isSupportUserSchema()) { + sql = sql + " WHERE c.class_name=a.class_name" + + " AND c.owner_name=a.owner_name" + + " ORDER BY a.owner_name, a.class_name, a.def_order"; + } else { + sql = sql + " WHERE c.class_name=a.class_name" + + " ORDER BY a.class_name, a.def_order"; + } + // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -311,14 +339,26 @@ private void getTableInfo() throws SQLException { String type = rs.getString("class_type"); boolean isTable = "CLASS".equals(type); boolean isUserClass = "NO".equals(rs.getString("is_system_class")); - String owner = rs.getString("owner_name"); String className = rs.getString("class_name"); + String owner = ""; + String tableName = ""; + if (isSupportUserSchema()) { + owner = rs.getString("owner_name"); + if (isUserClass) { + tableName = owner + "." + className; + } else { + tableName = className; + } + } else { + tableName = className; + } + String partitioned = rs.getString("partitioned"); - schemaInfo = schemas.get(className); + schemaInfo = schemas.get(tableName); if (schemaInfo == null) { schemaInfo = new SchemaInfo(); - schemas.put(className, schemaInfo); + schemas.put(tableName, schemaInfo); } if (isTable) { @@ -343,13 +383,14 @@ private void getTableInfo() throws SQLException { } SchemaComment tableComment = isSupportComment ? - descriptions.get(className + "*") : null; + descriptions.get(tableName + "*") : null; if (tableComment != null) { schemaInfo.setDescription(tableComment.getDescription()); } schemaInfo.setOwner(owner); schemaInfo.setClassname(className); + schemaInfo.setUniqueName(tableName); schemaInfo.setDbname(dbName); schemaInfo.setPartitionGroup(partitioned); getColumnInfo(rs, schemaInfo, isSupportCharset, descriptions); @@ -359,7 +400,15 @@ private void getTableInfo() throws SQLException { if (StringUtil.isNotEmpty(fromAttrName) && !fromAttrName.equals(attrName)) { DBResolution dbr = new DBResolution(); dbr.setAlias(attrName); - dbr.setClassName(rs.getString("from_class_name")); + if (isSupportUserSchema()) { + if (rs.getString("from_class_name") != null) { + dbr.setTableName(rs.getString("from_owner_name") + "." + rs.getString("from_class_name")); + } else { + dbr.setTableName(null); + } + } else { + dbr.setTableName(rs.getString("from_class_name")); + } dbr.setClassResolution(!rs.getString("attr_type").equals("INSTANCE")); dbr.setName(fromAttrName); schemaInfo.addResolution(dbr); @@ -393,7 +442,17 @@ private void getColumnInfo(ResultSet rs, SchemaInfo schemaInfo, boolean supportC String attrName = rs.getString("attr_name"); String type = rs.getString("attr_type"); - String inherit = rs.getString("from_class_name"); + + String inherit; + if (isSupportUserSchema()) { + if (rs.getString("from_class_name") != null) { + inherit = rs.getString("from_owner_name") + "." + rs.getString("from_class_name"); + } else { + inherit = null; + } + } else { + inherit = rs.getString("from_class_name"); + } String dataType = rs.getString("data_type"); String prec = rs.getString("prec"); String scale = rs.getString("scale"); @@ -404,7 +463,7 @@ private void getColumnInfo(ResultSet rs, SchemaInfo schemaInfo, boolean supportC attr.setName(attrName); if (inherit == null) { - attr.setInherit(schemaInfo.getClassname()); + attr.setInherit(schemaInfo.getUniqueName()); } else { attr.setInherit(inherit); } @@ -431,7 +490,7 @@ private void getColumnInfo(ResultSet rs, SchemaInfo schemaInfo, boolean supportC } SchemaComment columnSchema = descriptions != null ? - descriptions.get(schemaInfo.getClassname() + "*" + attrName) : null; + descriptions.get(schemaInfo.getUniqueName() + "*" + attrName) : null; if (columnSchema != null) { attr.setDescription(columnSchema.getDescription()); } @@ -454,8 +513,18 @@ private void getColumnInfo(ResultSet rs, SchemaInfo schemaInfo, boolean supportC * @throws SQLException the SQLException */ private void getQuerySpecs() throws SQLException { - String sql = "SELECT vclass_name, vclass_def FROM db_vclass ORDER BY vclass_name"; - + String sql = ""; + + if (isSupportUserSchema()) { + sql = "SELECT v.owner_name, v.vclass_name, v.vclass_def, c.is_system_class " + + "FROM db_vclass v, db_class c " + + "WHERE v.vclass_name=c.class_name " + + "AND v.owner_name=c.owner_name " + + "ORDER BY v.owner_name, v.vclass_name"; + } else { + sql = "SELECT vclass_name, vclass_def FROM db_vclass ORDER BY vclass_name"; + } + // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); try { @@ -463,11 +532,25 @@ private void getQuerySpecs() throws SQLException { rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String vClassName = rs.getString("vclass_name"); + String ownerName = ""; + String tableName = ""; + if (isSupportUserSchema()) { + boolean isUserClass = "NO".equals(rs.getString("is_system_class")); + ownerName = rs.getString("owner_name"); + if (isUserClass) { + tableName = ownerName + "." + vClassName; + } else { + tableName = vClassName; + } + } else { + tableName = vClassName; + } + String vClassDef = rs.getString("vclass_def"); - SchemaInfo schemaInfo = schemas.get(vClassName); + SchemaInfo schemaInfo = schemas.get(tableName); if (schemaInfo == null) { - LOGGER.error("View " + vClassName + " not found on the schema info."); + LOGGER.error("View " + tableName + " not found on the schema info."); continue; } @@ -490,18 +573,31 @@ private Map> getForeignKeyInfo() throws SQLException ResultSet metaRs = null; try { List tableNamesContainedFK = new ArrayList(); - String sql = "SELECT class_name" + + String sql = ""; + if (isSupportUserSchema()) { + sql = "SELECT owner_name, class_name" + " FROM db_index" + " WHERE is_foreign_key='YES'" - + " GROUP BY class_name"; - + + " GROUP BY owner_name, class_name"; + } else { + sql = "SELECT class_name" + + " FROM db_index" + + " WHERE is_foreign_key='YES'" + + " GROUP BY class_name"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); metaStmt = connection.prepareStatement(sql); metaRs = ((PreparedStatement) metaStmt).executeQuery(); while (metaRs.next()) { - tableNamesContainedFK.add(metaRs.getString("class_name")); + if (isSupportUserSchema()) { + tableNamesContainedFK.add(metaRs.getString("owner_name") + + "." + metaRs.getString("class_name")); + } else { + tableNamesContainedFK.add(metaRs.getString("class_name")); + } } QueryUtil.freeQuery(metaStmt, metaRs); @@ -560,12 +656,23 @@ private void getConstraintInfo() throws SQLException { Map constraintMap = new HashMap(); - String sql = "SELECT i.class_name, i.index_name, i.is_unique, i.is_reverse," + String sql = ""; + if (isSupportUserSchema()) { + sql = "SELECT i.owner_name, i.class_name, i.index_name, i.is_unique, i.is_reverse," + " i.is_primary_key, i.is_foreign_key, i.key_count," - + " k.key_attr_name, k.asc_desc, k.key_order" + extraColumns + funcDef - + " FROM db_index i, db_index_key k" - + " WHERE i.class_name=k.class_name AND i.index_name=k.index_name" - + " ORDER BY i.class_name, i.index_name, k.key_order"; + + " k.key_attr_name, k.asc_desc, k.key_order" + extraColumns + funcDef + ", c.is_system_class" + + " FROM db_index i, db_index_key k, db_class c" + + " WHERE i.class_name=k.class_name AND i.index_name=k.index_name AND i.owner_name=k.owner_name" + + " AND c.class_name=i.class_name AND c.owner_name=i.owner_name" + + " ORDER BY i.owner_name, i.class_name, i.index_name, k.key_order"; + } else { + sql = "SELECT i.class_name, i.index_name, i.is_unique, i.is_reverse," + + " i.is_primary_key, i.is_foreign_key, i.key_count," + + " k.key_attr_name, k.asc_desc, k.key_order" + extraColumns + funcDef + + " FROM db_index i, db_index_key k" + + " WHERE i.class_name=k.class_name AND i.index_name=k.index_name" + + " ORDER BY i.class_name, i.index_name, k.key_order"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -575,6 +682,17 @@ private void getConstraintInfo() throws SQLException { Map constraint2Unique = new HashMap(); while (rs.next()) { String className = rs.getString("class_name"); + String tableName; + if (isSupportUserSchema()) { + boolean isUserClass = "NO".equals(rs.getString("is_system_class")); + if (isUserClass) { + tableName = rs.getString("owner_name") + "." + className; + } else { + tableName = className; + } + } else { + tableName = className; + } String constraintName = rs.getString("index_name"); String pk = rs.getString("is_primary_key"); String fk = rs.getString("is_foreign_key"); @@ -582,13 +700,13 @@ private void getConstraintInfo() throws SQLException { String reverse = rs.getString("is_reverse"); int keyCount = rs.getInt("key_count"); - SchemaInfo schemaInfo = schemas.get(className); + SchemaInfo schemaInfo = schemas.get(tableName); if (schemaInfo == null) { - LOGGER.error("Table " + className + " not found on the schema info."); + LOGGER.error("Table " + tableName + " not found on the schema info."); continue; } - String constraintKey = className + "_" + constraintName; + String constraintKey = tableName + "_" + constraintName; Constraint constraint = constraintMap.get(constraintKey); if (constraint == null) { constraint = new Constraint(false); @@ -636,7 +754,7 @@ private void getConstraintInfo() throws SQLException { constraint.addAttribute(attrName); if (Constraint.ConstraintType.FOREIGNKEY.getText().equals(constraint.getType())) { - String key = className + "." + attrName; + String key = tableName + "." + attrName; Map fkInfo = foreignKeys.get(key); if (null != fkInfo) { //.append(" ON CACHE OBJECT {3}"); @@ -677,7 +795,7 @@ private void getTypeInfo() throws SQLException { + " FROM db_attr_setdomain_elm a" + " ORDER BY a.class_name, a.attr_name"; - // [TOOLS-2425]Support shard broker + // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); try { @@ -709,12 +827,12 @@ private void getTypeInfo() throws SQLException { subList.add(new SubAttribute(type, subType)); } for (Entry>> entryMap : schemaColumnMap.entrySet()) { - String className = entryMap.getKey(); + String tableName = entryMap.getKey(); Map> columnMap = entryMap.getValue(); - SchemaInfo schemaInfo = schemas.get(className); + SchemaInfo schemaInfo = schemas.get(tableName); if (schemaInfo == null) { - LOGGER.error("Table " + className + LOGGER.error("Table " + tableName + " not found on the schema info."); continue; } @@ -797,9 +915,15 @@ private void getAutoIncrementInfo() throws SQLException { for (SerialInfo autoIncrement : serialInfoList) { String className = autoIncrement.getClassName(); + String serialName = ""; + if (isSupportUserSchema()) { + serialName = autoIncrement.getOwner() + "." + className; + } else { + serialName = className; + } String attrName = autoIncrement.getAttName(); assert (null != attrName); - SchemaInfo schemaInfo = schemas.get(className); + SchemaInfo schemaInfo = schemas.get(serialName); if (schemaInfo == null) { LOGGER.error("Can't find a table with auto increment column : " + attrName); continue; @@ -867,9 +991,17 @@ private void getAutoIncrementInfo() throws SQLException { * @throws SQLException the exception */ private void getSuperClassInfo() throws SQLException { - String sql = "SELECT class_name, super_class_name" + String sql = ""; + + if (isSupportUserSchema()) { + sql = "SELECT owner_name, class_name, super_owner_name, super_class_name" + " FROM db_direct_super_class" - + " ORDER BY class_name, super_class_name"; + + " ORDER BY owner_name, class_name, super_owner_name, super_class_name"; + } else { + sql = "SELECT class_name, super_class_name" + + " FROM db_direct_super_class" + + " ORDER BY class_name, super_class_name"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -880,11 +1012,22 @@ private void getSuperClassInfo() throws SQLException { while (rs.next()) { String className = rs.getString("class_name"); String superClass = rs.getString("super_class_name"); - SchemaInfo schemaInfo = schemas.get(className); + String tableName = ""; + String superTableName = ""; + + if (isSupportUserSchema()) { + tableName = rs.getString("owner_name") + "." + className; + superTableName = rs.getString("super_owner_name") + "." + superClass; + } else { + tableName = className; + superTableName = superClass; + } + + SchemaInfo schemaInfo = schemas.get(tableName); if (schemaInfo != null) { - schemaInfo.addSuperClass(superClass); + schemaInfo.addSuperClass(superTableName); } else { - LOGGER.error("Table " + className + " not found on the schema info."); + LOGGER.error("Table " + tableName + " not found on the schema info."); } } } finally { @@ -918,7 +1061,7 @@ public int compare(SchemaInfo o1, SchemaInfo o2) { return -1; } - return o1.getClassname().compareToIgnoreCase(o2.getClassname()); + return o1.getUniqueName().compareToIgnoreCase(o2.getUniqueName()); } }); @@ -931,4 +1074,9 @@ public int compare(SchemaInfo o1, SchemaInfo o2) { public void setNeedCollationInfo(boolean isNeedCollationInfo) { this.isNeedCollationInfo = isNeedCollationInfo; } + + private boolean isSupportUserSchema() { + return databaseInfo.isSupportUserSchema(); + } + } diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetPartitionedClassListTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetPartitionedClassListTask.java index 781b8a7b..5f1cf969 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetPartitionedClassListTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetPartitionedClassListTask.java @@ -82,11 +82,19 @@ public List getAllPartitionedClassInfoList(String tableName) { errorMsg = Messages.error_getConnection; return allClassInfoList; } - String sql = "SELECT b.* FROM db_partition a, db_class b WHERE a.class_name=?" + + boolean isSupportUserSchema = databaseInfo.isSupportUserSchema(); + + String sql; + if (isSupportUserSchema) { + sql = "SELECT b.* FROM db_partition a, db_class b WHERE CONCAT(a.owner_name, '.' , a.class_name)=?" + " AND LOWER(b.class_name)=LOWER(a.partition_class_name)"; + } else { + sql = "SELECT b.* FROM db_partition a, db_class b WHERE a.class_name=?" + + " AND LOWER(b.class_name)=LOWER(a.partition_class_name)"; + } stmt = connection.prepareStatement(sql); - ((PreparedStatement) stmt).setString(1, - tableName.toLowerCase(Locale.getDefault())); + ((PreparedStatement) stmt).setString(1, tableName); rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String className = rs.getString("class_name"); @@ -103,8 +111,9 @@ public List getAllPartitionedClassInfoList(String tableName) { && isSystemClazz.trim().equalsIgnoreCase("YES")) { isSystemClass = true; } + ClassInfo classInfo = new ClassInfo(className, ownerName, type, - isSystemClass, true); + isSystemClass, true, isSupportUserSchema); allClassInfoList.add(classInfo); } } catch (SQLException e) { @@ -134,8 +143,14 @@ public List getPartitionItemList(String tableName) { return result; } - String sql = "SELECT * FROM db_partition WHERE class_name='" - + tableName.trim().toLowerCase() + "'"; + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT * FROM db_partition WHERE CONCAT(owner_name, '.' , class_name)='" + + tableName + "'"; + } else { + sql = "SELECT * FROM db_partition WHERE class_name='" + + tableName.trim().toLowerCase() + "'"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -146,6 +161,8 @@ public List getPartitionItemList(String tableName) { String exprDataType = null; while (rs.next()) { String className = rs.getString("class_name"); + String ownerName = rs.getString("owner_name"); + String TableName = ownerName + "." + className; String partitionName = rs.getString("partition_name"); String partitionClassName = rs.getString("partition_class_name"); String partitionExpr = rs.getString("partition_expr"); @@ -176,7 +193,7 @@ public List getPartitionItemList(String tableName) { } } } - PartitionInfo partitionItem = new PartitionInfo(className, + PartitionInfo partitionItem = new PartitionInfo(TableName, partitionName, partitionClassName, partitionType, partitionExpr, partitionValues, -1); if (isCommentSupport) { @@ -184,7 +201,7 @@ public List getPartitionItemList(String tableName) { } if (exprDataType == null && partitionExpr != null && partitionExpr.trim().length() > 0) { - exprDataType = getExprDataType(className, partitionExpr); + exprDataType = getExprDataType(TableName, partitionExpr); } partitionItem.setPartitionExprType(exprDataType); result.add(partitionItem); @@ -286,8 +303,14 @@ public List getColumnStatistics(String tableName) { StringBuilder qry = new StringBuilder(); qry.append("SELECT "); - String sql = "SELECT attr_name, data_type FROM db_attribute WHERE class_name = '" - + tableName.trim().toLowerCase() + "'"; + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT attr_name, data_type FROM db_attribute WHERE CONCAT(owner_name, '.' , class_name) = '" + + QuerySyntax.escapeKeyword(tableName) + "'"; + } else { + sql = "SELECT attr_name, data_type FROM db_attribute WHERE class_name = '" + + QuerySyntax.escapeKeyword(tableName.trim().toLowerCase()) + "'"; + } connection.setAutoCommit(true); stmt = connection.createStatement(); rs = stmt.executeQuery(sql); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetSchemaTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetSchemaTask.java index 269df39a..64ac4c6a 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetSchemaTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetSchemaTask.java @@ -79,7 +79,7 @@ public class GetSchemaTask extends JDBCTask { private IProgressMonitor monitor; public GetSchemaTask(DatabaseInfo dbInfo, String tableName) { super("GetSchemaTask", dbInfo); - this.tableName = tableName.toLowerCase(Locale.getDefault()); + this.tableName = tableName; } public GetSchemaTask(DatabaseInfo dbInfo, String tableName, IProgressMonitor monitor) { @@ -89,7 +89,7 @@ public GetSchemaTask(DatabaseInfo dbInfo, String tableName, IProgressMonitor mon public GetSchemaTask(Connection connection, DatabaseInfo dbInfo, String tableName) { super("GetSchemaTask", dbInfo, connection); - this.tableName = tableName.toLowerCase(Locale.getDefault()); + this.tableName = tableName; } /** @@ -183,7 +183,7 @@ private void getPartitionInfo(SchemaInfo schemaInfo) { partitionedClassListTask = new GetPartitionedClassListTask( databaseInfo); } - List partitionInfoList = partitionedClassListTask.getPartitionItemList(schemaInfo.getClassname()); + List partitionInfoList = partitionedClassListTask.getPartitionItemList(schemaInfo.getUniqueName()); schemaInfo.setPartitionList(partitionInfoList); } } @@ -203,11 +203,16 @@ private SchemaInfo getTableInfo() throws SQLException { if (supportComment) { schemaComment = SchemaCommentHandler.loadDescription( - databaseInfo, connection, tableName).get(tableName + "*"); + databaseInfo, connection, databaseInfo.isSupportUserSchema(), tableName).get(tableName + "*"); } //get table information - String sql = "SELECT * FROM db_class WHERE class_name=?"; + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT * FROM db_class WHERE CONCAT(owner_name, '.', class_name)=?"; + } else { + sql = "SELECT * FROM db_class WHERE class_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -222,6 +227,7 @@ private SchemaInfo getTableInfo() throws SQLException { String type = rs.getString("class_type"); String isSystemClass = rs.getString("is_system_class"); String owner = rs.getString("owner_name"); + String className = rs.getString("class_name"); schemaInfo = new SchemaInfo(); if ("CLASS".equals(type)) { schemaInfo.setVirtual(SchemaInfo.VIRTUAL_NORMAL); @@ -245,7 +251,12 @@ private SchemaInfo getTableInfo() throws SQLException { schemaInfo.setDescription(schemaComment.getDescription()); } schemaInfo.setOwner(owner); - schemaInfo.setClassname(tableName); + schemaInfo.setClassname(className); + if (databaseInfo.isSupportUserSchema()) { + schemaInfo.setUniqueName(owner + "." + className); + } else { + schemaInfo.setUniqueName(className); + } schemaInfo.setDbname(databaseInfo.getDbName()); schemaInfo.setPartitionGroup(rs.getString("partitioned")); } @@ -275,7 +286,7 @@ private static String getCreateSQL(SchemaInfo schemaInfo) { key = SchemaInfo.VIRTUAL_VIEW.toUpperCase(); } String sql = "SHOW CREATE " + key + " " - + QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + + QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); return sql; } @@ -375,9 +386,16 @@ private void getQuerySpecs(SchemaInfo schemaInfo) throws SQLException { */ private void getDBResolutionInfo(SchemaInfo schemaInfo) throws SQLException { if (schemaInfo != null) { - String sql = "SELECT attr_name, from_class_name, attr_type, from_attr_name" + + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT attr_name, from_owner_name, from_class_name, attr_type, from_attr_name" + + " FROM db_attribute WHERE LOWER(CONCAT (owner_name, ',', class_name))=? AND attr_name<>from_attr_name" + + " AND from_attr_name IS NOT NULL"; + } else { + sql = "SELECT attr_name, from_class_name, attr_type, from_attr_name" + " FROM db_attribute WHERE class_name=? AND attr_name<>from_attr_name" + " AND from_attr_name IS NOT NULL"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -389,7 +407,13 @@ private void getDBResolutionInfo(SchemaInfo schemaInfo) throws SQLException { while (rs.next()) { DBResolution dbr = new DBResolution(); dbr.setAlias(rs.getString("attr_name")); - dbr.setClassName(rs.getString("from_class_name")); + String tableName = ""; + if (databaseInfo.isSupportUserSchema()) { + tableName = rs.getString("from_owner_name") + "." + rs.getString("from_class_name"); + } else { + tableName = rs.getString("from_class_name"); + } + dbr.setTableName(tableName); dbr.setClassResolution(!rs.getString("attr_type").equals( "INSTANCE")); dbr.setName(rs.getString("from_attr_name")); @@ -425,7 +449,18 @@ private Map> getForeignKeyInfo() throws SQLException Map fkInfo = new HashMap(); fkInfo.put("PKTABLE_CAT", rs.getString("PKTABLE_CAT")); fkInfo.put("PKTABLE_SCHEM", rs.getString("PKTABLE_SCHEM")); - fkInfo.put("PKTABLE_NAME", rs.getString("PKTABLE_NAME")); + String pkTableName; + if (databaseInfo.isSupportUserSchema()) { + pkTableName = rs.getString("PKTABLE_NAME"); + int dotIdx = pkTableName.indexOf("."); + if (dotIdx > 0) { + pkTableName = pkTableName.substring(0, dotIdx).toUpperCase(Locale.getDefault()) + + pkTableName.substring(dotIdx); + } + } else { + pkTableName = rs.getString("PKTABLE_NAME"); + } + fkInfo.put("PKTABLE_NAME", pkTableName); fkInfo.put("PKCOLUMN_NAME", rs.getString("PKCOLUMN_NAME")); fkInfo.put("FKTABLE_CAT", rs.getString("FKTABLE_CAT")); fkInfo.put("FKTABLE_SCHEM", rs.getString("FKTABLE_SCHEM")); @@ -459,9 +494,18 @@ private void getConstraintInfo(SchemaInfo schemaInfo) throws SQLException { return; } + boolean isSupportUserSchema = databaseInfo.isSupportUserSchema(); + Map> foreignKeys = getForeignKeyInfo(); - String sql = "SELECT index_name, is_unique, is_reverse, is_primary_key, is_foreign_key, key_count" - + " FROM db_index WHERE class_name=? ORDER BY index_name"; + + String sql = ""; + if (isSupportUserSchema) { + sql = "SELECT owner_name, index_name, is_unique, is_reverse, is_primary_key, is_foreign_key, key_count" + + " FROM db_index WHERE CONCAT(owner_name, '.', class_name)=? ORDER BY index_name"; + } else { + sql = "SELECT index_name, is_unique, is_reverse, is_primary_key, is_foreign_key, key_count" + + " FROM db_index WHERE class_name=? ORDER BY index_name"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -513,8 +557,13 @@ private void getConstraintInfo(SchemaInfo schemaInfo) throws SQLException { String regex = String.format("\\[%s\\].\\[[\\w#]*\\]", tableName); String prefixIndexLength = isSupportPrefixIndexLength ? ", key_prefix_length" : ""; String funcIndex = isSupportFuncIndex ? ", func" : ""; - sql = "SELECT key_attr_name, asc_desc, key_order" + prefixIndexLength + funcIndex - + " FROM db_index_key WHERE index_name=? AND class_name=? ORDER BY key_order"; + if (isSupportUserSchema) { + sql = "SELECT key_attr_name, asc_desc, key_order" + prefixIndexLength + funcIndex + + " FROM db_index_key WHERE index_name=? AND CONCAT(owner_name, '.', class_name)=? ORDER BY key_order"; + } else { + sql = "SELECT key_attr_name, asc_desc, key_order" + prefixIndexLength + funcIndex + + " FROM db_index_key WHERE index_name=? AND class_name=? ORDER BY key_order"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -591,9 +640,16 @@ private void getConstraintInfo(SchemaInfo schemaInfo) throws SQLException { */ private void getTypeInfo(SchemaInfo schemaInfo) throws SQLException { if (schemaInfo != null) { - String sql = "SELECT a.attr_name, a.attr_type," + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT a.attr_name, a.attr_type," + " a.data_type, a.prec, a.scale" - + " FROM db_attr_setdomain_elm a" + " WHERE a.class_name=?"; + + " FROM db_attr_setdomain_elm a" + " WHERE CONCAT(a.owner_name, '.', a.class_name)=?"; + } else { + sql = "SELECT a.attr_name, a.attr_type," + + " a.data_type, a.prec, a.scale" + + " FROM db_attr_setdomain_elm a" + " WHERE a.class_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -663,17 +719,18 @@ private void getAutoIncrementInfo(SchemaInfo schemaInfo) throws SQLException { List serialInfoList = new ArrayList(); //databaseInfo.getServerInfo().compareVersionKey("8.2.2") >= 0; boolean isSupportCache = CompatibleUtil.isSupportCache(databaseInfo); - String sql = "SELECT owner.name, db_serial.* FROM db_serial WHERE class_name=?"; + + String sql = "SELECT db_serial.* FROM db_serial WHERE class_name=?"; // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); try { stmt = connection.prepareStatement(sql); - ((PreparedStatement) stmt).setString(1, tableName); + ((PreparedStatement) stmt).setString(1, schemaInfo.getClassname()); rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String name = rs.getString("name"); - String owner = rs.getString("owner.name"); + String owner = rs.getString("owner"); String currentVal = rs.getString("current_val"); String incrementVal = rs.getString("increment_val"); String maxVal = rs.getString("max_val"); @@ -729,13 +786,20 @@ private void getColumnInfo(SchemaInfo schemaInfo) throws SQLException { boolean supportComment = SchemaCommentHandler.isInstalledMetaTable(databaseInfo, connection); Map comments = null; if (supportComment) { - comments = SchemaCommentHandler.loadDescriptions(databaseInfo, connection); + comments = SchemaCommentHandler.loadDescriptions(databaseInfo, connection, databaseInfo.isSupportUserSchema()); } - sql = "SELECT *" - + " FROM db_attribute" - + " WHERE class_name=? " - + " ORDER BY def_order"; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT *" + + " FROM db_attribute" + + " WHERE CONCAT(owner_name, '.' , class_name)=?" + + " ORDER BY def_order"; + } else { + sql = "SELECT *" + + " FROM db_attribute" + + " WHERE class_name=? " + + " ORDER BY def_order"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -749,6 +813,15 @@ private void getColumnInfo(SchemaInfo schemaInfo) throws SQLException { String attrName = rs.getString("attr_name"); String type = rs.getString("attr_type"); String inherit = rs.getString("from_class_name"); + String realInherit = null; + if (databaseInfo.isSupportUserSchema()) { + String fromOwnerName = rs.getString("from_owner_name"); + if (fromOwnerName != null && inherit != null) { + realInherit = fromOwnerName + "." + inherit; + } + } else { + realInherit = inherit; + } String dataType = rs.getString("data_type"); String prec = rs.getString("prec"); String scale = rs.getString("scale"); @@ -758,10 +831,10 @@ private void getColumnInfo(SchemaInfo schemaInfo) throws SQLException { DBAttribute attr = new DBAttribute(); attr.setName(attrName); - if (inherit == null) { + if (realInherit == null) { attr.setInherit(tableName); } else { - attr.setInherit(inherit); + attr.setInherit(realInherit); } if ("YES".equals(isNull)) { //null attr.setNotNull(false); @@ -808,7 +881,7 @@ private void getColumnInfo(SchemaInfo schemaInfo) throws SQLException { // Get enumeration if (CompatibleUtil.isSupportEnumVersion(databaseInfo) && enumColumnList.size() > 0) { - String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schemaInfo.getUniqueName()); StringBuilder sb = new StringBuilder(); sb.append("SHOW COLUMNS FROM ").append(escapedTableName).append(" WHERE FIELD IN ("); try{ @@ -929,8 +1002,14 @@ private void getSuperClassInfo(SchemaInfo schemaInfo) throws SQLException { return; } - String sql = "SELECT super_class_name FROM db_direct_super_class" - + " WHERE class_name=?"; + String sql = ""; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT super_class_name, super_owner_name FROM db_direct_super_class" + + " WHERE LOWER(CONCAT(owner_name, '.', class_name))=?"; + } else { + sql = "SELECT super_class_name FROM db_direct_super_class" + + " WHERE class_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -941,7 +1020,13 @@ private void getSuperClassInfo(SchemaInfo schemaInfo) throws SQLException { rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String superClass = rs.getString(1); - schemaInfo.addSuperClass(superClass); + String realSuperClass = ""; + if (databaseInfo.isSupportUserSchema()) { + realSuperClass = rs.getString(2) + "." + superClass; + } else { + realSuperClass = superClass; + } + schemaInfo.addSuperClass(realSuperClass); } } finally { QueryUtil.freeQuery(stmt, rs); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetTablesTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetTablesTask.java index a7feac2e..c54377f8 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetTablesTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetTablesTask.java @@ -118,13 +118,24 @@ public List getUserTables() { */ public List getUserTablesNotContainSubPartitionTable() { StringBuilder sb = new StringBuilder(); - sb.append("SELECT c.class_name, c.class_type "); - sb.append("FROM db_class c, db_attribute a "); - sb.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); - sb.append("AND a.from_class_name IS NULL "); - sb.append("AND c.class_type = 'CLASS' "); - sb.append("GROUP BY c.class_name, c.class_type "); - sb.append("ORDER BY c.class_type, c.class_name"); + if (databaseInfo.isSupportUserSchema()) { + sb.append("SELECT c.owner_name, c.class_name, c.class_type "); + sb.append("FROM db_class c, db_attribute a "); + sb.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sb.append("AND c.owner_name=a.owner_name "); + sb.append("AND a.from_class_name IS NULL "); + sb.append("AND c.class_type = 'CLASS' "); + sb.append("GROUP BY c.owner_name, c.class_name, c.class_type "); + sb.append("ORDER BY c.owner_name, c.class_type, c.class_name"); + } else { + sb.append("SELECT c.class_name, c.class_type "); + sb.append("FROM db_class c, db_attribute a "); + sb.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' "); + sb.append("AND a.from_class_name IS NULL "); + sb.append("AND c.class_type = 'CLASS' "); + sb.append("GROUP BY c.class_name, c.class_type "); + sb.append("ORDER BY c.class_type, c.class_name"); + } String sql = sb.toString(); // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -155,7 +166,11 @@ public List getTables(String sql) { stmt = connection.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { - tlist.add(rs.getString("class_name")); + if (databaseInfo.isSupportUserSchema()) { + tlist.add(rs.getString("owner_name") + "." + rs.getString("class_name")); + } else { + tlist.add(rs.getString("class_name")); + } } } catch (SQLException e) { errorMsg = e.getMessage(); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassColumnsTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassColumnsTask.java index 2249b583..785723c9 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassColumnsTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassColumnsTask.java @@ -82,7 +82,7 @@ public List getColumns(String tableName) { return columns; } columns = SchemaUtil.getTableColumn(databaseInfo, connection, tableName); - List pkColumns = QueryUtil.getPrimaryKeys(connection, tableName); + List pkColumns = QueryUtil.getPrimaryKeys(connection, tableName, databaseInfo.isSupportUserSchema()); for (TableColumn dbColumn : columns) { String columnName = dbColumn.getColumnName(); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassIndexesTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassIndexesTask.java index 322305c5..3c7a28d7 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassIndexesTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetUserClassIndexesTask.java @@ -72,15 +72,19 @@ public List getIndexesNames(String tableName) { errorMsg = Messages.error_getConnection; return indexes; } - - String sql = "SELECT * FROM db_index WHERE class_name=?"; + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT * FROM db_index WHERE CONCAT(owner_name, '.' , class_name)=?"; + } else { + sql = "SELECT * FROM db_index WHERE class_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); stmt = connection.prepareStatement(sql); ((PreparedStatement) stmt).setString(1, - tableName.toLowerCase(Locale.getDefault())); + tableName); rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { String indexName = rs.getString("index_name"); @@ -90,6 +94,10 @@ public List getIndexesNames(String tableName) { String reverse = rs.getString("is_reverse"); TableIndex dbIndex = new TableIndex(); dbIndex.setIndexName(indexName); + if (databaseInfo.isSupportUserSchema()) { + String ownerName = rs.getString("owner_name"); + dbIndex.setOwnerName(ownerName); + } dbIndex.setPrimaryKey(pk); dbIndex.setForeignKey(fk); dbIndex.setUnique(unique); @@ -101,8 +109,13 @@ public List getIndexesNames(String tableName) { boolean isSupportFunIndex = CompatibleUtil.isSupportFuncIndex(databaseInfo); String funcIndex = isSupportFunIndex ? ", func" : ""; - sql = "SELECT key_attr_name" + funcIndex - + " FROM db_index_key WHERE index_name=? AND class_name=?"; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT key_attr_name" + funcIndex + + " FROM db_index_key WHERE index_name=? AND CONCAT(owner_name, '.' , class_name)=?"; + } else { + sql = "SELECT key_attr_name" + funcIndex + + " FROM db_index_key WHERE index_name=? AND class_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); @@ -113,7 +126,7 @@ public List getIndexesNames(String tableName) { ((PreparedStatement) stmt).setString(1, indexName.toLowerCase(Locale.getDefault())); ((PreparedStatement) stmt).setString(2, - tableName.toLowerCase(Locale.getDefault())); + tableName); rs = ((PreparedStatement) stmt).executeQuery(); List columns = new ArrayList(); while (rs.next()) { diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetViewAllColumnsTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetViewAllColumnsTask.java index ddf62ff8..353d31b1 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetViewAllColumnsTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/table/task/GetViewAllColumnsTask.java @@ -72,7 +72,12 @@ public void getAllVclassListTaskExcute() { return; } - String sql = "SELECT vclass_name, vclass_def FROM db_vclass WHERE vclass_name=?"; + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT vclass_name, vclass_def FROM db_vclass WHERE CONCAT(owner_name, '.' , vclass_name)=?"; + } else { + sql = "SELECT vclass_name, vclass_def FROM db_vclass WHERE vclass_name=?"; + } // [TOOLS-2425]Support shard broker sql = databaseInfo.wrapShardQuery(sql); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/model/TriggerDDL.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/model/TriggerDDL.java index e10460ba..33e719c2 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/model/TriggerDDL.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/model/TriggerDDL.java @@ -32,6 +32,7 @@ import com.cubrid.common.core.common.model.Trigger; import com.cubrid.common.core.util.QuerySyntax; import com.cubrid.common.core.util.StringUtil; +import com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo; /** * @@ -49,15 +50,18 @@ private TriggerDDL() { static String newLine = StringUtil.NEWLINE; static String endLineChar = ";"; + public static String getDDL(Trigger trigger) { + return getDDL(trigger, false); + } /** * Get the ddl * * @param trigger Trigger * @return String */ - public static String getDDL(Trigger trigger) { + public static String getDDL(Trigger trigger, boolean isSupportUserSchema) { StringBuffer bf = new StringBuffer(); - appendHead(trigger, bf); + appendHead(trigger, bf, isSupportUserSchema); appendStatus(trigger, bf); appendPriority(trigger, bf); appendEvent(trigger, bf); @@ -200,14 +204,30 @@ private static void appendStatus(Trigger trigger, StringBuffer bf) { * @param trigger Trigger * @param bf StringBuffer */ - private static void appendHead(Trigger trigger, StringBuffer bf) { + private static void appendHead(Trigger trigger, StringBuffer bf, boolean isSupportUserSchema) { //CREATE TRIGGER trigger_name bf.append("CREATE TRIGGER "); String triggerName = trigger.getName(); + String ownerName = trigger.getOwner(); if (triggerName == null || triggerName.trim().equals("")) { bf.append(""); } else { - bf.append(QuerySyntax.escapeKeyword(triggerName)); + if (ownerName == null || ownerName.isEmpty()) { + if (isSupportUserSchema) { + int idx = triggerName.indexOf("."); + if (idx > 0) { + String owner = triggerName.substring(0, idx); + String name = triggerName.substring(idx + 1); + bf.append(QuerySyntax.escapeKeyword(owner) + "." + QuerySyntax.escapeKeyword(name)); + } else { + bf.append(QuerySyntax.escapeKeyword(triggerName)); + } + } else { + bf.append(QuerySyntax.escapeKeyword(triggerName)); + } + } else { + bf.append(QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(triggerName)); + } } bf.append(newLine); } @@ -221,6 +241,7 @@ private static void appendHead(Trigger trigger, StringBuffer bf) { */ public static String getAlterDDL(Trigger oldTrigger, Trigger newTrigger) { String triggerName = oldTrigger.getName(); + String ownerName = oldTrigger.getOwner(); String oldPriority = oldTrigger.getPriority(); String oldStatus = oldTrigger.getStatus(); String oldDescription = oldTrigger.getDescription(); @@ -234,7 +255,11 @@ public static String getAlterDDL(Trigger oldTrigger, Trigger newTrigger) { } if (statusChanged) { bf.append("ALTER TRIGGER "); - bf.append(QuerySyntax.escapeKeyword(triggerName)); + if (ownerName == null || ownerName.isEmpty()) { + bf.append(QuerySyntax.escapeKeyword(triggerName)); + } else { + bf.append(QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(triggerName)); + } bf.append(" STATUS ").append(newStatus); bf.append(endLineChar); bf.append(newLine); @@ -246,7 +271,11 @@ public static String getAlterDDL(Trigger oldTrigger, Trigger newTrigger) { } if (priorityChanged) { bf.append("ALTER TRIGGER "); - bf.append(QuerySyntax.escapeKeyword(triggerName)); + if (ownerName == null || ownerName.isEmpty()) { + bf.append(QuerySyntax.escapeKeyword(triggerName)); + } else { + bf.append(QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(triggerName)); + } bf.append(" PRIORITY ").append(newPriority); bf.append(endLineChar); bf.append(newLine); @@ -259,7 +288,11 @@ public static String getAlterDDL(Trigger oldTrigger, Trigger newTrigger) { if (commentChanged) { bf.append("ALTER TRIGGER "); - bf.append(QuerySyntax.escapeKeyword(triggerName)); + if (ownerName == null || ownerName.isEmpty()) { + bf.append(QuerySyntax.escapeKeyword(triggerName)); + } else { + bf.append(QuerySyntax.escapeKeyword(ownerName) + "." + QuerySyntax.escapeKeyword(triggerName)); + } newDescription = String.format("'%s'", newDescription); bf.append(String.format(" COMMENT %s", StringUtil.escapeQuotes(newDescription))); bf.append(endLineChar); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerInfoTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerInfoTask.java index 66258055..94c35fcf 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerInfoTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerInfoTask.java @@ -74,9 +74,18 @@ public Trigger getTriggerInfo(String triggerName) { return null; } - String sql = "SELECT t.*, c.target_class_name" + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT t.*, c.target_class_name, t.owner.name as trigger_owner" + + " FROM db_trigger t, db_trig c" + + " WHERE t.name=c.trigger_name" + + " AND t.owner.name=c.owner_name" + + " AND unique_name=?"; + } else { + sql = "SELECT t.*, c.target_class_name, t.owner.name as trigger_owner" + " FROM db_trigger t, db_trig c" + " WHERE t.name=c.trigger_name AND t.name=?"; + } // [TOOLS-2425]Support shard broker sql = DatabaseInfo.wrapShardQuery(databaseInfo, sql); @@ -86,7 +95,12 @@ public Trigger getTriggerInfo(String triggerName) { rs = ((PreparedStatement) stmt).executeQuery(); while (rs.next()) { trigger = new Trigger(); - trigger.setName(rs.getString("name")); + if (databaseInfo.isSupportUserSchema()) { + trigger.setName(rs.getString("unique_name")); + } else { + trigger.setName(rs.getString("name")); + } + trigger.setOwner(rs.getString("trigger_owner")); trigger.setConditionTime(JDBCGetTriggerListTask.getConditionTime(rs.getInt("condition_time"))); trigger.setEventType(JDBCGetTriggerListTask.getEventType(rs.getInt("event"))); trigger.setTarget_class(rs.getString("target_class_name")); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerListTask.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerListTask.java index 29881418..6b95569b 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerListTask.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/cubrid/trigger/task/JDBCGetTriggerListTask.java @@ -31,6 +31,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.slf4j.Logger; @@ -76,9 +77,17 @@ public void execute() { // FROM db_user u, TABLE(groups) AS t(g) // WHERE u.name = d.name) // and d.name=CURRENT_USER - String sql = "SELECT t.*, c.target_class_name" + String sql; + if (databaseInfo.isSupportUserSchema()) { + sql = "SELECT t.*, c.target_class_name, c.target_owner_name, c.owner_name" + + " FROM db_trigger t, db_trig c" + + " WHERE t.name=c.trigger_name" + + " AND t.owner.name=c.owner_name"; + } else { + sql = "SELECT t.*, c.target_class_name" + " FROM db_trigger t, db_trig c" + " WHERE t.name=c.trigger_name"; + } // [TOOLS-2425]Support shard broker sql = DatabaseInfo.wrapShardQuery(databaseInfo, sql); @@ -87,9 +96,18 @@ public void execute() { while (rs.next()) { Trigger trigger = new Trigger(); trigger.setName(rs.getString("name")); + if (databaseInfo.isSupportUserSchema()) { + //Data is LowerCase from CMS + trigger.setOwner(rs.getString("owner_name").toLowerCase(Locale.getDefault())); + } trigger.setConditionTime(getConditionTime(rs.getInt("condition_time"))); trigger.setEventType(getEventType(rs.getInt("event"))); - trigger.setTarget_class(rs.getString("target_class_name")); + if (databaseInfo.isSupportUserSchema()) { + String target_class = rs.getString("target_owner_name") + "." + rs.getString("target_class_name"); + trigger.setTarget_class(target_class); + } else { + trigger.setTarget_class(rs.getString("target_class_name")); + } trigger.setTarget_att(rs.getString("target_attribute")); trigger.setCondition(rs.getString("condition")); trigger.setActionTime(getActionTime(rs.getInt("action_time"))); diff --git a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/utils/ModelUtil.java b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/utils/ModelUtil.java index 50b43c9a..8c2ad0f1 100644 --- a/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/utils/ModelUtil.java +++ b/com.cubrid.cubridmanager.core/src/com/cubrid/cubridmanager/core/utils/ModelUtil.java @@ -400,7 +400,7 @@ public static SchemaInfo getSchemaInfo(TreeNode classinfo, ResultSet rs = null; try { connection = JDBCConnectionManager.getConnection(dbInfo, true); - String escapedTableName = QuerySyntax.escapeKeyword(schema.getClassname()); + String escapedTableName = QuerySyntax.escapeKeyword(schema.getUniqueName()); StringBuilder sb = new StringBuilder(); sb.append("SHOW COLUMNS FROM ").append(escapedTableName).append(" WHERE FIELD IN ("); stmt = connection.createStatement(); diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/broker/control/BrokersParameterPropertyPage.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/broker/control/BrokersParameterPropertyPage.java index e0efee7c..c7d9ecde 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/broker/control/BrokersParameterPropertyPage.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/broker/control/BrokersParameterPropertyPage.java @@ -125,7 +125,7 @@ public class BrokersParameterPropertyPage extends private static final String MASTER_SHMID_LBL_NAME = "MASTER_SHM_ID:"; private static final String ADMIN_LOG_LBL_NAME = "ADMIN_LOG_FILE:"; - private static final String ENABLE_ACCESS_CONTROL = "ENABLE_ACCESS_CONTROL:"; + private static final String ENABLE_ACCESS_CONTROL = "ACCESS_CONTROL:"; private static final String ACCESS_CONTROL_FILE = "ACCESS_CONTROL_FILE:"; private Button addBtn; private Button editBtn; diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/CopyDatabaseDialog.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/CopyDatabaseDialog.java index 49b92e5d..36515e4d 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/CopyDatabaseDialog.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/CopyDatabaseDialog.java @@ -577,14 +577,15 @@ private void initial() { if (spaceInfoList == null) { spaceInfoList = new ArrayList>(); for (DbSpaceInfo bean : volumeList) { - Map map = new HashMap(); + Map map = new HashMap(); if (bean.getType().equals("Active_log")) { srcLogDir = bean.getLocation(); } if (!bean.getType().equals("GENERIC") && !bean.getType().equals("DATA") && !bean.getType().equals("TEMP") - && !bean.getType().equals("INDEX")) { + && !bean.getType().equals("INDEX") + && !bean.getType().equals("PERMANENT")) { continue; } map.put("0", bean.getSpacename()); diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseDialog.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseDialog.java index 4904d31d..ccf38f4d 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseDialog.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseDialog.java @@ -479,6 +479,9 @@ private boolean connect() { } if (taskExcutor.isSuccess()) { + if (CompatibleUtil.isAfter112(dbInfo.getServerInfo())) { + dbInfo.setSupportUserSchema(true); + } saveBrokerInfo(); } diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseTaskExecutor.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseTaskExecutor.java index f3d90480..ac6969de 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseTaskExecutor.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/database/dialog/LoginDatabaseTaskExecutor.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import com.cubrid.common.core.task.ITask; +import com.cubrid.common.core.util.CompatibleUtil; import com.cubrid.common.core.util.LogUtil; import com.cubrid.common.ui.spi.persist.QueryOptions; import com.cubrid.common.ui.spi.progress.TaskExecutor; @@ -173,6 +174,7 @@ public boolean exec(final IProgressMonitor monitor) { dbInfo.setLogined(true); dbUserInfo.setNoEncryptPassword(dbPassword); dbInfo.setAuthLoginedDbUserInfo(dbUserInfo); + dbInfo.setSupportUserSchema(CompatibleUtil.isAfter112(dbInfo)); } diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddBackupPlanAction.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddBackupPlanAction.java index 944df4a3..882cffe4 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddBackupPlanAction.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddBackupPlanAction.java @@ -112,7 +112,7 @@ public void run (CubridDatabase database) { BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo(); String newBackupId = backupPlanInfo.getBackupid(); DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, - newBackupId, ICON_PATH); + newBackupId, newBackupId, ICON_PATH); newNode.setContainer(false); newNode.setType(CubridNodeType.BACKUP_PLAN); newNode.setModelObj(backupPlanInfo); diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddQueryPlanAction.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddQueryPlanAction.java index 6b124263..293d881d 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddQueryPlanAction.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/cubrid/jobauto/action/AddQueryPlanAction.java @@ -124,7 +124,7 @@ public void run(CubridDatabase database) { QueryPlanInfoHelp queryPlanInfoHelp = editQueryPlanDlg.getQueryPlanInfo(); QueryPlanInfo queryPlanInfo = queryPlanInfoHelp.getQueryPlanInfo(); String newQueryId = queryPlanInfoHelp.getQuery_id(); - newNode = new DefaultSchemaNode(newQueryId, newQueryId, ICON_PATH); + newNode = new DefaultSchemaNode(newQueryId, newQueryId, newQueryId, ICON_PATH); newNode.setContainer(false); newNode.setType(CubridNodeType.QUERY_PLAN); newNode.setModelObj(queryPlanInfo); diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbConnectionLoader.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbConnectionLoader.java index ce91c77e..ab220b62 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbConnectionLoader.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbConnectionLoader.java @@ -124,7 +124,7 @@ private void addProcedureFolder(final IProgressMonitor monitor, String spFolderId = database.getId() + NODE_SEPARATOR + SP_FOLDER_ID; ICubridNode spFolder = database.getChild(spFolderId); if (spFolder == null) { - spFolder = new DefaultSchemaNode(spFolderId, SP_FOLDER_NAME, + spFolder = new DefaultSchemaNode(spFolderId, SP_FOLDER_NAME, SP_FOLDER_NAME, "icons/navigator/procedure_group.png"); spFolder.setType(NodeType.STORED_PROCEDURE_FOLDER); spFolder.setContainer(true); @@ -156,7 +156,7 @@ private void addSerialFolder(final IProgressMonitor monitor, ICubridNode serialFolder = database.getChild(serialFolderId); if (serialFolder == null) { serialFolder = new DefaultSchemaNode(serialFolderId, - SERIAL_FOLDER_NAME, "icons/navigator/serial_group.png"); + SERIAL_FOLDER_NAME, SP_FOLDER_NAME, "icons/navigator/serial_group.png"); serialFolder.setType(NodeType.SERIAL_FOLDER); serialFolder.setContainer(true); ICubridNodeLoader loader = new CubridSerialFolderLoader(); @@ -191,7 +191,7 @@ private void addTriggerFolder(final IProgressMonitor monitor, ICubridNode tiggerFolder = database.getChild(tiggerFolderId); if (tiggerFolder == null) { tiggerFolder = new DefaultSchemaNode(tiggerFolderId, - TRIGGER_FOLDER_NAME, "icons/navigator/trigger_group.png"); + TRIGGER_FOLDER_NAME, TRIGGER_FOLDER_NAME, "icons/navigator/trigger_group.png"); tiggerFolder.setType(NodeType.TRIGGER_FOLDER); tiggerFolder.setContainer(true); ICubridNodeLoader loader = new CubridTriggerFolderLoader(); @@ -223,7 +223,7 @@ private void addViewFolder(final IProgressMonitor monitor, ICubridNode viewsFolder = database.getChild(viewsFolderId); if (viewsFolder == null) { viewsFolder = new DefaultSchemaNode(viewsFolderId, - VIEWS_FOLDER_NAME, "icons/navigator/schema_view.png"); + VIEWS_FOLDER_NAME, VIEWS_FOLDER_NAME, "icons/navigator/schema_view.png"); viewsFolder.setType(NodeType.VIEW_FOLDER); viewsFolder.setContainer(true); ICubridNodeLoader loader = new CubridViewsFolderLoader(); @@ -254,7 +254,7 @@ private void addUserFolder(final IProgressMonitor monitor, + USERS_FOLDER_ID; ICubridNode userFolder = database.getChild(userFolderId); if (userFolder == null) { - userFolder = new DefaultSchemaNode(userFolderId, USERS_FOLDER_NAME, + userFolder = new DefaultSchemaNode(userFolderId, USERS_FOLDER_NAME, USERS_FOLDER_NAME, "icons/navigator/user_group.png"); userFolder.setType(NodeType.USER_FOLDER); userFolder.setContainer(true); @@ -287,7 +287,7 @@ private void addTableFolder(final IProgressMonitor monitor, ICubridNode tablesFolder = database.getChild(tablesFolderId); if (tablesFolder == null) { tablesFolder = new DefaultSchemaNode(tablesFolderId, - TABLES_FOLDER_NAME, "icons/navigator/schema_table.png"); + TABLES_FOLDER_NAME, TABLES_FOLDER_NAME, "icons/navigator/schema_table.png"); tablesFolder.setType(NodeType.TABLE_FOLDER); tablesFolder.setContainer(true); ICubridNodeLoader loader = new CubridTablesFolderLoader(); diff --git a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbUsersFolderLoader.java b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbUsersFolderLoader.java index 44c9e2bf..9f9e5524 100644 --- a/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbUsersFolderLoader.java +++ b/com.cubrid.cubridmanager.ui/src/com/cubrid/cubridmanager/ui/spi/model/loader/CQBDbUsersFolderLoader.java @@ -107,7 +107,7 @@ public void load(ICubridNode parent, final IProgressMonitor monitor) { String id = parent.getId() + NODE_SEPARATOR + dbUserInfo.getName(); ICubridNode dbUserInfoNode = new DefaultSchemaNode(id, - dbUserInfo.getName(), "icons/navigator/user_item.png"); + dbUserInfo.getName(), dbUserInfo.getName(), "icons/navigator/user_item.png"); dbUserInfoNode.setType(NodeType.USER); dbUserInfoNode.setModelObj(dbUserInfo); dbUserInfoNode.setContainer(false);