Search in sources :

Example 76 with QualityProfileDto

use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.

the class QProfileFactory method findByKey.

private QualityProfileDto findByKey(DbSession dbSession, String profileKey) {
    QualityProfileDto profile;
    profile = db.qualityProfileDao().selectByKey(dbSession, profileKey);
    return checkFound(profile, "Unable to find a profile for with key '%s'", profileKey);
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 77 with QualityProfileDto

use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.

the class QProfileFactory method setDefault.

void setDefault(DbSession dbSession, String profileKey) {
    checkRequest(StringUtils.isNotBlank(profileKey), "Profile key must be set");
    QualityProfileDto profile = db.qualityProfileDao().selectByKey(dbSession, profileKey);
    if (profile == null) {
        throw new NotFoundException("Quality profile not found: " + profileKey);
    }
    setDefault(dbSession, profile);
    dbSession.commit();
}
Also used : NotFoundException(org.sonar.server.exceptions.NotFoundException) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 78 with QualityProfileDto

use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.

the class QProfileLookup method incrementAncestors.

private void incrementAncestors(QProfile profile, List<QProfile> ancestors, DbSession session) {
    if (profile.parent() != null) {
        QualityProfileDto parentDto = db.qualityProfileDao().selectParentById(session, profile.id());
        if (parentDto == null) {
            throw new IllegalStateException("Cannot find parent of profile : " + profile.id());
        }
        QProfile parent = QProfile.from(parentDto);
        ancestors.add(parent);
        incrementAncestors(parent, ancestors, session);
    }
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 79 with QualityProfileDto

use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.

the class AppAction method addProfiles.

private void addProfiles(JsonWriter json, DbSession dbSession) {
    json.name("qualityprofiles").beginArray();
    for (QualityProfileDto profile : dbClient.qualityProfileDao().selectAll(dbSession)) {
        if (languageIsSupported(profile)) {
            json.beginObject().prop("key", profile.getKey()).prop("name", profile.getName()).prop("lang", profile.getLanguage()).prop("parentKey", profile.getParentKee()).endObject();
        }
    }
    json.endArray();
}
Also used : QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Example 80 with QualityProfileDto

use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.

the class CopyAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    qProfileWsSupport.checkQProfileAdminPermission();
    String newName = request.mandatoryParam(PARAM_PROFILE_NAME);
    String profileKey = request.mandatoryParam(PARAM_PROFILE_KEY);
    QualityProfileDto copiedProfile = profileCopier.copyToName(profileKey, newName);
    String languageKey = copiedProfile.getLanguage();
    Language language = languages.get(copiedProfile.getLanguage());
    String parentKey = copiedProfile.getParentKee();
    response.newJsonWriter().beginObject().prop("key", copiedProfile.getKey()).prop("name", copiedProfile.getName()).prop("language", languageKey).prop("languageName", language == null ? null : language.getName()).prop("isDefault", copiedProfile.isDefault()).prop("isInherited", parentKey != null).prop("parentKey", parentKey).endObject().close();
}
Also used : Language(org.sonar.api.resources.Language) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Aggregations

QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)126 Test (org.junit.Test)76 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)37 RuleDto (org.sonar.db.rule.RuleDto)29 WsTester (org.sonar.server.ws.WsTester)21 RuleQuery (org.sonar.server.rule.index.RuleQuery)14 QualityProfileDao (org.sonar.db.qualityprofile.QualityProfileDao)13 ActiveRuleDao (org.sonar.db.qualityprofile.ActiveRuleDao)12 DbSession (org.sonar.db.DbSession)11 ActiveRuleParamDto (org.sonar.db.qualityprofile.ActiveRuleParamDto)9 SearchOptions (org.sonar.server.es.SearchOptions)9 ComponentDto (org.sonar.db.component.ComponentDto)8 OrganizationDto (org.sonar.db.organization.OrganizationDto)7 ActiveRuleKey (org.sonar.db.qualityprofile.ActiveRuleKey)6 Date (java.util.Date)5 QualityProfileTesting.newQualityProfileDto (org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto)5 RuleParamDto (org.sonar.db.rule.RuleParamDto)5 RulesProfile (org.sonar.api.profiles.RulesProfile)4 Language (org.sonar.api.resources.Language)4 RuleKey (org.sonar.api.rule.RuleKey)4