use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class InheritanceAction method writeChildren.
private void writeChildren(JsonWriter json, List<QualityProfileDto> children, Map<String, Multimap<String, FacetValue>> profileStats) {
json.name("children").beginArray();
for (QualityProfileDto child : children) {
String childKey = child.getKey();
writeProfileAttributes(json, childKey, child.getName(), null, profileStats);
}
json.endArray();
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class OldRestoreAction method writeResponse.
private void writeResponse(JsonWriter json, BulkChangeResult result) {
QualityProfileDto profile = result.profile();
if (profile != null) {
String languageKey = profile.getLanguage();
Language language = languages.get(languageKey);
JsonWriter jsonProfile = json.beginObject().name("profile").beginObject();
jsonProfile.prop("key", profile.getKey()).prop("name", profile.getName()).prop("language", languageKey).prop("isDefault", false).prop("isInherited", false);
if (language != null) {
jsonProfile.prop("languageName", language.getName());
}
jsonProfile.endObject();
}
json.prop("ruleSuccesses", result.countSucceeded());
json.prop("ruleFailures", result.countFailed());
json.endObject().close();
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RegisterQualityProfiles method setDefault.
private void setDefault(String language, List<RulesProfile> profileDefs, DbSession session) {
QualityProfileDto currentDefault = dbClient.qualityProfileDao().selectDefaultProfile(session, language);
if (currentDefault == null) {
String defaultProfileName = nameOfDefaultProfile(profileDefs);
LOGGER.info("Set default " + language + " profile: " + defaultProfileName);
QualityProfileDto newDefaultProfile = dbClient.qualityProfileDao().selectByNameAndLanguage(defaultProfileName, language, session);
if (newDefaultProfile == null) {
// Must not happen, we just registered it
throw new IllegalStateException("Could not find declared default profile '%s' for language '%s'");
} else {
dbClient.qualityProfileDao().update(session, newDefaultProfile.setDefault(true));
}
}
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RuleActivator method cascadeDeactivation.
private List<ActiveRuleChange> cascadeDeactivation(ActiveRuleKey key, DbSession dbSession, boolean isCascade, boolean force) {
List<ActiveRuleChange> changes = Lists.newArrayList();
RuleActivatorContext context = contextFactory.create(key.qProfile(), key.ruleKey(), dbSession);
ActiveRuleChange change;
ActiveRuleDto activeRuleDto = context.activeRule();
if (activeRuleDto == null) {
return changes;
}
checkRequest(force || isCascade || activeRuleDto.getInheritance() == null, "Cannot deactivate inherited rule '%s'", key.ruleKey());
change = ActiveRuleChange.createFor(ActiveRuleChange.Type.DEACTIVATED, key);
changes.add(change);
persist(change, context, dbSession);
// get all inherited profiles
List<QualityProfileDto> profiles = db.qualityProfileDao().selectChildren(dbSession, key.qProfile());
for (QualityProfileDto profile : profiles) {
ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), key.ruleKey());
changes.addAll(cascadeDeactivation(activeRuleKey, dbSession, true, force));
}
if (!changes.isEmpty()) {
updateProfileDates(dbSession, context);
}
return changes;
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RestoreAction method writeResponse.
private void writeResponse(JsonWriter json, BulkChangeResult result) {
QualityProfileDto profile = result.profile();
if (profile != null) {
String languageKey = profile.getLanguage();
Language language = languages.get(languageKey);
JsonWriter jsonProfile = json.beginObject().name("profile").beginObject();
jsonProfile.prop("key", profile.getKey()).prop("name", profile.getName()).prop("language", languageKey).prop("isDefault", false).prop("isInherited", false);
if (language != null) {
jsonProfile.prop("languageName", language.getName());
}
jsonProfile.endObject();
}
json.prop("ruleSuccesses", result.countSucceeded());
json.prop("ruleFailures", result.countFailed());
json.endObject().close();
}
Aggregations