use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class QProfileProjectOperations method removeProject.
public void removeProject(DbSession dbSession, String profileKey, ComponentDto project) {
checkAdminOnProject(project);
QualityProfileDto qualityProfile = selectProfileByKey(dbSession, profileKey);
db.qualityProfileDao().deleteProjectProfileAssociation(project.uuid(), qualityProfile.getKey(), dbSession);
dbSession.commit();
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class QProfileProjectOperations method addProject.
public void addProject(DbSession dbSession, String profileKey, ComponentDto project) {
checkAdminOnProject(project);
QualityProfileDto qualityProfile = selectProfileByKey(dbSession, profileKey);
QualityProfileDto currentProfile = db.qualityProfileDao().selectByProjectAndLanguage(dbSession, project.key(), qualityProfile.getLanguage());
boolean updated = false;
if (currentProfile == null) {
db.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), qualityProfile.getKey(), dbSession);
updated = true;
} else if (!profileKey.equals(currentProfile.getKey())) {
db.qualityProfileDao().updateProjectProfileAssociation(project.uuid(), profileKey, currentProfile.getKey(), dbSession);
updated = true;
}
if (updated) {
dbSession.commit();
}
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ActiveRuleCompleter method buildQProfiles.
private Rules.QProfiles.Builder buildQProfiles(DbSession dbSession, Collection<String> harvestedProfileKeys) {
Map<String, QualityProfileDto> qProfilesByKey = Maps.newHashMap();
for (String qProfileKey : harvestedProfileKeys) {
if (!qProfilesByKey.containsKey(qProfileKey)) {
QualityProfileDto profile = loadProfile(dbSession, qProfileKey);
if (profile == null) {
LOG.warn("Could not find quality profile with key " + qProfileKey);
continue;
}
qProfilesByKey.put(qProfileKey, profile);
String parentKee = profile.getParentKee();
if (parentKee != null && !qProfilesByKey.containsKey(parentKee)) {
qProfilesByKey.put(parentKee, loadProfile(dbSession, parentKee));
}
}
}
Rules.QProfiles.Builder qProfilesResponse = Rules.QProfiles.newBuilder();
Map<String, Rules.QProfile> qProfilesMapResponse = qProfilesResponse.getMutableQProfiles();
for (QualityProfileDto profile : qProfilesByKey.values()) {
writeProfile(qProfilesMapResponse, profile);
}
return qProfilesResponse;
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ChangelogAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
QualityProfileDto profile = profileFactory.find(dbSession, QProfileRef.from(request));
QProfileChangeQuery query = new QProfileChangeQuery(profile.getKey());
Date since = parseStartingDateOrDateTime(request.param(PARAM_SINCE));
if (since != null) {
query.setFromIncluded(since.getTime());
}
Date to = parseEndingDateOrDateTime(request.param(PARAM_TO));
if (to != null) {
query.setToExcluded(to.getTime());
}
int page = request.mandatoryParamAsInt(Param.PAGE);
int pageSize = request.mandatoryParamAsInt(Param.PAGE_SIZE);
query.setPage(page, pageSize);
ChangelogLoader.Changelog changelog = changelogLoader.load(dbSession, query);
writeResponse(response.newJsonWriter(), page, pageSize, changelog);
}
}
use of org.sonar.db.qualityprofile.QualityProfileDto 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();
}
}
Aggregations