use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class RenameAction method handle.
@Override
public void handle(Request request, Response response) {
long idToRename = QualityGatesWs.parseId(request, QualityGatesWsParameters.PARAM_ID);
QualityGateDto renamedQualityGate = qualityGates.rename(idToRename, request.mandatoryParam(QualityGatesWsParameters.PARAM_NAME));
JsonWriter writer = response.newJsonWriter();
QualityGatesWs.writeQualityGate(renamedQualityGate, writer).close();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateUpdater method checkQualityGateDoesNotAlreadyExist.
private void checkQualityGateDoesNotAlreadyExist(DbSession dbSession, @Nullable Long qGateId, String name, List<String> errors) {
QualityGateDto existingQgate = dbClient.qualityGateDao().selectByName(dbSession, name);
boolean isModifyingCurrentQgate = qGateId != null && existingQgate != null && existingQgate.getId().equals(qGateId);
if (!isModifyingCurrentQgate && existingQgate != null) {
errors.add(format(Validation.IS_ALREADY_USED_MESSAGE, "Name"));
}
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateUpdater method create.
public QualityGateDto create(DbSession dbSession, String name) {
validateQualityGate(dbSession, null, name);
QualityGateDto newQualityGate = new QualityGateDto().setName(name);
dbClient.qualityGateDao().insert(dbSession, newQualityGate);
return newQualityGate;
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGates method delete.
public void delete(long idToDelete) {
checkIsSystemAdministrator();
QualityGateDto qGate = getNonNullQgate(idToDelete);
try (DbSession session = dbClient.openSession(false)) {
if (isDefault(qGate)) {
propertiesDao.deleteGlobalProperty(SONAR_QUALITYGATE_PROPERTY, session);
}
propertiesDao.deleteProjectProperties(SONAR_QUALITYGATE_PROPERTY, Long.toString(idToDelete), session);
dao.delete(qGate, session);
session.commit();
}
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGates method checkQgateNotAlreadyExists.
private void checkQgateNotAlreadyExists(DbSession dbSession, @Nullable Long updatingQgateId, String name, List<String> errors) {
QualityGateDto existingQgate = dao.selectByName(dbSession, name);
boolean isModifyingCurrentQgate = updatingQgateId != null && existingQgate != null && existingQgate.getId().equals(updatingQgateId);
if (!isModifyingCurrentQgate && existingQgate != null) {
errors.add(format(Validation.IS_ALREADY_USED_MESSAGE, "Name"));
}
}
Aggregations