Package org.sonar.core.persistence.migration.v44

Examples of org.sonar.core.persistence.migration.v44.ChangeLog


  private void executeUpsert(DbSession session, ActiveRuleChange.Type type, List<ChangeLog> changes) {

    Iterator<ChangeLog> changeLogIterator = changes.iterator();
    if (changeLogIterator.hasNext()) {
      // startCase
      ChangeLog change = changeLogIterator.next();
      int currentId = change.getId();
      Date currentTimeStamp = change.getCreatedAt();
      String currentAuthor = change.getUserLogin();
      ActiveRuleChange ruleChange = newActiveRuleChance(type, change);
      processRuleChange(ruleChange, change);

      while (changeLogIterator.hasNext()) {
        change = changeLogIterator.next();
        int id = change.getId();
        if (id != currentId) {
          saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
          currentId = id;
          currentTimeStamp = change.getCreatedAt();
          currentAuthor = change.getUserLogin();
          ruleChange = newActiveRuleChance(type, change);
        }
        processRuleChange(ruleChange, change);
      }
      // save the last
View Full Code Here


  @Override
  public void execute() {
    DbSession session = db.openSession(false);
    try {
      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
      for (Long measureId : mapper.selectMeasuresOnDeletedQualityProfiles()) {
        mapper.deleteProfileMeasure(measureId);
      }
      session.commit();

    } finally {
      session.close();
View Full Code Here

  }

  @Override
  public void execute() {
    DbSession session = db.openSession(false);
    Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
    try {
      executeUpsert(session, ActiveRuleChange.Type.ACTIVATED, migrationMapper.selectActiveRuleChange(true));
      executeUpsert(session, ActiveRuleChange.Type.UPDATED, migrationMapper.selectActiveRuleChange(null));
      executeUpsert(session, ActiveRuleChange.Type.DEACTIVATED, migrationMapper.selectActiveRuleChange(false));
      session.commit();
    } finally {
      session.close();
    }
  }
View Full Code Here

  public void execute() {
    DbSession session = db.openSession(false);
    try {
      int i = 0;
      Date now = new Date();
      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
      for (ProfileMeasure profileMeasure : mapper.selectProfileMeasures()) {
        boolean updated = false;
        Integer version = mapper.selectProfileVersion(profileMeasure.getSnapshotId());
        QProfileDto44 profile = mapper.selectProfileById(profileMeasure.getProfileId());
        if (profile != null) {
          Date date = now;
          if (version != null) {
            date = (Date)ObjectUtils.defaultIfNull(
              mapper.selectProfileVersionDate(profileMeasure.getProfileId(), version), now);
          }
          // see format of JSON in org.sonar.batch.rule.UsedQProfiles
          StringWriter writer = new StringWriter();
          JsonWriter json = JsonWriter.of(writer);
          json
            .beginArray()
            .beginObject()
            .prop("key", profile.getKee())
            .prop("language", profile.getLanguage())
            .prop("name", profile.getName())
            .prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(date))
            .endObject()
            .endArray()
            .close();
          mapper.updateProfileMeasure(profileMeasure.getId(), writer.toString());
          updated = true;
        }
        if (!updated) {
          mapper.deleteProfileMeasure(profileMeasure.getId());
        }
        if (i % 100 == 0) {
          session.commit();
          i++;
        }
View Full Code Here

    DbSession session = db.openSession(false);
    try {
      Date now = new Date(system.now());
      int i = 0;
      QualityProfileMapper profileMapper = session.getMapper(QualityProfileMapper.class);
      Migration44Mapper migrationMapper = session.getMapper(Migration44Mapper.class);
      for (QualityProfileDto profile : profileMapper.selectAll()) {
        Date createdAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileCreatedAt(profile.getId()), now);
        Date updatedAt = (Date) ObjectUtils.defaultIfNull(migrationMapper.selectProfileUpdatedAt(profile.getId()), now);

        migrationMapper.updateProfileDates(profile.getId(), createdAt, updatedAt, UtcDateUtils.formatDateTime(updatedAt));
        if (i % 100 == 0) {
          session.commit();
          i++;
        }
      }
View Full Code Here

      Date now = new Date();
      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
      for (ProfileMeasure profileMeasure : mapper.selectProfileMeasures()) {
        boolean updated = false;
        Integer version = mapper.selectProfileVersion(profileMeasure.getSnapshotId());
        QProfileDto44 profile = mapper.selectProfileById(profileMeasure.getProfileId());
        if (profile != null) {
          Date date = now;
          if (version != null) {
            date = (Date)ObjectUtils.defaultIfNull(
              mapper.selectProfileVersionDate(profileMeasure.getProfileId(), version), now);
          }
          // see format of JSON in org.sonar.batch.rule.UsedQProfiles
          StringWriter writer = new StringWriter();
          JsonWriter json = JsonWriter.of(writer);
          json
            .beginArray()
            .beginObject()
            .prop("key", profile.getKee())
            .prop("language", profile.getLanguage())
            .prop("name", profile.getName())
            .prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(date))
            .endObject()
            .endArray()
            .close();
          mapper.updateProfileMeasure(profileMeasure.getId(), writer.toString());
View Full Code Here

TOP

Related Classes of org.sonar.core.persistence.migration.v44.ChangeLog

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.