aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-01-04 12:51:27 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2011-01-04 12:51:27 +0000
commit55eda8f84f3a524fcabc8418c2573af464b15015 (patch)
tree28bafc018b2d7ec0c479b622ee8a71e407cf4a43 /sonar-batch
parent4856fc0de5e25f655fb6ff91be1a798882dd029b (diff)
downloadsonarqube-55eda8f84f3a524fcabc8418c2573af464b15015.tar.gz
sonarqube-55eda8f84f3a524fcabc8418c2573af464b15015.zip
exclude library snapshots from timemachine services
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDays.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByVersion.java4
5 files changed, 16 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
index 8c22431ce83..a88afd1d37a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
@@ -29,6 +29,7 @@ import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
+import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.DefaultIndex;
@@ -88,9 +89,10 @@ public class DefaultTimeMachine implements TimeMachine {
} else {
sb.append("SELECT s.createdAt, m.metricId, m.value ");
}
- sb.append(" FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s WHERE m.snapshotId=s.id AND s.resourceId=:resourceId AND s.status=:status AND m.characteristic IS NULL ");
+ sb.append(" FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s WHERE m.snapshotId=s.id AND s.resourceId=:resourceId AND s.status=:status AND m.characteristic IS NULL AND s.qualifier<>:lib");
params.put("resourceId", resource.getId());
params.put("status", Snapshot.STATUS_PROCESSED);
+ params.put("lib", Project.QUALIFIER_LIB);
sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL ");
if (!metricIds.isEmpty()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java
index 75ef31b9084..f627cfdcd42 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDate.java
@@ -22,6 +22,7 @@ package org.sonar.batch.components;
import org.sonar.api.BatchExtension;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Project;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -38,11 +39,12 @@ public class PastSnapshotFinderByDate implements BatchExtension {
}
PastSnapshot findByDate(Snapshot projectSnapshot, Date date) {
- String hql = "from " + Snapshot.class.getSimpleName() + " where createdAt>=:date AND resourceId=:resourceId AND status=:status order by createdAt asc";
+ String hql = "from " + Snapshot.class.getSimpleName() + " where createdAt>=:date AND resourceId=:resourceId AND status=:status AND qualifier<>:lib order by createdAt asc";
List<Snapshot> snapshots = session.createQuery(hql)
.setParameter("date", date)
.setParameter("resourceId", projectSnapshot.getResourceId())
.setParameter("status", Snapshot.STATUS_PROCESSED)
+ .setParameter("lib", Project.QUALIFIER_LIB)
.setMaxResults(1)
.getResultList();
if (snapshots.isEmpty()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDays.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDays.java
index 3ab57983339..20cd4bd0a6a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDays.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByDays.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang.time.DateUtils;
import org.sonar.api.BatchExtension;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Project;
import java.util.Date;
import java.util.List;
@@ -39,11 +40,12 @@ public class PastSnapshotFinderByDays implements BatchExtension {
PastSnapshot findFromDays(Snapshot projectSnapshot, int days) {
Date targetDate = DateUtils.addDays(projectSnapshot.getCreatedAt(), -days);
- String hql = "from " + Snapshot.class.getSimpleName() + " where resourceId=:resourceId AND status=:status AND createdAt<:date order by createdAt asc";
+ String hql = "from " + Snapshot.class.getSimpleName() + " where resourceId=:resourceId AND status=:status AND createdAt<:date AND qualifier<>:lib order by createdAt asc";
List<Snapshot> snapshots = session.createQuery(hql)
.setParameter("date", projectSnapshot.getCreatedAt())
.setParameter("resourceId", projectSnapshot.getResourceId())
.setParameter("status", Snapshot.STATUS_PROCESSED)
+ .setParameter("lib", Project.QUALIFIER_LIB)
.getResultList();
if (snapshots.isEmpty()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java
index 55dda549bbc..85acf01d449 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysis.java
@@ -23,6 +23,7 @@ import org.sonar.api.BatchExtension;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Project;
import java.text.SimpleDateFormat;
import java.util.List;
@@ -36,11 +37,13 @@ public class PastSnapshotFinderByPreviousAnalysis implements BatchExtension {
}
PastSnapshot findByPreviousAnalysis(Snapshot projectSnapshot) {
- String hql = "from " + Snapshot.class.getSimpleName() + " where createdAt<:date AND resourceId=:resourceId AND status=:status and last=true order by createdAt desc";
+ String hql = "from " + Snapshot.class.getSimpleName() + " where createdAt<:date AND resourceId=:resourceId AND status=:status and last=:last and qualifier<>:lib order by createdAt desc";
List<Snapshot> snapshots = session.createQuery(hql)
.setParameter("date", projectSnapshot.getCreatedAt())
.setParameter("resourceId", projectSnapshot.getResourceId())
.setParameter("status", Snapshot.STATUS_PROCESSED)
+ .setParameter("last", true)
+ .setParameter("lib", Project.QUALIFIER_LIB)
.setMaxResults(1)
.getResultList();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByVersion.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByVersion.java
index cd360d2b125..34eafc5a2b4 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByVersion.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinderByVersion.java
@@ -22,6 +22,7 @@ package org.sonar.batch.components;
import org.sonar.api.BatchExtension;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Project;
import java.util.List;
@@ -36,11 +37,12 @@ public class PastSnapshotFinderByVersion implements BatchExtension {
}
PastSnapshot findByVersion(Snapshot projectSnapshot, String version) {
- String hql = "from " + Snapshot.class.getSimpleName() + " where version=:version AND resourceId=:resourceId AND status=:status order by createdAt desc";
+ String hql = "from " + Snapshot.class.getSimpleName() + " where version=:version AND resourceId=:resourceId AND status=:status AND qualifier<>:lib order by createdAt desc";
List<Snapshot> snapshots = session.createQuery(hql)
.setParameter("version", version)
.setParameter("resourceId", projectSnapshot.getResourceId())
.setParameter("status", Snapshot.STATUS_PROCESSED)
+ .setParameter("lib", Project.QUALIFIER_LIB)
.setMaxResults(1)
.getResultList();