Package org.hsqldb.lib

Examples of org.hsqldb.lib.HsqlArrayList


     * @throws HsqlException
     */
    private void processRoleGrantOrRevoke(boolean grant) throws HsqlException {

        String         token;
        HsqlArrayList  list = new HsqlArrayList();
        String         role;
        GranteeManager granteeManager = database.getGranteeManager();

        do {
            role = tokenizer.getSimpleToken();

            Trace.check(granteeManager.isRole(role),
                        (grant ? Trace.NO_SUCH_ROLE_GRANT
                               : Trace.NO_SUCH_ROLE_REVOKE));
            list.add(role);
        } while (tokenizer.isGetThis(Token.T_COMMA));

        tokenizer.getThis(grant ? Token.T_TO
                                : Token.T_FROM);

        token = getUserIdentifier();

        GranteeManager gm = database.getGranteeManager();

        for (int i = 0; i < list.size(); i++) {
            if (grant) {
                gm.grant(token, (String) list.get(i));
            } else {
                gm.revoke(token, (String) list.get(i));
            }
        }
    }
View Full Code Here


        String privilege;
        String isGrantable;

        // intermediate holders
        UserManager   um;
        HsqlArrayList users;
        HashSet       classNameSet;
        Iterator      classNames;
        User          granteeUser;
        Object[]      row;

        // column number mappings
        final int icls_cat   = 0;
        final int icls_schem = 1;
        final int icls_name  = 2;
        final int igrantor   = 3;
        final int igrantee   = 4;
        final int iprivilege = 5;
        final int iis_grntbl = 6;

        // Initialization
        grantorName = GranteeManager.DBA_ADMIN_ROLE_NAME;
        um          = database.getUserManager();
        users       = um.listVisibleUsers(session, true);

        // Do it.
        for (int i = 0; i < users.size(); i++) {
            granteeUser  = (User) users.get(i);
            granteeName  = granteeUser.getName();
            isGrantable  = granteeUser.isAdmin() ? "YES"
                                                 : "NO";
            classNameSet = granteeUser.getGrantedClassNames(false);
View Full Code Here

        // Intermediate holders
        Iterator        tables;
        Table           table;
        HsqlArrayList[] vTrigs;
        HsqlArrayList   triggerList;
        TriggerDef      def;
        Object[]        row;

        // column number mappings
        final int itrigger_cat       = 0;
        final int itrigger_schem     = 1;
        final int itrigger_name      = 2;
        final int itrigger_type      = 3;
        final int itriggering_event  = 4;
        final int itable_cat         = 5;
        final int itable_schem       = 6;
        final int ibase_object_type  = 7;
        final int itable_name        = 8;
        final int icolumn_name       = 9;
        final int ireferencing_names = 10;
        final int iwhen_clause       = 11;
        final int istatus            = 12;
        final int idescription       = 13;
        final int iaction_type       = 14;
        final int itrigger_body      = 15;

        // Initialization
        tables = database.schemaManager.allTablesIterator();

        // these are the only values supported, currently
        actionType       = "CALL";
        baseObjectType   = "TABLE";
        columnName       = null;
        referencingNames = "ROW";
        whenClause       = null;

        // Do it.
        while (tables.hasNext()) {
            table  = (Table) tables.next();
            vTrigs = table.triggerLists;

            // faster test first
            if (vTrigs == null) {
                continue;
            }

            if (!isAccessibleTable(table)) {
                continue;
            }

            tableCatalog   = ns.getCatalogName(table);
            triggerCatalog = tableCatalog;
            tableSchema    = table.getSchemaName();
            triggerSchema  = tableSchema;
            tableName      = table.getName().name;

            for (int i = 0; i < vTrigs.length; i++) {
                triggerList = vTrigs[i];

                if (triggerList == null) {
                    continue;
                }

                for (int j = 0; j < triggerList.size(); j++) {
                    def = (TriggerDef) triggerList.get(j);

                    if (def == null) {
                        continue;
                    }
View Full Code Here

        String  specificName;
        int     colSequence;
        int     colCount;

        // intermediate holders
        HsqlArrayList aliasList;
        Object[]      info;
        Method        method;
        Iterator      methods;
        Object[]      row;
        DITypeInfo    ti;
View Full Code Here

     *  which reflects the structure of the underlying tables at the *time of the definition
     *  of the view.
     */
    private void replaceAsterisksInStatement() {

        HsqlArrayList asteriskPositions = new HsqlArrayList();

        asteriskPositions.setSize(statement.length());

        // asterisk positions in sub queries
        for (int i = 0; i < viewSubqueries.length; ++i) {

            // collect the occurances of asterisks in the statement
            Select subSelect = viewSubqueries[i].select;

            collectAsteriskPos(subSelect, asteriskPositions);

            // the same for all (possible) UNION SELECTs of the sub select
            if (subSelect.unionArray != null) {

                // start with index 1, not 0 - the first select is the one already covered by subSelect
                for (int u = 1; u < subSelect.unionArray.length; ++u) {
                    collectAsteriskPos(subSelect.unionArray[u],
                                       asteriskPositions);
                }
            }
        }

        StringBuffer expandedStatement = new StringBuffer(statement);

        for (int pos = asteriskPositions.size() - 1; pos >= 0; --pos) {
            String colList = (String) asteriskPositions.get(pos);

            if (colList == null) {
                continue;
            }

View Full Code Here

    /**
     * Returns list of schemas
     */
    HsqlName[] getSchemas() {

        HsqlArrayList list = new HsqlArrayList();

        for (int i = 0; i < viewSubqueries.length; i++) {
            Select select = viewSubqueries[i].select;

            for (; select != null; select = select.unionSelect) {
                TableFilter[] tfilter = select.tFilter;

                for (int j = 0; j < tfilter.length; j++) {
                    list.add(tfilter[j].filterTable.tableName.schema);
                }
            }
        }

        return (HsqlName[]) list.toArray(new HsqlName[list.size()]);
    }
View Full Code Here

        int[]         mainCols;
        int[]         refCols;
        Constraint[]  constraints;
        Constraint    constraint;
        int           constraintCount;
        HsqlArrayList fkConstraintsList;
        Object[]      row;
        DITableInfo   pkInfo;
        DITableInfo   fkInfo;

        // column number mappings
        final int ipk_table_cat   = 0;
        final int ipk_table_schem = 1;
        final int ipk_table_name  = 2;
        final int ipk_column_name = 3;
        final int ifk_table_cat   = 4;
        final int ifk_table_schem = 5;
        final int ifk_table_name  = 6;
        final int ifk_column_name = 7;
        final int ikey_seq        = 8;
        final int iupdate_rule    = 9;
        final int idelete_rule    = 10;
        final int ifk_name        = 11;
        final int ipk_name        = 12;
        final int ideferrability  = 13;

        tables = database.schemaManager.allTablesIterator();
        pkInfo = new DITableInfo();
        fkInfo = new DITableInfo();

        // the only deferrability rule currently supported by hsqldb is:
        deferrability = ValuePool.getInt(Constraint.NOT_DEFERRABLE);

        // We must consider all the constraints in all the user tables, since
        // this is where reference relationships are recorded.  However, we
        // are only concerned with Constraint.FOREIGN_KEY constraints here
        // because their corresponing Constraint.MAIN entries are essentially
        // duplicate data recorded in the referenced rather than the
        // referencing table.  Also, we skip constraints where either
        // the referenced, referencing or both tables are not accessible
        // relative to the session of the calling context
        fkConstraintsList = new HsqlArrayList();

        while (tables.hasNext()) {
            table = (Table) tables.next();

            if (!isAccessibleTable(table)) {
                continue;
            }

            constraints     = table.getConstraints();
            constraintCount = constraints.length;

            for (int i = 0; i < constraintCount; i++) {
                constraint = (Constraint) constraints[i];

                if (constraint.getType() == Constraint.FOREIGN_KEY
                        && isAccessibleTable(constraint.getRef())) {
                    fkConstraintsList.add(constraint);
                }
            }
        }

        // Now that we have all of the desired constraints, we need to
        // process them, generating one row in our ouput table for each
        // imported/exported column pair of each constraint.
        // Do it.
        for (int i = 0; i < fkConstraintsList.size(); i++) {
            constraint = (Constraint) fkConstraintsList.get(i);
            pkTable    = constraint.getMain();

            pkInfo.setTable(pkTable);

            pkTableName = pkInfo.getName();
View Full Code Here

        String granteeName;
        String privilege;
        String isGrantable;

        // intermediate holders
        HsqlArrayList users;
        User          user;
        String[]      tablePrivileges;
        Iterator      tables;
        Table         table;
        HsqlName      accessKey;
        Object[]      row;

        // column number mappings
        final int itable_cat    = 0;
        final int itable_schem  = 1;
        final int itable_name   = 2;
        final int igrantor      = 3;
        final int igrantee      = 4;
        final int iprivilege    = 5;
        final int iis_grantable = 6;

        // Initialization
        grantorName = GranteeManager.DBA_ADMIN_ROLE_NAME;
        users = database.getUserManager().listVisibleUsers(session, true);
        tables      = allTables();

        // Do it.
        while (tables.hasNext()) {
            table     = (Table) tables.next();
            accessKey = table.getName();

            // Only show table grants if session user is admin, has some
            // right, or the special PUBLIC user has some right.
            if (!isAccessibleTable(table)) {
                continue;
            }

            tableName    = table.getName().name;
            tableCatalog = ns.getCatalogName(table);
            tableSchema  = table.getSchemaName();

            for (int i = 0; i < users.size(); i++) {
                user        = (User) users.get(i);
                granteeName = user.getName();

                if (user.isAdmin()) {
                    tablePrivileges =
                        UserManager.getRightsArray(UserManager.ALL);
View Full Code Here

            return t;
        }

        // Intermediate holders
        HsqlArrayList users;
        User          user;
        int           userCount;
        Object[]      row;

        // Initialization
        users = database.getUserManager().listVisibleUsers(session, false);

        // Do it.
        for (int i = 0; i < users.size(); i++) {
            row    = t.getEmptyRowData();
            user   = (User) users.get(i);
            row[0] = user.getName();
            row[1] = ValuePool.getBoolean(user.isAdmin());

            t.insertSys(row);
        }
View Full Code Here

        Iterator      tables;
        Table         table;
        Constraint[]  tableConstraints;
        int           constraintCount;
        Constraint    constraint;
        HsqlArrayList constraintList;
        Object[]      row;

        // column number mappings
        final int icons_cat    = 0;
        final int icons_schem  = 1;
        final int icons_name   = 2;
        final int icons_clause = 3;

        tables         = database.schemaManager.allTablesIterator();
        constraintList = new HsqlArrayList();

        while (tables.hasNext()) {
            table = (Table) tables.next();

            if (!isAccessibleTable(table)) {
                continue;
            }

            tableConstraints = table.getConstraints();
            constraintCount  = tableConstraints.length;

            for (int i = 0; i < constraintCount; i++) {
                constraint = (Constraint) tableConstraints[i];

                if (constraint.getType() == Constraint.CHECK) {
                    constraintList.add(constraint);
                }
            }
        }

        for (int i = 0; i < constraintList.size(); i++) {
            row              = t.getEmptyRowData();
            constraint       = (Constraint) constraintList.get(i);
            table            = constraint.getMain();
            row[icons_cat]   = ns.getCatalogName(table);
            row[icons_schem] = table.getSchemaName();
            row[icons_name= constraint.constName.name;
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.HsqlArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.