Search in sources :

Example 1 with QualityGateDto

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();
}
Also used : JsonWriter(org.sonar.api.utils.text.JsonWriter) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 2 with QualityGateDto

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"));
    }
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 3 with QualityGateDto

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;
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 4 with QualityGateDto

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();
    }
}
Also used : DbSession(org.sonar.db.DbSession) QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Example 5 with QualityGateDto

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"));
    }
}
Also used : QualityGateDto(org.sonar.db.qualitygate.QualityGateDto)

Aggregations

QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)51 Test (org.junit.Test)33 ComponentDto (org.sonar.db.component.ComponentDto)12 DbSession (org.sonar.db.DbSession)6 PropertyDto (org.sonar.db.property.PropertyDto)6 GetByProjectWsResponse (org.sonarqube.ws.WsQualityGates.GetByProjectWsResponse)6 QualityGateConditionDto (org.sonar.db.qualitygate.QualityGateConditionDto)5 JsonWriter (org.sonar.api.utils.text.JsonWriter)4 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 WsQualityGates (org.sonarqube.ws.WsQualityGates)2 CreateWsResponse (org.sonarqube.ws.WsQualityGates.CreateWsResponse)2 Matchers.anyString (org.mockito.Matchers.anyString)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 MetricDto (org.sonar.db.metric.MetricDto)1 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)1 UserDto (org.sonar.db.user.UserDto)1