Search in sources :

Example 1 with Project

use of org.sonar.server.webhook.Project in project sonarqube by SonarSource.

the class WebhookPostTask method convert.

private static org.sonar.server.webhook.ProjectAnalysis convert(ProjectAnalysis projectAnalysis) {
    CeTask ceTask = new CeTask(projectAnalysis.getCeTask().getId(), CeTask.Status.valueOf(projectAnalysis.getCeTask().getStatus().name()));
    Analysis analysis = projectAnalysis.getAnalysis().map(a -> new Analysis(a.getAnalysisUuid(), a.getDate().getTime(), a.getRevision().orElse(null))).orElse(null);
    Branch branch = projectAnalysis.getBranch().map(b -> new Branch(b.isMain(), b.getName().orElse(null), Branch.Type.valueOf(b.getType().name()))).orElse(null);
    EvaluatedQualityGate qualityGate = Optional.ofNullable(projectAnalysis.getQualityGate()).map(QGToEvaluatedQG.INSTANCE).orElse(null);
    Long date = projectAnalysis.getAnalysis().map(a -> a.getDate().getTime()).orElse(null);
    Map<String, String> properties = projectAnalysis.getScannerContext().getProperties();
    Project project = new Project(projectAnalysis.getProject().getUuid(), projectAnalysis.getProject().getKey(), projectAnalysis.getProject().getName());
    return new org.sonar.server.webhook.ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, date, properties);
}
Also used : CeTask(org.sonar.server.webhook.CeTask) QGToEvaluatedQG(org.sonar.ce.task.projectanalysis.api.posttask.QGToEvaluatedQG) EvaluatedQualityGate(org.sonar.server.qualitygate.EvaluatedQualityGate) Analysis(org.sonar.server.webhook.Analysis) Supplier(java.util.function.Supplier) Branch(org.sonar.server.webhook.Branch) Project(org.sonar.server.webhook.Project) WebHooks(org.sonar.server.webhook.WebHooks) Map(java.util.Map) Optional(java.util.Optional) WebhookPayloadFactory(org.sonar.server.webhook.WebhookPayloadFactory) WebhookPayload(org.sonar.server.webhook.WebhookPayload) PostProjectAnalysisTask(org.sonar.api.ce.posttask.PostProjectAnalysisTask) Project(org.sonar.server.webhook.Project) Analysis(org.sonar.server.webhook.Analysis) Branch(org.sonar.server.webhook.Branch) CeTask(org.sonar.server.webhook.CeTask) EvaluatedQualityGate(org.sonar.server.qualitygate.EvaluatedQualityGate)

Aggregations

Map (java.util.Map)1 Optional (java.util.Optional)1 Supplier (java.util.function.Supplier)1 PostProjectAnalysisTask (org.sonar.api.ce.posttask.PostProjectAnalysisTask)1 QGToEvaluatedQG (org.sonar.ce.task.projectanalysis.api.posttask.QGToEvaluatedQG)1 EvaluatedQualityGate (org.sonar.server.qualitygate.EvaluatedQualityGate)1 Analysis (org.sonar.server.webhook.Analysis)1 Branch (org.sonar.server.webhook.Branch)1 CeTask (org.sonar.server.webhook.CeTask)1 Project (org.sonar.server.webhook.Project)1 WebHooks (org.sonar.server.webhook.WebHooks)1 WebhookPayload (org.sonar.server.webhook.WebhookPayload)1 WebhookPayloadFactory (org.sonar.server.webhook.WebhookPayloadFactory)1