aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol/src/main/java
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-24 16:18:10 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-25 15:20:10 +0100
commitac44823d701c7ae3ea30ea8060c8fe28ca8ee6af (patch)
treea521202e8caac86d174fbf2675ea129c401ccd74 /sonar-batch-protocol/src/main/java
parentc9ce765d410c8924cb7d11b28e42e85078409622 (diff)
downloadsonarqube-ac44823d701c7ae3ea30ea8060c8fe28ca8ee6af.tar.gz
sonarqube-ac44823d701c7ae3ea30ea8060c8fe28ca8ee6af.zip
SONAR-6257 Persist duplication measures in compute
Diffstat (limited to 'sonar-batch-protocol/src/main/java')
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java10
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java8
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java3
3 files changed, 20 insertions, 1 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
index 819e23a09c1..2ec80f936c3 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
@@ -79,6 +79,16 @@ public class BatchReportReader {
return ProtobufUtil.readFile(file, Issues.PARSER);
}
+ public List<BatchReport.Duplication> readComponentDuplications(int componentRef) {
+ File file = fileStructure.fileFor(FileStructure.Domain.DUPLICATIONS, componentRef);
+ if (file.exists() && file.isFile()) {
+ // all the duplications are loaded in memory
+ BatchReport.Duplications duplications = ProtobufUtil.readFile(file, BatchReport.Duplications.PARSER);
+ return duplications.getDuplicationList();
+ }
+ return Collections.emptyList();
+ }
+
private boolean isNotAnExistingFile(File file) {
return !file.exists() || !file.isFile();
}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
index 7022d1da350..82c9583b52c 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java
@@ -84,4 +84,12 @@ public class BatchReportWriter {
ProtobufUtil.writeToFile(issuesBuilder.build(), file);
}
+ public void writeComponentDuplications(int componentRef, Iterable<BatchReport.Duplication> duplications) {
+ BatchReport.Duplications.Builder builder = BatchReport.Duplications.newBuilder();
+ builder.setComponentRef(componentRef);
+ builder.addAllDuplication(duplications);
+ File file = fileStructure.fileFor(FileStructure.Domain.DUPLICATIONS, componentRef);
+ ProtobufUtil.writeToFile(builder.build(), file);
+ }
+
}
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
index ded4fa227ab..546b85d23bd 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java
@@ -27,7 +27,8 @@ import java.io.File;
public class FileStructure {
public static enum Domain {
- ISSUES("issues-"), ISSUES_ON_DELETED("issues-deleted-"), COMPONENT("component-"), MEASURES("measures-");
+ ISSUES("issues-"), ISSUES_ON_DELETED("issues-deleted-"), COMPONENT("component-"),
+ MEASURES("measures-"), DUPLICATIONS("duplications-");
private final String filePrefix;