aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar/batch/components
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-01-21 14:32:24 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-01-21 14:32:24 +0100
commit08cb4444e0341652a4bf34133485ac405fb1ec50 (patch)
treebfefc7453a2ad73be491cdeaa10c3b1bd45bd060 /sonar-batch/src/main/java/org/sonar/batch/components
parent1ab2475003835b71ff44b3652691c538059db699 (diff)
downloadsonarqube-08cb4444e0341652a4bf34133485ac405fb1ec50.tar.gz
sonarqube-08cb4444e0341652a4bf34133485ac405fb1ec50.zip
SONAR-2127 API: do not automatically create hierarchy of resource tree
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/components')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
index ee3ad649957..eb374de1094 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
@@ -30,6 +30,7 @@ import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.Resource;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -61,8 +62,10 @@ public class PastMeasuresLoader implements BatchExtension {
}
public List<MeasureModel> getPastMeasures(Resource resource, Snapshot projectSnapshot) {
- // assume that the resource has already been saved
- return getPastMeasures(resource.getId(), projectSnapshot);
+ if (isPersisted(resource)) {
+ return getPastMeasures(resource.getId(), projectSnapshot);
+ }
+ return Collections.emptyList();
}
public List<MeasureModel> getPastMeasures(int resourceId, Snapshot projectSnapshot) {
@@ -78,4 +81,8 @@ public class PastMeasuresLoader implements BatchExtension {
.setParameter("status", Snapshot.STATUS_PROCESSED)
.getResultList();
}
+
+ private boolean isPersisted(Resource resource) {
+ return resource.getId()!=null;
+ }
}