Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOOLS-4364] For Support CUBRID Server 11.2 (UserSchema And Etc.) #184

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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;
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -74,26 +74,26 @@ 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<String> partitionValues, int rows) {
this.className = className;
this.tableName = tableName;
this.partitionName = partitionName;
this.partitionType = partitionType;
this.partitionExpr = partitionExpr;
this.setPartitionValues(partitionValues);
this.rows = rows;
}

public PartitionInfo(String className, String partitionName,
public PartitionInfo(String tableName, String partitionName,
String partitionClassName, PartitionType partitionType,
String partitionExpr, List<String> partitionValues, int rows) {
this.className = className;
this.tableName = tableName;
this.partitionName = partitionName;
this.partitionClassName = partitionClassName;
this.partitionType = partitionType;
Expand All @@ -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() {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class SchemaInfo implements Comparable<SchemaInfo>, Cloneable {
private List<PartitionInfo> 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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<DBAttribute> list = new ArrayList<DBAttribute>();
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);
}
}
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1054,7 +1057,7 @@ public boolean isSystemClass() {
* argument obj.
*/
public int compareTo(SchemaInfo obj) {
return classname.compareTo(obj.classname);
return uniqueName.compareTo(obj.uniqueName);
}

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -1308,7 +1320,7 @@ public List<DBAttribute> getLocalClassAttributes() {
}
List<DBAttribute> list = new ArrayList<DBAttribute>();
for (DBAttribute classAttribute : classAttributes) {
if (classAttribute.getInherit().equals(this.getClassname())) {
if (classAttribute.getInherit().equals(this.getUniqueName())) {
list.add(classAttribute);
}
}
Expand All @@ -1327,7 +1339,7 @@ public List<DBAttribute> getLocalAttributes() {
}
List<DBAttribute> list = new ArrayList<DBAttribute>();
for (DBAttribute attribute : attributes) {
if (attribute.getInherit().equals(this.getClassname())) {
if (attribute.getInherit().equals(this.getUniqueName())) {
list.add(attribute);
}
}
Expand All @@ -1346,7 +1358,7 @@ public List<DBAttribute> getInheritClassAttributes() {
}
List<DBAttribute> list = new ArrayList<DBAttribute>();
for (DBAttribute classAttribute : classAttributes) {
if (!classAttribute.getInherit().equals(this.getClassname())) {
if (!classAttribute.getInherit().equals(this.getUniqueName())) {
list.add(classAttribute);
}
}
Expand All @@ -1365,7 +1377,7 @@ public List<DBAttribute> getInheritAttributes() {
}
List<DBAttribute> list = new ArrayList<DBAttribute>();
for (DBAttribute attribute : attributes) {
if (!attribute.getInherit().equals(this.getClassname())) {
if (!attribute.getInherit().equals(this.getUniqueName())) {
list.add(attribute);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.slf4j.Logger;

import com.cubrid.common.core.util.LogUtil;
import com.cubrid.common.core.util.QuerySyntax;

/**
*
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class Trigger implements
Comparable<Trigger> { // 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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading