Ejemplo n.º 1
0
  protected void upgradeDatabaseToLatest(DatabaseAccess.Transaction dat, Log l)
      throws SQLException, IllegalArgumentException {

    /* add all database updates here
     * first get the database version by reading the navconfig table
     */
    String currversion = OmVersion.getVersion();
    l.logDebug("DatabaseUpgrade " + currversion);

    NavVersion DBversion = new NavVersion("");

    /* read the navconfig table into a namepair list */
    ResultSet rs = queryNavConfig(dat);

    NameValuePairs navconfigDB = new NameValuePairs();
    while (rs.next()) {
      navconfigDB.add(rs.getString(1), rs.getString(2));
    }

    /* now find the version */
    String Names[] = navconfigDB.getNames();
    String Values[] = navconfigDB.getValues();
    /* read the current version from the database */
    for (int i = 0; i < Names.length; i++) {
      if (Names[i].compareToIgnoreCase("dbversion") == 0) {
        DBversion.setVersion(Values[i]);
      }
    }
    /* if the current database version is less than the navigator version, check for updates */
    if (DBversion.isLessThanStr(currversion)) {
      /* make sure these are listed in version order, because the function updates the DB version as we go */
      l.logDebug(
          "DatabaseUpgrade",
          "Applying database upgrades, version before update " + DBversion.getVersion());

      updateDatabase(
          "1.10.1",
          DBversion,
          "ALTER TABLE " + getPrefix() + "params ALTER COLUMN paramvalue NVARCHAR(4000)",
          l,
          dat);

      /* finally having applied all the updates set the DB version to the current */
      l.logDebug("DatabaseUpgrade", "Update DB version to current " + currversion);
      dat.update(
          "UPDATE "
              + getPrefix()
              + "navconfig SET value = \'"
              + currversion
              + "\' where name=\'dbversion\'");

      applyUpdateForEmailNotification(dat, l, DBversion);

    } else {
      l.logDebug(
          "DatabaseUpgrade",
          "Database up to date at version " + DBversion.getVersion() + " no updates attempted.");
    }
  }
Ejemplo n.º 2
0
  /**
   * Obtains a random number generator based on the seed, attempts and navigatorVersion passed by
   * the test navigator. If 'incrementSeed' is false attempts and navigatorVersion wont be used to
   * get the random number generator.
   *
   * @param sGroup Group name (arbitrary string)
   * @param incrementSeed If true, then increments the random seed passed by the test navigator
   * @return Random number generator
   */
  private Random getRandom(String sGroup, boolean incrementSeed) {
    // Returns NotSoRandom object if fixed variant is used.
    if (nsr != null) {
      return nsr;
    }
    long randomSeed = ip.getRandomSeed();

    // Increment seed if the request is from OpenMark test navigator only
    if (ip.getNavigatorVersion() != null && incrementSeed) {
      int seedIncrement = MAGIC_RANDOM_SEED_INCREMENT;
      if (OmVersion.compareVersions(ip.getNavigatorVersion(), "1.3.0") <= 0) {
        seedIncrement = 1;
      }
      randomSeed = randomSeed + ip.getAttempt() * seedIncrement;
    }

    long lHash = sGroup.hashCode();
    return new Random(randomSeed ^ lHash);
  }