Package org.sonar.server.db.migrations

Examples of org.sonar.server.db.migrations.MassUpdate$Handler


  @Override
  public void execute(Context context) throws SQLException {
    final Date now = new Date(system.now());

    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT p.id FROM projects p WHERE p.scope=? AND p.enabled=?").setString(1, "PRJ").setBoolean(2, true);
    massUpdate.update("UPDATE projects SET authorization_updated_at=? WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long id = row.getLong(1);
        update.setDate(1, now);
        update.setLong(2, id);
View Full Code Here


    super(database);
  }

  @Override
  public void execute(Context context) throws SQLException {
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT i.id, r.name FROM issues i INNER JOIN rules r ON r.id=i.rule_id WHERE i.message IS NULL");
    massUpdate.update("UPDATE issues SET message=? WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long issueId = row.getLong(1);
        String ruleName = row.getString(2);
View Full Code Here

    super(database);
  }

  @Override
  public void execute(Context context) throws SQLException {
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT id, kee FROM projects WHERE qualifier='PAC'");
    massUpdate.update("UPDATE projects SET qualifier='DIR', kee=? WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long id = row.getLong(1);
        String key = row.getString(2);
        update.setString(1, convertKey(key));
View Full Code Here

    super(db);
  }

  @Override
  public void execute(Context context) throws SQLException {
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT ss.id, s.build_date " +
      "FROM snapshot_sources ss " +
      "INNER JOIN snapshots s ON s.id = ss.snapshot_id " +
      "WHERE ss.updated_at IS NULL");
    massUpdate.update("UPDATE snapshot_sources " +
      "SET updated_at=? " +
      "WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        update.setDate(1, row.getDate(2));
        update.setLong(2, row.getLong(1));
        return true;
View Full Code Here

    super(db);
  }

  @Override
  public void execute(Context context) throws SQLException {
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("select id,data_field from activities where log_type='QPROFILE'");
    massUpdate.update("delete from activities where id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        String csv = row.getString(2);
        if (isUnescaped(csv)) {
          update.setLong(1, row.getLong(1));
View Full Code Here

  public void execute(Context context) throws SQLException {
    workDurationConvertor.init();

    Long metricId = context.prepareSelect("select id from metrics where name='development_cost'").get(Select.LONG_READER);
    if (metricId != null) {
      MassUpdate massUpdate = context.prepareMassUpdate();
      massUpdate.select("select id, value from project_measures where metric_id=? and value is not null").setLong(1, metricId);
      massUpdate.update("update project_measures set value=NULL,text_value=? where id=?");
      massUpdate.execute(new MassUpdate.Handler() {
        @Override
        public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
          Long id = row.getLong(1);
          Double value = row.getDouble(2);
View Full Code Here

      "or name='sqale_effort_to_grade_a' or name='sqale_effort_to_grade_b' or name='sqale_effort_to_grade_c' " +
      "or name='sqale_effort_to_grade_d' or name='blocker_remediation_cost' or name='critical_remediation_cost' " +
      "or name='major_remediation_cost' or name='minor_remediation_cost' or name='info_remediation_cost'").list(Select.LONG_READER);

    if (!metricIds.isEmpty()) {
      MassUpdate massUpdate = context.prepareMassUpdate();
      massUpdate.rowPluralName("measures");

      SqlStatement select = massUpdate.select("SELECT pm.id, pm.value " +
        ", pm.variation_value_1 , pm.variation_value_2, pm.variation_value_3 " +
        ", pm.variation_value_4 , pm.variation_value_5 " +
        " FROM project_measures pm " +
        " WHERE pm.metric_id IN (" + StringUtils.repeat("?", ",", metricIds.size()) + ")");
      for (int i = 0; i < metricIds.size(); i++) {
        select.setLong(i + 1, metricIds.get(i));
      }
      massUpdate.update("UPDATE project_measures SET value=?," +
        "variation_value_1=?,variation_value_2=?,variation_value_3=?,variation_value_4=?,variation_value_5=? WHERE id=?");
      massUpdate.execute(new Converter());
    }
  }
View Full Code Here

  @Override
  public void execute(Context context) throws SQLException {
    workDurationConvertor.init();
    final Date now = new Date(system2.now());
    MassUpdate massUpdate = context.prepareMassUpdate();

    // See https://jira.codehaus.org/browse/SONAR-5394
    // The SQL request should not set the filter on technical_debt is not null. There's no index
    // on this column, so filtering is done programmatically.
    massUpdate.select("select id, technical_debt from issues");

    massUpdate.update("update issues set technical_debt=?, updated_at=? where id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long debt = row.getLong(2);
        if (debt != null) {
          Long id = row.getLong(1);
View Full Code Here

  }

  @Override
  public void execute(Context context) throws SQLException {
    final Date now = new Date(system2.now());
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT i.id FROM issues i " +
      "INNER JOIN projects p on p.id=i.component_id " +
      "WHERE p.enabled=? AND i.resolution IS NULL ").setBoolean(1, false);
    massUpdate.update("UPDATE issues SET status=?,resolution=?,updated_at=? WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long id = row.getLong(1);
        update.setString(1, Issue.STATUS_CLOSED);
        update.setString(2, Issue.RESOLUTION_REMOVED);
View Full Code Here

    super(database);
  }

  @Override
  public void execute(Context context) throws SQLException {
    MassUpdate massUpdate = context.prepareMassUpdate();
    massUpdate.select("SELECT project_measures.id,characteristics.rule_id FROM project_measures " +
      "INNER JOIN characteristics ON characteristics.id = project_measures.characteristic_id " +
      "WHERE characteristics.rule_id IS NOT NULL");
    massUpdate.update("UPDATE project_measures SET characteristic_id=null,rule_id=? WHERE id=?");
    massUpdate.execute(new MassUpdate.Handler() {
      @Override
      public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
        Long id = row.getLong(1);
        Long ruleId = row.getLong(2);
View Full Code Here

TOP

Related Classes of org.sonar.server.db.migrations.MassUpdate$Handler

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.