use of org.sonar.server.qualityprofile.QProfile in project sonarqube by SonarSource.
the class InheritanceAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
DbSession dbSession = dbClient.openSession(false);
try {
QualityProfileDto profile = profileFactory.find(dbSession, QProfileRef.from(request));
List<QProfile> ancestors = profileLookup.ancestors(profile, dbSession);
List<QualityProfileDto> children = dbClient.qualityProfileDao().selectChildren(dbSession, profile.getKey());
Map<String, Multimap<String, FacetValue>> profileStats = profileLoader.getAllProfileStats();
writeResponse(response.newJsonWriter(), profile, ancestors, children, profileStats);
} finally {
dbSession.close();
}
}
use of org.sonar.server.qualityprofile.QProfile in project sonarqube by SonarSource.
the class InheritanceAction method writeAncestors.
private void writeAncestors(JsonWriter json, List<QProfile> ancestors, Map<String, Multimap<String, FacetValue>> profileStats) {
json.name("ancestors").beginArray();
for (QProfile ancestor : ancestors) {
String ancestorKey = ancestor.key();
writeProfileAttributes(json, ancestorKey, ancestor.name(), ancestor.parent(), profileStats);
}
json.endArray();
}
use of org.sonar.server.qualityprofile.QProfile in project sonarqube by SonarSource.
the class SearchAction method buildResponse.
private SearchWsResponse buildResponse(SearchData data) {
List<QProfile> profiles = data.getProfiles();
Map<String, QProfile> profilesByKey = profiles.stream().collect(Collectors.toMap(QProfile::key, identity()));
SearchWsResponse.Builder response = SearchWsResponse.newBuilder();
for (QProfile profile : profiles) {
QualityProfile.Builder profileBuilder = response.addProfilesBuilder();
String profileKey = profile.key();
profileBuilder.setKey(profileKey);
if (profile.name() != null) {
profileBuilder.setName(profile.name());
}
if (profile.getRulesUpdatedAt() != null) {
profileBuilder.setRulesUpdatedAt(profile.getRulesUpdatedAt());
}
if (profile.getLastUsed() != null) {
profileBuilder.setLastUsed(formatDateTime(profile.getLastUsed()));
}
if (profile.getUserUpdatedAt() != null) {
profileBuilder.setUserUpdatedAt(formatDateTime(profile.getUserUpdatedAt()));
}
profileBuilder.setActiveRuleCount(data.getActiveRuleCount(profileKey));
profileBuilder.setActiveDeprecatedRuleCount(data.getActiveDeprecatedRuleCount(profileKey));
if (!profile.isDefault()) {
profileBuilder.setProjectCount(data.getProjectCount(profileKey));
}
writeLanguageFields(profileBuilder, profile);
writeParentFields(profileBuilder, profile, profilesByKey);
profileBuilder.setIsInherited(profile.isInherited());
profileBuilder.setIsDefault(profile.isDefault());
}
return response.build();
}
use of org.sonar.server.qualityprofile.QProfile in project sonarqube by SonarSource.
the class SearchAction method writeParentFields.
private static void writeParentFields(QualityProfile.Builder profileBuilder, QProfile profile, Map<String, QProfile> profilesByKey) {
String parentKey = profile.parent();
if (parentKey == null) {
return;
}
profileBuilder.setParentKey(parentKey);
QProfile parent = profilesByKey.get(parentKey);
if (parent != null && parent.name() != null) {
profileBuilder.setParentName(parent.name());
}
}
Aggregations