Search in sources :

Example 1 with WebhookDao

use of org.sonar.db.webhook.WebhookDao in project sonarqube by SonarSource.

the class WebHooksImpl method readWebHooksFrom.

private Stream<WebhookDto> readWebHooksFrom(String projectUuid, @CheckForNull PostProjectAnalysisTask.LogStatistics taskLogStatistics) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<ProjectDto> optionalProjectDto = dbClient.projectDao().selectByUuid(dbSession, projectUuid);
        ProjectDto projectDto = checkStateWithOptional(optionalProjectDto, "the requested project '%s' was not found", projectUuid);
        WebhookDao dao = dbClient.webhookDao();
        List<WebhookDto> projectWebhooks = dao.selectByProject(dbSession, projectDto);
        List<WebhookDto> globalWebhooks = dao.selectGlobalWebhooks(dbSession);
        if (taskLogStatistics != null) {
            taskLogStatistics.add("globalWebhooks", globalWebhooks.size());
            taskLogStatistics.add("projectWebhooks", projectWebhooks.size());
        }
        return Stream.concat(projectWebhooks.stream(), globalWebhooks.stream());
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) WebhookDto(org.sonar.db.webhook.WebhookDto) DbSession(org.sonar.db.DbSession) WebhookDao(org.sonar.db.webhook.WebhookDao)

Aggregations

DbSession (org.sonar.db.DbSession)1 ProjectDto (org.sonar.db.project.ProjectDto)1 WebhookDao (org.sonar.db.webhook.WebhookDao)1 WebhookDto (org.sonar.db.webhook.WebhookDto)1