aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-02-15 13:50:01 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-02-15 13:50:01 +0100
commit6b67f3c2ac1a2078a2eceba647f328fd47f3f568 (patch)
treede5721e9181f8e7e8d69a8880cb6ffb2447aadf0 /sonar-batch
parent364850c6ee27e86a6a788a6d7bf5c889ca7bf55a (diff)
downloadsonarqube-6b67f3c2ac1a2078a2eceba647f328fd47f3f568.tar.gz
sonarqube-6b67f3c2ac1a2078a2eceba647f328fd47f3f568.zip
SONAR-3208 use PERSON_ID instead of COMMITTER in PROJECT_MEASURES and RULE_FAILURES
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/PastMeasuresLoader.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java8
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml2
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml6
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml4
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml6
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml2
9 files changed, 22 insertions, 20 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 326dfbb9b2d..c96674fd8b5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java
@@ -100,7 +100,7 @@ public class DefaultTimeMachine implements TimeMachine {
params.put("lib", Qualifiers.LIBRARY);
sb.append(" AND m.characteristic IS NULL");
- sb.append(" AND m.committer IS NULL");
+ sb.append(" AND m.personId IS NULL");
sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL");
if (!metricIds.isEmpty()) {
sb.append(" AND m.metricId IN (:metricIds) ");
@@ -162,7 +162,7 @@ public class DefaultTimeMachine implements TimeMachine {
measure.setVariation5(model.getVariationValue5());
measure.setUrl(model.getUrl());
measure.setCharacteristic(model.getCharacteristic());
- measure.setCommitter(model.getCommitter());
+ measure.setPersonId(model.getPersonId());
return measure;
}
}
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 7b2560a3e28..2d2725cae50 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
@@ -65,7 +65,7 @@ public class PastMeasuresLoader implements BatchExtension {
}
public List<Object[]> getPastMeasures(String resourceKey, Snapshot projectPastSnapshot) {
- String sql = "select m.metric_id, m.characteristic_id, m.committer, m.rule_id, m.value from project_measures m, snapshots s" +
+ String sql = "select m.metric_id, m.characteristic_id, m.person_id, m.rule_id, m.value from project_measures m, snapshots s" +
" where m.snapshot_id=s.id and m.metric_id in (:metricIds) " +
" and (s.root_snapshot_id=:rootSnapshotId or s.id=:rootSnapshotId) " +
" and s.status=:status and s.project_id=(select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib)";
@@ -89,8 +89,10 @@ public class PastMeasuresLoader implements BatchExtension {
return number != null ? number.intValue() : null;
}
- public static String getCommitter(Object[] row) {
- return (String) row[2];
+ public static Integer getPersonId(Object[] row) {
+ // can be BigDecimal on Oracle
+ Number number = (Number) row[2];
+ return number != null ? number.intValue() : null;
}
public static Integer getRuleId(Object[] row) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
index 8552118e54c..ddc1df16b7e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
@@ -150,7 +150,7 @@ public final class MeasurePersister {
merge.setVariationValue5(measure.getVariation5());
merge.setUrl(measure.getUrl());
merge.setCharacteristic(measure.getCharacteristic());
- merge.setCommitter(measure.getCommitter());
+ merge.setPersonId(measure.getPersonId());
if (measure.getValue() != null) {
merge.setValue(measure.getValue().doubleValue());
} else {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
index 5c4e9638507..44d004adecd 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
@@ -52,13 +52,13 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
Object[] pastMeasure = measures.get(0);
assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(1));
assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue());
- assertThat(PastMeasuresLoader.getCommitter(pastMeasure), nullValue());
+ assertThat(PastMeasuresLoader.getPersonId(pastMeasure), nullValue());
assertThat(PastMeasuresLoader.getValue(pastMeasure), is(5.0));
pastMeasure = measures.get(1);
assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(2));
assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue());
- assertThat(PastMeasuresLoader.getCommitter(pastMeasure), nullValue());
+ assertThat(PastMeasuresLoader.getPersonId(pastMeasure), nullValue());
assertThat(PastMeasuresLoader.getValue(pastMeasure), is(60.0));
}
@@ -76,13 +76,13 @@ public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
Object[] pastMeasure = measures.get(0);
assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(1));
assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue());
- assertThat(PastMeasuresLoader.getCommitter(pastMeasure), nullValue());
+ assertThat(PastMeasuresLoader.getPersonId(pastMeasure), nullValue());
assertThat(PastMeasuresLoader.getValue(pastMeasure), is(60.0));
pastMeasure = measures.get(1);
assertThat(PastMeasuresLoader.getMetricId(pastMeasure), is(2));
assertThat(PastMeasuresLoader.getCharacteristicId(pastMeasure), nullValue());
- assertThat(PastMeasuresLoader.getCommitter(pastMeasure), nullValue());
+ assertThat(PastMeasuresLoader.getPersonId(pastMeasure), nullValue());
assertThat(PastMeasuresLoader.getValue(pastMeasure), is(80.0));
}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml
index b3e9936d13b..2b8c2b91a70 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shared.xml
@@ -33,7 +33,7 @@
<project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
</dataset>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml
index cca7f553c6a..b6f2c36971e 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldDelaySaving-result.xml
@@ -33,20 +33,20 @@
<project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
<project_measures id="2" VALUE="1234.0" METRIC_ID="1" SNAPSHOT_ID="3001" alert_text="[null]"
RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
<project_measures id="3" VALUE="50.0" METRIC_ID="1" SNAPSHOT_ID="3002" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml
index 65045ce8147..933b0fff827 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldInsertMeasure-result.xml
@@ -33,13 +33,13 @@
<project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
<project_measures id="2" VALUE="1234.0" METRIC_ID="1" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
</dataset>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml
index 087482acc04..edc7e905a03 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldNotDelaySavingWithDatabaseOnlyMeasure-result.xml
@@ -33,20 +33,20 @@
<project_measures id="1" VALUE="60" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
<project_measures id="2" VALUE="1234.0" METRIC_ID="1" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
<!-- delayed -->
<!--<project_measures id="3" VALUE="50.0" METRIC_ID="1" SNAPSHOT_ID="3002" alert_text="[null]" RULES_CATEGORY_ID="[null]"-->
<!--RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
<!--alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"-->
- <!--committer="[null]"-->
+ <!--person_id="[null]"-->
<!--variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>-->
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml
index d36cda4f4a2..4758f158973 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/MeasurePersisterTest/shouldUpdateMeasure-result.xml
@@ -33,7 +33,7 @@
<project_measures id="1" VALUE="12.5" METRIC_ID="2" SNAPSHOT_ID="3001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
- committer="[null]"
+ person_id="[null]"
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
</dataset>