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);
}
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();
}
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);
}
}
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();
}
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();
}
Aggregations