Package org.sonar.core.qualityprofile.db

Examples of org.sonar.core.qualityprofile.db.QualityProfileDto


    this.db = db;
    this.index = index;
  }

  void backup(String key, Writer writer) {
    QualityProfileDto profile;
    DbSession dbSession = db.openSession(false);
    try {
      profile = db.qualityProfileDao().getNonNullByKey(dbSession, key);
    } finally {
      dbSession.close();
    }
    List<ActiveRule> activeRules = index.get(ActiveRuleIndex.class).findByProfile(profile.getKey());
    writeXml(writer, profile, activeRules);
  }
View Full Code Here


  }

  private QProfileName prepareTarget(String fromProfileKey, String toName) {
    DbSession dbSession = db.openSession(false);
    try {
      QualityProfileDto fromProfile = db.qualityProfileDao().getNonNullByKey(dbSession, fromProfileKey);
      QProfileName toProfileName = new QProfileName(fromProfile.getLanguage(), toName);
      verify(fromProfile, toProfileName);
      QualityProfileDto toProfile = db.qualityProfileDao().getByNameAndLanguage(toProfileName.getName(), toProfileName.getLanguage(), dbSession);
      if (toProfile == null) {
        // Do not delegate creation to QProfileBackuper because we need to keep
        // the parent-child association, if exists.
        toProfile = factory.create(dbSession, toProfileName);
        toProfile.setParentKee(fromProfile.getParentKee());
        db.qualityProfileDao().update(dbSession, toProfile);
        dbSession.commit();
      }
      return toProfileName;
View Full Code Here

  @CheckForNull
  @Deprecated
  public ActiveRuleDto getById(DbSession session, int activeRuleId) {
    ActiveRuleDto activeRule = mapper(session).selectById(activeRuleId);
    if (activeRule != null) {
      QualityProfileDto profile = profileDao.getById(activeRule.getProfileId(), session);
      RuleDto rule = ruleDao.getById(session, activeRule.getRuleId());
      if (profile != null && rule != null) {
        activeRule.setKey(ActiveRuleKey.of(profile.getKey(), rule.getKey()));
        return activeRule;
      }
    }
    return null;
  }
View Full Code Here

  }

  void addProject(int profileId, long projectId, UserSession userSession, DbSession session) {
    ComponentDto project = db.componentDao().getById(projectId, session);
    checkPermission(userSession, project.key());
    QualityProfileDto qualityProfile = findNotNull(profileId, session);

    db.propertiesDao().setProperty(new PropertyDto().setKey(
      QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage()).setValue(qualityProfile.getName()).setResourceId(project.getId()), session);
    session.commit();
  }
View Full Code Here

  public void removeProject(int profileId, long projectId, UserSession userSession) {
    DbSession session = db.openSession(false);
    try {
      ComponentDto project = db.componentDao().getById(projectId, session);
      checkPermission(userSession, project.key());
      QualityProfileDto qualityProfile = findNotNull(profileId, session);

      db.propertiesDao().deleteProjectProperty(QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage(), project.getId(), session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  public void removeAllProjects(int profileId, UserSession userSession) {
    checkPermission(userSession);
    DbSession session = db.openSession(false);
    try {
      QualityProfileDto qualityProfile = findNotNull(profileId, session);
      db.propertiesDao().deleteProjectProperties(QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage(), qualityProfile.getName(), session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

      MyBatis.closeQuietly(session);
    }
  }

  private QualityProfileDto findNotNull(int id, DbSession session) {
    QualityProfileDto qualityProfile = db.qualityProfileDao().getById(id, session);
    QProfileValidations.checkProfileIsNotNull(qualityProfile);
    return qualityProfile;
  }
View Full Code Here

  @Test
  public void synchronize_index() throws Exception {

    Date beginning = new Date();

    QualityProfileDto profile1 = QProfileTesting.newXooP1();
    db.qualityProfileDao().insert(dbSession, profile1);

    RuleDto rule1 = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
    db.ruleDao().insert(dbSession, rule1);
View Full Code Here

    assertThat(index.get(ActiveRuleIndex.class).getLastSynchronization()).isNotNull();
  }

  @Test
  public void insert_and_index_active_rule() {
    QualityProfileDto profileDto = QProfileTesting.newXooP1();
    db.qualityProfileDao().insert(dbSession, profileDto);
    RuleKey ruleKey = RuleTesting.XOO_X1;
    RuleDto ruleDto = newRuleDto(ruleKey);
    db.ruleDao().insert(dbSession, ruleDto);
View Full Code Here

  }

  @Test
  public void insert_and_index_active_rule_param() throws InterruptedException {
    // insert and index
    QualityProfileDto profileDto = QProfileTesting.newXooP1();
    db.qualityProfileDao().insert(dbSession, profileDto);
    RuleKey ruleKey = RuleTesting.XOO_X1;
    RuleDto ruleDto = newRuleDto(ruleKey);
    db.ruleDao().insert(dbSession, ruleDto);
View Full Code Here

TOP

Related Classes of org.sonar.core.qualityprofile.db.QualityProfileDto

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.