use of org.sonar.db.DbSession in project sonarqube by SonarSource.
the class QualityGates method rename.
public QualityGateDto rename(long idToRename, String name) {
checkIsSystemAdministrator();
try (DbSession dbSession = dbClient.openSession(false)) {
QualityGateDto toRename = getNonNullQgate(idToRename);
validateQualityGate(dbSession, idToRename, name);
toRename.setName(name);
dao.update(toRename, dbSession);
dbSession.commit();
return toRename;
}
}
use of org.sonar.db.DbSession in project sonarqube by SonarSource.
the class QualityGates method listConditions.
public Collection<QualityGateConditionDto> listConditions(long qGateId) {
try (DbSession dbSession = dbClient.openSession(false)) {
Collection<QualityGateConditionDto> conditionsForGate = conditionDao.selectForQualityGate(dbSession, qGateId);
for (QualityGateConditionDto condition : conditionsForGate) {
Metric metric = metricFinder.findById((int) condition.getMetricId());
if (metric == null) {
throw new IllegalStateException("Could not find metric with id " + condition.getMetricId());
}
condition.setMetricKey(metric.getKey());
}
return conditionsForGate;
}
}
use of org.sonar.db.DbSession in project sonarqube by SonarSource.
the class QualityGates method copy.
public QualityGateDto copy(long sourceId, String destinationName) {
checkIsSystemAdministrator();
getNonNullQgate(sourceId);
try (DbSession dbSession = dbClient.openSession(false)) {
validateQualityGate(dbSession, null, destinationName);
QualityGateDto destinationGate = new QualityGateDto().setName(destinationName);
dao.insert(dbSession, destinationGate);
for (QualityGateConditionDto sourceCondition : conditionDao.selectForQualityGate(dbSession, sourceId)) {
conditionDao.insert(new QualityGateConditionDto().setQualityGateId(destinationGate.getId()).setMetricId(sourceCondition.getMetricId()).setOperator(sourceCondition.getOperator()).setWarningThreshold(sourceCondition.getWarningThreshold()).setErrorThreshold(sourceCondition.getErrorThreshold()).setPeriod(sourceCondition.getPeriod()), dbSession);
}
dbSession.commit();
return destinationGate;
}
}
use of org.sonar.db.DbSession in project sonarqube by SonarSource.
the class RegisterQualityGates method start.
@Override
public void start() {
try (DbSession dbSession = dbClient.openSession(false)) {
if (shouldRegisterBuiltinQualityGate(dbSession)) {
createBuiltinQualityGate(dbSession);
registerBuiltinQualityGate(dbSession);
dbSession.commit();
}
}
}
use of org.sonar.db.DbSession in project sonarqube by SonarSource.
the class DeselectAction method handle.
@Override
public void handle(Request request, Response response) {
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto project = getProject(dbSession, request.param(PARAM_PROJECT_ID), request.param(PARAM_PROJECT_KEY));
qualityGates.dissociateProject(dbSession, QualityGatesWs.parseId(request, QualityGatesWsParameters.PARAM_GATE_ID), project);
response.noContent();
}
}
Aggregations