Search in sources :

Example 1 with DbObject

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;
}
Also used : DbObject(com.wplatform.ddal.dbobject.DbObject) Right(com.wplatform.ddal.dbobject.Right) Index(com.wplatform.ddal.dbobject.index.Index)

Example 2 with DbObject

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;
}
Also used : Table(com.wplatform.ddal.dbobject.table.Table) DbObject(com.wplatform.ddal.dbobject.DbObject)

Example 3 with DbObject

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);
}
Also used : Comment(com.wplatform.ddal.dbobject.Comment) DbObject(com.wplatform.ddal.dbobject.DbObject)

Aggregations

DbObject (com.wplatform.ddal.dbobject.DbObject)3 Comment (com.wplatform.ddal.dbobject.Comment)1 Right (com.wplatform.ddal.dbobject.Right)1 Index (com.wplatform.ddal.dbobject.index.Index)1 Table (com.wplatform.ddal.dbobject.table.Table)1