]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5911 add analysis date to issues change log
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 6 Jan 2015 11:38:35 +0000 (12:38 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 6 Jan 2015 11:38:50 +0000 (12:38 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java
server/sonar-server/src/main/java/org/sonar/server/computation/ComputeEngineContext.java

index 658b2b520cd31d2bf902f5077c3f34f93c910ca5..ab4f4a874151d501edfc6c3c9d9b422bf6b5dc87 100644 (file)
@@ -46,6 +46,7 @@ import javax.annotation.Nullable;
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 public class AnalysisReportService implements ServerComponent {
@@ -132,6 +133,7 @@ public class AnalysisReportService implements ServerComponent {
     defaultIssue.setLine(issue.line());
     defaultIssue.setEffortToFix(issue.effortToFix());
     setDebt(defaultIssue, issue.debt());
+    setFieldDiffs(defaultIssue, issue.diffFields(), context.getAnalysisDate());
     defaultIssue.setStatus(issue.status());
     defaultIssue.setResolution(issue.resolution());
     defaultIssue.setReporter(issue.reporter());
@@ -143,13 +145,20 @@ public class AnalysisReportService implements ServerComponent {
     defaultIssue.setCreationDate(issue.creationDate());
     defaultIssue.setUpdateDate(issue.updateDate());
     defaultIssue.setCloseDate(issue.closeDate());
-    defaultIssue.setCurrentChange(FieldDiffs.parse(issue.diffFields()));
     defaultIssue.setChanged(issue.isChanged());
     defaultIssue.setNew(issue.isNew());
     defaultIssue.setSelectedAt(issue.selectedAt());
     return defaultIssue;
   }
 
+  private DefaultIssue setFieldDiffs(DefaultIssue issue, String diffFields, Date analysisDate) {
+    FieldDiffs fieldDiffs = FieldDiffs.parse(diffFields);
+    fieldDiffs.setCreationDate(analysisDate);
+    issue.setCurrentChange(fieldDiffs);
+
+    return issue;
+  }
+
   private DefaultIssue setComponentId(DefaultIssue issue, ReportComponent component) {
     if (component != null) {
       issue.setComponentId((long) component.id());
index c62ccf1dbb5af222f3f134bd83ed0dbf7afe3e3c..09aa16566fafaea0043fb54c1bb6d7cb82fd6b7a 100644 (file)
@@ -30,6 +30,7 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 import java.io.File;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -39,6 +40,7 @@ public class ComputeEngineContext {
   private final ComponentDto project;
   private File reportDirectory;
   private Map<Long, ReportComponent> components = new HashMap<>();
+  private Date analysisDate;
 
   public ComputeEngineContext(AnalysisReportDto reportDto, ComponentDto project) {
     this.reportDto = reportDto;
@@ -62,6 +64,7 @@ public class ComputeEngineContext {
   }
 
   public void addResources(ReportComponents reportComponents) {
+    analysisDate = reportComponents.analysisDate();
     addResource(reportComponents.root());
   }
 
@@ -81,4 +84,9 @@ public class ComputeEngineContext {
       addResource(childResource);
     }
   }
+
+  @CheckForNull
+  public Date getAnalysisDate() {
+    return analysisDate;
+  }
 }