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

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


                // ***************************
                // *** ForeignKey ***
                // ***************************

                // trying to find table column with specified name
                TableColumn tableColumn = table.findColumnByName(fkColumnName);

                String errMessage = null;
                // warn if null
                if (tableColumn == null) {
                    errMessage = String.format("[Database %s] Unable to find table column '%5$s' for the table %s (schema %s, catalog %s)",
                                               database.getName(),
                                               tableName,
                                               schemaName,
                                               catalogName,
                                               fkColumnName);
                    traceLog.debug(errMessage);
                }
                // if fail is enabled
                if (failOnError && (tableColumn == null)) {
                    throw new DatabaseMetaDataMethodException(errMessage, "populateForeignKeys");
                }

                // create FK column
                ForeignKeyColumn fkColumn = factory.createForeignKeyColumn();

                // check if we found the original table column
                if (tableColumn != null) {
                    // mark original table column as part of FK
                    tableColumn.setForeignKeyColumn(Boolean.TRUE);
                    // clone properties from original table column to the fkcolumn
                    PropertyUtils.copyProperties(fkColumn, tableColumn);
                } else { // recovery if table column is not found but we still want to create fk column
                    // set name at least
                    fkColumn.setName(fkColumnName);
                }
                // 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


                index.setPages(pages);
                // set filter condition
                index.setFilterCondition(filterCondition);

                // trying to find table column with specified name
                TableColumn tableColumn = table.findColumnByName(indexColumnName);

                String errMessage = null;
                // warn if null
                if (tableColumn == null) {
                    errMessage = String.format("[Database %s] Unable to find table column '%5$s' for the table %s (schema %s, catalog %s)",
                                               database.getName(),
                                               tableName,
                                               schemaName,
                                               catalogName,
                                               indexColumnName);
                    traceLog.debug(errMessage);
                }
                // if fail is enabled
                if (failOnError && (tableColumn == null)) {
                    throw new DatabaseMetaDataMethodException(errMessage, "populateIndexes");

                }

                // create index column
                IndexColumn indexColumn = factory.createIndexColumn();

                // check if we found the original table column
                if (tableColumn != null) {
                    // mark original table column as part of index
                    tableColumn.setIndexColumn(Boolean.TRUE);
                    // clone properties from original table column to the index column
                    PropertyUtils.copyProperties(indexColumn, tableColumn);
                } else { // recovery if table column is not found but we still want to create index column
                    // set name at least
                    indexColumn.setName(indexColumnName);
View Full Code Here

        // pseudo Column Type
        Integer columnPseudoType = getInteger(resultSet, "PSEUDO_COLUMN", false);

        // find table column object
        TableColumn column = table.findColumnByName(columnName);

        // create new
        if (column == null) {
            // creating column if not found (it is pseudo)
            column = factory.createTableColumn();

            // ***************************************
            // *** DatabaseNamedObject properties ***
            // ***************************************

            // name
            column.setName(columnName);

            // ***************
            // *** Column ***
            // ***************

            // owner
            column.setOwner(table);
            // SQL type
            column.setSqlType(getSqlType(dataType));
            // type name
            column.setTypeName(typeName);
            // Size
            column.setSize(size);
            // precision
            column.setPrecision(precision);
            // OrdinalPosition
            column.setOrdinalPosition(null); // N/A

            // ********************
            // *** Table Column ***
            // ********************

            // add column to the table
            table.addColumn(column);
        }

        // set pseudo type
        column.setPseudoType(getColumnPseudoType(columnPseudoType));

        // log
        if (traceLog.isDebugEnabled()) {
            traceLog.debug(String.format("[Database %s] The table '%s' (schema %s, catalog %s) column %s has been updated or added.",
                                         database.getName(),
View Full Code Here

TOP

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

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.