Package org.jboss.dna.common.jdbc.model.api

Examples of org.jboss.dna.common.jdbc.model.api.Table


        super.tearDown();
    }

    public void testSetSourceTable() {
        Table sourceTable = new DefaultModelFactory().createTable();
        // set
        bean.setSourceTable(sourceTable);
        // check
        assertSame("Unable to set source table", sourceTable, bean.getSourceTable());
    }
View Full Code Here


                   id,
                   bean.findBestRowIdentifierByScopeType(BestRowIdentifierScopeType.SESSION));
    }

    public void testSetSuperTable() {
        Table superTable = factory.createTable();
        // set
        bean.setSuperTable(superTable);
        // check
        assertSame("Unable to set super table", superTable, bean.getSuperTable());
    }
View Full Code Here

        super.tearDown();
    }

    public void testSetOwner() {
        // create table
        Table table = new DefaultModelFactory().createTable();
        // set
        bean.setOwner(table);
        // check
        assertSame("Unable to set owner", table, bean.getOwner());
    }
View Full Code Here

    }

    public void testAddTable() {
        String NAME = "My Name";
        // create
        Table object = new DefaultModelFactory().createTable();
        // set
        object.setName(NAME);
        // add
        bean.addTable(object);
        // check
        assertFalse(bean.getTables().isEmpty());
    }
View Full Code Here

    }

    public void testDeleteTable() {
        String NAME = "My Name";
        // create
        Table object = new DefaultModelFactory().createTable();
        // set
        object.setName(NAME);
        // add
        bean.addTable(object);
        // check
        assertFalse(bean.getTables().isEmpty());
View Full Code Here

    }

    public void testFindTableByName() {
        String NAME = "My Name";
        // create
        Table object = new DefaultModelFactory().createTable();
        // set
        object.setName(NAME);
        // add
        bean.addTable(object);
        // check
        assertSame(object, bean.findTableByName(null, null, object.getName()));
    }
View Full Code Here

        assertSame("Unable to find column", column, bean.findColumnByName(COLUMN_NAME));
    }

    public void testSetSourceTable() {
        // create
        Table sourceTable = new DefaultModelFactory().createTable();
        // set
        bean.setSourceTable(sourceTable);
        // check
        assertSame("Unable to set source table", sourceTable, bean.getSourceTable());
    }
View Full Code Here

        String selfRefColumnName = getString(resultSet, "SELF_REFERENCING_COL_NAME", false);
        // get ref generation
        String refGeneration = getString(resultSet, "REF_GENERATION", false);

        // create Table object
        Table table = factory.createTable();

        // ***************************
        // *** DatabaseNamedObject ***
        // ***************************

        // set name
        table.setName(tableName);
        // set remarks
        table.setRemarks(remarks);
        // TODO set extra properties
        // table.addExtraProperty (String key, Object value);

        // ********************
        // *** SchemaObject ***
        // ********************

        // set catalog
        if ((tableCatalog != null) && (tableCatalog.trim().length() != 0)) {
            // find catalog
            Catalog catalog = database.findCatalogByName(tableCatalog);
            // set catalog
            table.setCatalog(catalog);
            // warn if null
            if (catalog == null) {
                traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the table %s (schema %s, catalog %s)",
                                             database.getName(),
                                             tableName,
                                             tableSchema,
                                             tableCatalog));
            }
            // if fail is enabled
            if (failOnError) {
                throw new DatabaseMetaDataMethodException("Catalog name shall be provided", "populateTable");

            }
        }

        // set schema
        if ((tableSchema != null) && (tableSchema.trim().length() != 0)) {
            // find schema
            Schema schema = database.findSchemaByName(tableCatalog, tableSchema);
            // set schema
            table.setSchema(schema);
            // warn if null
            if (schema == null) {
                traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the table %s (schema %s, catalog %s)",
                                             database.getName(),
                                             tableName,
                                             tableSchema,
                                             tableCatalog));
            }
            // if fail is enabled
            if (failOnError) {
                throw new DatabaseMetaDataMethodException("Table name shall be provided", "populateTable");
            }
        }

        // **************
        // *** Table ***
        // **************

        // set table type
        if (tableTypeName != null) {
            // create
            TableType tableType = factory.createTableType();
            // fill
            tableType.setName(tableTypeName);
            // set type
            table.setTableType(tableType);
        }

        // set catalog
        if ((typeCatalogName != null) && (typeCatalogName.trim().length() != 0)) {
            // find catalog
            Catalog typeCatalog = database.findCatalogByName(typeCatalogName);
            // set type catalog
            table.setTypeCatalog(typeCatalog);
            // warn if null
            if (typeCatalog == null) {
                traceLog.debug(String.format("[Database %s] Unable to find catalog '%4$s' for the table %s (schema %s, catalog %s)",
                                             database.getName(),
                                             tableName,
                                             tableSchema,
                                             typeCatalogName));
            }
        }

        // set schema
        if ((typeSchemaName != null) && (typeSchemaName.trim().length() != 0)) {
            // find schema
            Schema typeSchema = database.findSchemaByName(typeCatalogName, typeSchemaName);
            // set schema
            table.setTypeSchema(typeSchema);
            // warn if null
            if (typeSchema == null) {
                traceLog.debug(String.format("[Database %s] Unable to find schema '%3$s' for the table %s (schema %s, catalog %s)",
                                             database.getName(),
                                             tableName,
                                             typeSchemaName,
                                             typeCatalogName));
            }
            // if fail is enabled
            if (failOnError && (typeSchema == null)) {
                throw new DatabaseMetaDataMethodException("Schema name shall be provided", "populateTable");
            }
        }

        // set type name
        table.setTypeName(typeName);
        // set self referencing column name
        table.setSelfReferencingColumnName(selfRefColumnName);
        // set reference generation
        table.setReferenceGeneration(refGeneration);

        // add table to the list
        database.addTable(table);

        // log
View Full Code Here

                }
                // modify ordinal position that correspond to the position in FK
                fkColumn.setOrdinalPosition(ordinalPosition);

                // check for PK table and corresponding PK column
                Table pkTable = database.findTableByName(pkTableCatalogName, pkTableSchemaName, pkTableName);
                // sets the scope table of a foreign key.
                fk.setSourceTable(pkTable);
                // find PK
                PrimaryKey pk = (pkTable == null) ? null : pkTable.getPrimaryKey();
                // set
                fk.setSourcePrimaryKey(pk);

                // What happens to a foreign key when the primary key is updated
                fk.setUpdateRule(getKeyModifyRuleType(updateRule));
                // What happens to a foreign key when the primary key is deleted
                fk.setDeleteRule(getKeyModifyRuleType(deleteRule));
                // Can the evaluation of foreign key constraints be deferred until commit
                fk.setDeferrability(getKeyDeferrabilityType(defferability));

                // find PK table column
                TableColumn pkColumn = (pkTable == null) ? null : pkTable.findColumnByName(pkColumnName);
                // Sets mapped source column (in PK/source table) for this foreign key column
                fkColumn.setSourceColumn(pkColumn);

                // add FK column to the foreign key
                fk.addColumn(fkColumn);
View Full Code Here

TOP

Related Classes of org.jboss.dna.common.jdbc.model.api.Table

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.