aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-18 16:59:01 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-18 17:03:03 +0200
commit6a76aaf0dfda27d898a6577e8def32e205399a2a (patch)
tree399f8961897dc1c1d68bfada30c2675cde925d53 /sonar-batch
parent839e1016b530ad3b817531528582d1da5ac49d2b (diff)
downloadsonarqube-6a76aaf0dfda27d898a6577e8def32e205399a2a.tar.gz
sonarqube-6a76aaf0dfda27d898a6577e8def32e205399a2a.zip
SONAR-5417 Metric ID is still needed
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/measure/DeprecatedMetricFinder.java6
3 files changed, 9 insertions, 4 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java
index 8aa68596d07..fcd22b383ef 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/AnalyzerMediumTester.java
@@ -230,6 +230,8 @@ public class AnalyzerMediumTester {
private static class FakeProjectReferentialsLoader implements ProjectReferentialsLoader {
+ private int metricId = 1;
+
private ProjectReferentials ref = new ProjectReferentials();
@Override
@@ -243,7 +245,8 @@ public class AnalyzerMediumTester {
}
public FakeProjectReferentialsLoader add(Metric metric) {
- ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metric.key(), metric.getType().name()));
+ ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metricId, metric.key(), metric.getType().name()));
+ metricId++;
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
index d4f15f1fa3f..31fe1ff4ced 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
@@ -71,7 +71,7 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) {
ProjectReferentials ref = new ProjectReferentials();
for (Metric m : sessionFactory.getSession().getResults(Metric.class, ENABLED, true)) {
- ref.metrics().add(new org.sonar.batch.protocol.input.Metric(m.getKey(), m.getType().name()));
+ ref.metrics().add(new org.sonar.batch.protocol.input.Metric(m.getId(), m.getKey(), m.getType().name()));
}
String defaultName = settings.getString(ModuleQProfiles.SONAR_PROFILE_PROP);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/DeprecatedMetricFinder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/DeprecatedMetricFinder.java
index c2a8a7e6399..00d8403a473 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/DeprecatedMetricFinder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/DeprecatedMetricFinder.java
@@ -33,16 +33,18 @@ import java.util.Map;
public final class DeprecatedMetricFinder implements MetricFinder {
private Map<String, Metric> metricsByKey = Maps.newLinkedHashMap();
+ private Map<Integer, Metric> metricsById = Maps.newLinkedHashMap();
public DeprecatedMetricFinder(ProjectReferentials projectReferentials) {
for (org.sonar.batch.protocol.input.Metric metric : projectReferentials.metrics()) {
- metricsByKey.put(metric.key(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), ValueType.valueOf(metric.valueType())).create());
+ metricsByKey.put(metric.key(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), ValueType.valueOf(metric.valueType())).create().setId(metric.id()));
+ metricsById.put(metric.id(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), ValueType.valueOf(metric.valueType())).create().setId(metric.id()));
}
}
@Override
public Metric findById(int metricId) {
- throw new UnsupportedOperationException("Metric id is not available on batch side");
+ return metricsById.get(metricId);
}
@Override