private void processDatabases(
      Element root, DefaultDataSet dataset, BdbEnvironment envFormat, List<Database> dbs)
      throws Exception {

    for (Database db : dbs) {
      String dbName = db.getDatabaseName();
      BdbDatabase dbFormat = envFormat.getDatabase(dbName);
      String peerName = envFormat.getPeerName();
      String tagName = (peerName == null) ? dbName : envFormat.getPeerName() + "." + dbName;

      DefaultTable table = new DefaultTable(tagName);
      dataset.addTable(table);
      DatabaseEntry key = new DatabaseEntry();
      DatabaseEntry data = new DatabaseEntry();

      if (dbFormat != null) {
        Cursor c = db.openCursor(null, null);
        int rows = 0;
        try {
          while (c.getNext(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
            rows++;
            byteBufferRead(root, tagName, key, data, dbFormat, schemaIDBinding);
          }
          if (rows == 0) {
            root.addElement(tagName);
          }
        } finally {
          c.close();
        }
      }
    }
  }
Пример #2
0
  private void initialize(DataSource dataSource) throws AmbiguousTableNameException {
    databaseTester = new DataSourceDatabaseTester(dataSource);
    databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
    databaseTester.setTearDownOperation(DatabaseOperation.DELETE_ALL);
    DefaultDataSet dataSet = new DefaultDataSet();
    dataSet.addTable(new DefaultTable("agents"));

    dataSet.addTable(new DefaultTable("pipelines"));
    dataSet.addTable(new DefaultTable("materials"));
    dataSet.addTable(new DefaultTable("modifications"));
    dataSet.addTable(new DefaultTable("pipelineMaterialRevisions"));
    dataSet.addTable(new DefaultTable("modifiedFiles"));

    dataSet.addTable(new DefaultTable("notificationfilters"));
    dataSet.addTable(new DefaultTable("users"));
    dataSet.addTable(new DefaultTable("artifactPropertiesGenerator"));
    dataSet.addTable(new DefaultTable("stages"));
    dataSet.addTable(new DefaultTable("buildCauseBuffer"));
    dataSet.addTable(new DefaultTable("pipelineLabelCounts"));
    dataSet.addTable(new DefaultTable("environmentVariables"));
    dataSet.addTable(new DefaultTable("properties"));
    dataSet.addTable(new DefaultTable("artifactPlans"));
    dataSet.addTable(new DefaultTable("buildStateTransitions"));
    dataSet.addTable(new DefaultTable("resources"));
    dataSet.addTable(new DefaultTable("builds"));

    dataSet.addTable(new DefaultTable("oauthclients"));
    dataSet.addTable(new DefaultTable("oauthauthorizations"));
    dataSet.addTable(new DefaultTable("oauthtokens"));

    dataSet.addTable(new DefaultTable("gadgetOauthClients"));
    dataSet.addTable(new DefaultTable("gadgetOauthAuthorizationCodes"));
    dataSet.addTable(new DefaultTable("gadgetOauthAccessTokens"));
    dataSet.addTable(new DefaultTable("stageArtifactCleanupProhibited"));
    dataSet.addTable(new DefaultTable("serverBackups"));

    databaseTester.setDataSet(dataSet);
  }