Examples of QualityProfileDto


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

    }
  }

  void setDefault(DbSession dbSession, String profileKey) {
    Verifications.check(StringUtils.isNotBlank(profileKey), "Profile key must be set");
    QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, profileKey);
    setDefault(dbSession, profile);
    dbSession.commit();
  }
View Full Code Here

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

  public boolean rename(String key, String newName) {
    Verifications.check(StringUtils.isNotBlank(newName), "Name must be set");
    Verifications.check(newName.length() < 100, String.format("Name is too long (>%d characters)", 100));
    DbSession dbSession = db.openSession(false);
    try {
      QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, key);
      if (!StringUtils.equals(newName, profile.getName())) {
        if (db.qualityProfileDao().getByNameAndLanguage(newName, profile.getLanguage(), dbSession) != null) {
          throw new BadRequestException("Quality profile already exists: " + newName);
        }
        String previousName = profile.getName();
        profile.setName(newName);
        db.qualityProfileDao().update(dbSession, profile);
        db.propertiesDao().updateProperties(PROFILE_PROPERTY_PREFIX + profile.getLanguage(), previousName, newName, dbSession);
        dbSession.commit();
        return true;
      }
      return false;
    } finally {
View Full Code Here

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

  }

  private void register(QProfileName name, Collection<RulesProfile> profiles, DbSession session) {
    LOGGER.info("Register profile " + name);

    QualityProfileDto profileDto = dbClient.qualityProfileDao().getByNameAndLanguage(name.getName(), name.getLanguage(), session);
    if (profileDto != null) {
      profileFactory.delete(session, profileDto.getKey(), true);
    }
    profileFactory.create(session, name);

    for (RulesProfile profile : profiles) {
      for (org.sonar.api.rules.ActiveRule activeRule : profile.getActiveRules()) {
View Full Code Here

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

  public QProfileResult create(QProfileName name, @Nullable Map<String, String> xmlQProfilesByPlugin) {
    verifyAdminPermission();
    DbSession dbSession = db.openSession(false);
    try {
      QProfileResult result = new QProfileResult();
      QualityProfileDto profile = factory.create(dbSession, name);
      result.setProfile(profile);
      if (xmlQProfilesByPlugin != null) {
        for (Map.Entry<String, String> entry : xmlQProfilesByPlugin.entrySet()) {
          result.add(exporters.importXml(profile, entry.getKey(), entry.getValue(), dbSession));
        }
View Full Code Here

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

    this.db = db;
  }

  RuleActivatorContext create(String profileKey, RuleKey ruleKey, DbSession session) {
    RuleActivatorContext context = new RuleActivatorContext();
    QualityProfileDto profile = db.qualityProfileDao().getByKey(session, profileKey);
    if (profile == null) {
      throw new BadRequestException("Quality profile not found: " + profileKey);
    }
    context.setProfile(profile);
    return create(ruleKey, session, context);
View Full Code Here

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

    return create(ruleKey, session, context);
  }

  RuleActivatorContext create(QProfileName profileName, RuleKey ruleKey, DbSession session) {
    RuleActivatorContext context = new RuleActivatorContext();
    QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage(profileName.getName(), profileName.getLanguage(), session);
    if (profile == null) {
      throw new BadRequestException("Quality profile not found: " + profileName);
    }
    context.setProfile(profile);
    return create(ruleKey, session, context);
View Full Code Here

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

  }

  private void addProfiles(ProjectReferentials ref, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
    for (Language language : languages.all()) {
      String languageKey = language.getKey();
      QualityProfileDto qualityProfileDto = getProfile(languageKey, projectKey, profileName, session);
      ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(
        qualityProfileDto.getKey(),
        qualityProfileDto.getName(),
        qualityProfileDto.getLanguage(),
        UtcDateUtils.parseDateTime(qualityProfileDto.getRulesUpdatedAt())));
    }
  }
View Full Code Here

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

   * If still no profile found, try to find the default profile of the language
   *
   * Never return null because a default profile should always be set on ech language
   */
  private QualityProfileDto getProfile(String languageKey, @Nullable String projectKey, @Nullable String profileName, DbSession session) {
    QualityProfileDto qualityProfileDto = profileName != null ? qProfileFactory.getByNameAndLanguage(session, profileName, languageKey) : null;
    if (qualityProfileDto == null && projectKey != null) {
      qualityProfileDto = qProfileFactory.getByProjectAndLanguage(session, projectKey, languageKey);
    }
    qualityProfileDto = qualityProfileDto != null ? qualityProfileDto : qProfileFactory.getDefault(session, languageKey);
    if (qualityProfileDto != null) {
View Full Code Here

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

      dbSession.close();
    }
  }

  void setParent(DbSession dbSession, String profileKey, @Nullable String parentKey) {
    QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, profileKey);
    if (parentKey == null) {
      // unset if parent is defined, else nothing to do
      removeParent(dbSession, profile);

    } else if (profile.getParentKee() == null || !parentKey.equals(profile.getParentKee())) {
      QualityProfileDto parentProfile = db.qualityProfileDao().getNonNullByKey(dbSession, parentKey);
      if (isDescendant(dbSession, profile, parentProfile)) {
        throw new BadRequestException(String.format("Descendant profile '%s' can not be selected as parent of '%s'", parentKey, profileKey));
      }
      removeParent(dbSession, profile);
View Full Code Here

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

      }
    }
  }

  boolean isDescendant(DbSession dbSession, QualityProfileDto childProfile, @Nullable QualityProfileDto parentProfile) {
    QualityProfileDto currentParent = parentProfile;
    while (currentParent != null) {
      if (childProfile.getName().equals(currentParent.getName())) {
        return true;
      }
      String parentKey = currentParent.getParentKee();
      if (parentKey != null) {
        currentParent = db.qualityProfileDao().getByKey(dbSession, parentKey);
      } else {
        currentParent = null;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.