use of org.sonar.db.qualitygate.QualityGateDto 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.qualitygate.QualityGateDto 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.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class RegisterQualityGates method createBuiltinQualityGate.
private void createBuiltinQualityGate(DbSession dbSession) {
String ratingAValue = Integer.toString(RatingGrid.Rating.A.getIndex());
QualityGateDto builtin = qualityGateUpdater.create(dbSession, BUILTIN_QUALITY_GATE);
qualityGateConditionsUpdater.createCondition(dbSession, builtin.getId(), NEW_SECURITY_RATING_KEY, OPERATOR_GREATER_THAN, null, ratingAValue, LEAK_PERIOD);
qualityGateConditionsUpdater.createCondition(dbSession, builtin.getId(), NEW_RELIABILITY_RATING_KEY, OPERATOR_GREATER_THAN, null, ratingAValue, LEAK_PERIOD);
qualityGateConditionsUpdater.createCondition(dbSession, builtin.getId(), NEW_MAINTAINABILITY_RATING_KEY, OPERATOR_GREATER_THAN, null, ratingAValue, LEAK_PERIOD);
qualityGateConditionsUpdater.createCondition(dbSession, builtin.getId(), NEW_COVERAGE_KEY, OPERATOR_LESS_THAN, null, "80", LEAK_PERIOD);
qualityGates.setDefault(dbSession, builtin.getId());
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class CopyAction method handle.
@Override
public void handle(Request request, Response response) {
QualityGateDto newQualityGate = qualityGates.copy(QualityGatesWs.parseId(request, PARAM_ID), request.mandatoryParam(PARAM_NAME));
JsonWriter writer = response.newJsonWriter();
QualityGatesWs.writeQualityGate(newQualityGate, writer).close();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class GetByProjectAction method buildResponse.
private static GetByProjectWsResponse buildResponse(Optional<QualityGateData> data) {
if (!data.isPresent()) {
return GetByProjectWsResponse.getDefaultInstance();
}
QualityGateDto qualityGate = data.get().getQualityGate();
GetByProjectWsResponse.Builder response = GetByProjectWsResponse.newBuilder();
response.getQualityGateBuilder().setId(String.valueOf(qualityGate.getId())).setName(qualityGate.getName()).setDefault(data.get().isDefault());
return response.build();
}
Aggregations