当前位置: 首页>>代码示例>>Java>>正文


Java Database.getTableCount方法代码示例

本文整理汇总了Java中org.apache.ddlutils.model.Database.getTableCount方法的典型用法代码示例。如果您正苦于以下问题:Java Database.getTableCount方法的具体用法?Java Database.getTableCount怎么用?Java Database.getTableCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ddlutils.model.Database的用法示例。


在下文中一共展示了Database.getTableCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTables

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Outputs the DDL required to drop (if requested) and (re)create all tables in the database model.
 * 
 * @param database   The database
 * @param params     The parameters used in the creation
 * @param dropTables Whether to drop tables before creating them
 */
public void createTables(Database database, CreationParameters params, boolean dropTables) throws IOException
{
    if (dropTables)
    {
        dropTables(database);
    }

    for (int idx = 0; idx < database.getTableCount(); idx++)
    {
        Table table = database.getTable(idx);

        writeTableComment(table);
        createTable(database,
                    table,
                    params == null ? null : params.getParametersFor(table));
    }

    // we're writing the external foreignkeys last to ensure that all referenced tables are already defined
    createForeignKeys(database);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:SqlBuilder.java

示例2: testZDeleteClient

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Test which copies a client, then deletes it, and then tests that the foreign keys are still
 * activated
 */
@Test
public void testZDeleteClient() {
  Platform platform = SystemService.getInstance().getPlatform();
  ExcludeFilter excludeFilter = DBSMOBUtil.getInstance().getExcludeFilter(
      new File(OBPropertiesProvider.getInstance().getOpenbravoProperties()
          .getProperty("source.path")));
  Database dbBefore = platform.loadTablesFromDatabase(excludeFilter);
  String newClientId = exportImport(QA_TEST_CLIENT_ID);
  Client client = OBDal.getInstance().get(Client.class, newClientId);

  SystemService.getInstance().deleteClient(client);
  Database dbAfter = platform.loadTablesFromDatabase(excludeFilter);
  for (int i = 0; i < dbBefore.getTableCount(); i++) {
    Table table1 = dbBefore.getTable(i);
    Table table2 = dbAfter.getTable(i);
    for (int j = 0; j < table1.getForeignKeyCount(); j++) {
      assertTrue(table1.getForeignKey(j).equals(table2.getForeignKey(j)));
    }
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:25,代码来源:ClientExportImportTest.java

示例3: apply

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void apply(Database database, boolean caseSensitive)
{
    // we only need to replace the table in the model, as there can't be a
    // foreign key from or to it when these kind of changes are created
    for (int tableIdx = 0; tableIdx < database.getTableCount(); tableIdx++)
    {
        Table curTable = database.getTable(tableIdx);

        if ((caseSensitive  && curTable.getQualifiedName().equals(getChangedTable())) ||
            (!caseSensitive && curTable.getQualifiedName().equalsIgnoreCase(getChangedTable())))
        {
            database.removeTable(tableIdx);
            database.addTable(tableIdx, new CloneHelper().clone(_targetTable, true, false, database, caseSensitive));
            break;
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:RecreateTableChange.java

示例4: compareModels

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Compares the given source and target models and creates change objects to get from
 * the source to the target one. These changes will be applied to the given
 * intermediate model (the other two won't be changed), so that it will be equal to
 * the target model after this model has finished.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List compareModels(Database sourceModel,
                             Database intermediateModel,
                             Database targetModel)
{
    ArrayList changes = new ArrayList();

    changes.addAll(checkForRemovedForeignKeys(sourceModel, intermediateModel, targetModel));
    changes.addAll(checkForRemovedTables(sourceModel, intermediateModel, targetModel));

    for (int tableIdx = 0; tableIdx < intermediateModel.getTableCount(); tableIdx++)
    {
        Table intermediateTable = intermediateModel.getTable(tableIdx);
        Table sourceTable       = sourceModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        Table targetTable       = targetModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        List  tableChanges      = compareTables(sourceModel, sourceTable,
                                                intermediateModel, intermediateTable,
                                                targetModel, targetTable);

        changes.addAll(tableChanges);
    }

    changes.addAll(checkForAddedTables(sourceModel, intermediateModel, targetModel));
    changes.addAll(checkForAddedForeignKeys(sourceModel, intermediateModel, targetModel));
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:ModelComparator.java

示例5: getFilteredParameters

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Filters the parameters for the given model and platform.
 * 
 * @param model           The database model
 * @param platformName    The name of the platform
 * @param isCaseSensitive Whether case is relevant when comparing names of tables
 * @return The filtered parameters
 */
protected CreationParameters getFilteredParameters(Database model, String platformName, boolean isCaseSensitive)
{
    CreationParameters parameters = new CreationParameters();

    for (Iterator it = _parameters.iterator(); it.hasNext();)
    {
        TableSpecificParameter param = (TableSpecificParameter)it.next();

        if (param.isForPlatform(platformName))
        {
            for (int idx = 0; idx < model.getTableCount(); idx++)
            {
                Table table = model.getTable(idx);

                if (param.isForTable(table, isCaseSensitive))
                {
                    parameters.addParameter(table, param.getName(), param.getValue());
                }
            }
        }
    }
    return parameters;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:DatabaseCommandWithCreationParameters.java

示例6: writeDatabaseElement

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Writes the database model to the given XML writer.
 * 
 * @param model     The database model
 * @param xmlWriter The XML writer
 */
private void writeDatabaseElement(Database model, PrettyPrintingXmlWriter xmlWriter) throws DdlUtilsXMLException
{
    writeElementStart(xmlWriter, QNAME_ELEMENT_DATABASE);
    xmlWriter.writeNamespace(null, DDLUTILS_NAMESPACE);
    writeAttribute(xmlWriter, QNAME_ATTRIBUTE_NAME,              model.getName());
    writeAttribute(xmlWriter, QNAME_ATTRIBUTE_DEFAULT_ID_METHOD, model.getIdMethod());
    writeAttribute(xmlWriter, QNAME_ATTRIBUTE_VERSION,           model.getVersion());
    if (model.getTableCount() > 0)
    {
        xmlWriter.printlnIfPrettyPrinting();
        for (int idx = 0; idx < model.getTableCount(); idx++)
        {
            writeTableElement(model.getTable(idx), xmlWriter);
        }
    }
    writeElementEnd(xmlWriter);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:DatabaseIO.java

示例7: getTableCreationParameters

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Returns the test table creation parameters for the given model.
 * 
 * @param model The model
 * @return The creation parameters
 */
protected CreationParameters getTableCreationParameters(Database model)
{
    CreationParameters params = new CreationParameters();

    for (Iterator entryIt = _testProps.entrySet().iterator(); entryIt.hasNext();)
    {
        Map.Entry entry = (Map.Entry)entryIt.next();
        String    name  = (String)entry.getKey();
        String    value = (String)entry.getValue();

        if (name.startsWith(DDLUTILS_TABLE_CREATION_PREFIX))
        {
            name = name.substring(DDLUTILS_TABLE_CREATION_PREFIX.length());
            for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
            {
                params.addParameter(model.getTable(tableIdx), name, value);
            }
        }
    }
    return params;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:TestAgainstLiveDatabaseBase.java

示例8: postprocessModelFromDatabase

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Allows the platform to postprocess the model just read from the database.
 * 
 * @param model The model
 */
protected void postprocessModelFromDatabase(Database model)
{
    // Default values for CHAR/VARCHAR/LONGVARCHAR columns have quotation marks
    // around them which we'll remove now
    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++)
        {
            Column column = table.getColumn(columnIdx);

            if (TypeMap.isTextType(column.getTypeCode()) ||
                TypeMap.isDateTimeType(column.getTypeCode()))
            {
                String defaultValue = column.getDefaultValue();

                if ((defaultValue != null) && (defaultValue.length() >= 2) &&
                    defaultValue.startsWith("'") && defaultValue.endsWith("'"))
                {
                    defaultValue = defaultValue.substring(1, defaultValue.length() - 1);
                    column.setDefaultValue(defaultValue);
                }
            }
        }
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:33,代码来源:PlatformImplBase.java

示例9: createForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates the external foreignkey creation statements for all tables in the database.
 * 
 * @param database The database
 */
public void createForeignKeys(Database database) throws IOException
{
    for (int idx = 0; idx < database.getTableCount(); idx++)
    {
        createForeignKeys(database, database.getTable(idx));
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:13,代码来源:SqlBuilder.java

示例10: createForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * 
 * {@inheritDoc}
 */
public void createForeignKeys(Database database) throws IOException
{
    for (int idx = 0; idx < database.getTableCount(); idx++)
    {
        createForeignKeys(database, database.getTable(idx));
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:12,代码来源:FirebirdBuilder.java

示例11: checkForAddedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
protected List checkForAddedForeignKeys(Database sourceModel,
                                        Database intermediateModel,
                                        Database targetModel)
{
    List changes           = super.checkForAddedForeignKeys(sourceModel, intermediateModel, targetModel);
    List additionalChanges = new ArrayList();

    // re-adding all foreign keys that are maintained and that use a changed column
    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table sourceTable       = sourceModel.findTable(targetTable.getName(), isCaseSensitive());
        Table intermediateTable = intermediateModel.findTable(targetTable.getName(), isCaseSensitive());

        if (sourceTable != null)
        {
            for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
            {
                ForeignKey targetFk       = targetTable.getForeignKey(fkIdx);
                ForeignKey sourceFk       = findCorrespondingForeignKey(sourceTable, targetFk);
                ForeignKey intermediateFk = findCorrespondingForeignKey(intermediateTable, targetFk);

                if ((sourceFk != null) && (intermediateFk == null))
                {
                    additionalChanges.add(new AddForeignKeyChange(intermediateTable.getName(), targetFk));
                }
            }
        }
    }
    for (Iterator changeIt = additionalChanges.iterator(); changeIt.hasNext();)
    {
        ((AddForeignKeyChange)changeIt.next()).apply(intermediateModel, isCaseSensitive());
    }
    changes.addAll(additionalChanges);
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:40,代码来源:MSSqlModelComparator.java

示例12: sortForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Sorts the foreign keys in the tables of the model.
 * 
 * @param model The model
 */
protected void sortForeignKeys(Database model)
{
    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        model.getTable(tableIdx).sortForeignKeys(getPlatform().isDelimitedIdentifierModeOn());
    }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:13,代码来源:JdbcModelReader.java

示例13: checkForRemovedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for foreign keys that are present in the given source model but are no longer in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForRemovedForeignKeys(Database sourceModel,
                                          Database intermediateModel,
                                          Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < intermediateModel.getTableCount(); tableIdx++)
    {
        Table        intermediateTable = intermediateModel.getTable(tableIdx);
        Table        targetTable       = targetModel.findTable(intermediateTable.getQualifiedName(), _caseSensitive);
        ForeignKey[] intermediateFks   = intermediateTable.getForeignKeys();

        // Dropping foreign keys from tables to be removed might not be necessary, but some databases might require it
        for (int fkIdx = 0; fkIdx < intermediateFks.length; fkIdx++)
        {
            ForeignKey sourceFk = intermediateFks[fkIdx];
            ForeignKey targetFk = targetTable == null ? null : findCorrespondingForeignKey(targetTable, sourceFk);

            if (targetFk == null)
            {
                if (_log.isInfoEnabled())
                {
                    _log.info("Foreign key " + sourceFk + " needs to be removed from table " + intermediateTable.getQualifiedName());
                }

                RemoveForeignKeyChange fkChange = new RemoveForeignKeyChange(intermediateTable.getQualifiedName(), sourceFk);

                changes.add(fkChange);
                fkChange.apply(intermediateModel, _caseSensitive);
            }
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:ModelComparator.java

示例14: checkForAddedForeignKeys

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for foreign keys that are not present in the given source model but are in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForAddedForeignKeys(Database sourceModel,
                                        Database intermediateModel,
                                        Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table intermediateTable = intermediateModel.findTable(targetTable.getQualifiedName(), _caseSensitive);

        for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
        {
            ForeignKey targetFk       = targetTable.getForeignKey(fkIdx);
            ForeignKey intermediateFk = findCorrespondingForeignKey(intermediateTable, targetFk);

            if (intermediateFk == null)
            {
                if (_log.isInfoEnabled())
                {
                    _log.info("Foreign key " + targetFk + " needs to be added to table " + intermediateTable.getQualifiedName());
                }

                intermediateFk = _cloneHelper.clone(targetFk, intermediateTable, intermediateModel, _caseSensitive);

                AddForeignKeyChange fkChange = new AddForeignKeyChange(intermediateTable.getQualifiedName(), intermediateFk);

                changes.add(fkChange);
                fkChange.apply(intermediateModel, _caseSensitive);
            }
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:ModelComparator.java

示例15: checkForAddedTables

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Creates change objects for tables that are not present in the given source model but are in the target
 * model, and applies them to the given intermediate model.
 * 
 * @param sourceModel       The source model
 * @param intermediateModel The intermediate model to apply the changes to
 * @param targetModel       The target model
 * @return The changes
 */
protected List checkForAddedTables(Database sourceModel,
                                   Database intermediateModel,
                                   Database targetModel)
{
    List changes = new ArrayList();

    for (int tableIdx = 0; tableIdx < targetModel.getTableCount(); tableIdx++)
    {
        Table targetTable       = targetModel.getTable(tableIdx);
        Table intermediateTable = intermediateModel.findTable(targetTable.getQualifiedName(), _caseSensitive);

        if (intermediateTable == null)
        {
            if (_log.isInfoEnabled())
            {
                _log.info("Table " + targetTable.getQualifiedName() + " needs to be added");
            }

            // we're using a clone of the target table, and remove all foreign
            // keys as these will be added later
            intermediateTable = _cloneHelper.clone(targetTable, true, false, intermediateModel, _caseSensitive);

            AddTableChange tableChange = new AddTableChange(intermediateTable);

            changes.add(tableChange);
            tableChange.apply(intermediateModel, _caseSensitive);
        }
    }
    return changes;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:40,代码来源:ModelComparator.java


注:本文中的org.apache.ddlutils.model.Database.getTableCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。