use of com.wplatform.ddal.dbobject.DbObject in project jdbc-shards by wplatform.
the class Table method getChildren.
@Override
public ArrayList<DbObject> getChildren() {
ArrayList<DbObject> children = New.arrayList();
ArrayList<Index> indexes = getIndexes();
if (indexes != null) {
children.addAll(indexes);
}
if (sequences != null) {
children.addAll(sequences);
}
ArrayList<Right> rights = database.getAllRights();
for (Right right : rights) {
if (right.getGrantedTable() == this) {
children.add(right);
}
}
return children;
}
use of com.wplatform.ddal.dbobject.DbObject in project jdbc-shards by wplatform.
the class Database method getDependentTable.
/**
* Get the first table that depends on this object.
*
* @param obj the object to find
* @param except the table to exclude (or null)
* @return the first dependent table, or null
*/
public Table getDependentTable(SchemaObject obj, Table except) {
switch(obj.getType()) {
case DbObject.COMMENT:
case DbObject.CONSTRAINT:
case DbObject.INDEX:
case DbObject.RIGHT:
case DbObject.TRIGGER:
case DbObject.USER:
return null;
default:
}
HashSet<DbObject> set = New.hashSet();
for (Table t : getAllTablesAndViews()) {
if (except == t) {
continue;
} else if (Table.VIEW.equals(t.getTableType())) {
continue;
}
set.clear();
t.addDependencies(set);
if (set.contains(obj)) {
return t;
}
}
return null;
}
use of com.wplatform.ddal.dbobject.DbObject in project jdbc-shards by wplatform.
the class Database method removeDatabaseObject.
/**
* Remove the object from the database.
*
* @param session the session
* @param obj the object to remove
*/
public synchronized void removeDatabaseObject(Session session, DbObject obj) {
String objName = obj.getName();
int type = obj.getType();
HashMap<String, DbObject> map = getMap(type);
if (SysProperties.CHECK && !map.containsKey(objName)) {
DbException.throwInternalError("not found: " + objName);
}
Comment comment = findComment(obj);
if (comment != null) {
removeDatabaseObject(session, comment);
}
obj.removeChildrenAndResources(session);
map.remove(objName);
}