aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-03-07 19:43:04 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-03-08 13:57:11 +0400
commitd660da5fd487949dae1954f3ef76a1d310e0e8a8 (patch)
treecba7b34cdb7abb4469f4bd77811f5b7bdffdb7d4 /plugins
parentb74eecaa0a60f30078f68f462226efe14eeb647a (diff)
downloadsonarqube-d660da5fd487949dae1954f3ef76a1d310e0e8a8.tar.gz
sonarqube-d660da5fd487949dae1954f3ef76a1d310e0e8a8.zip
Persist duplications XML measure directly into database
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java6
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java14
2 files changed, 14 insertions, 6 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
index 259993eda33..fc800738a86 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DuplicationsData.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Sets;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.PersistenceMode;
import org.sonar.api.resources.Resource;
import java.util.Collections;
@@ -58,7 +59,10 @@ public class DuplicationsData {
context.saveMeasure(resource, CoreMetrics.DUPLICATED_FILES, 1d);
context.saveMeasure(resource, CoreMetrics.DUPLICATED_LINES, (double) duplicatedLines.size());
context.saveMeasure(resource, CoreMetrics.DUPLICATED_BLOCKS, duplicatedBlocks);
- context.saveMeasure(resource, new Measure(CoreMetrics.DUPLICATIONS_DATA, getDuplicationXMLData()));
+
+ Measure data = new Measure(CoreMetrics.DUPLICATIONS_DATA, getDuplicationXMLData())
+ .setPersistenceMode(PersistenceMode.DATABASE);
+ context.saveMeasure(resource, data);
}
private String getDuplicationXMLData() {
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
index 961b085bf4f..460fdd10fa0 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
@@ -27,6 +27,7 @@ import org.sonar.api.batch.SensorContext;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.PersistenceMode;
import org.sonar.api.resources.*;
import org.sonar.api.utils.SonarException;
import org.sonar.duplications.block.Block;
@@ -79,10 +80,10 @@ public class SonarEngine extends CpdEngine {
static String getFullKey(Project project, Resource resource) {
return new StringBuilder(ResourceModel.KEY_SIZE)
- .append(project.getKey())
- .append(':')
- .append(resource.getKey())
- .toString();
+ .append(project.getKey())
+ .append(':')
+ .append(resource.getKey())
+ .toString();
}
@Override
@@ -195,7 +196,10 @@ public class SonarEngine extends CpdEngine {
context.saveMeasure(resource, CoreMetrics.DUPLICATED_FILES, 1.0);
context.saveMeasure(resource, CoreMetrics.DUPLICATED_LINES, (double) duplicatedLines.size());
context.saveMeasure(resource, CoreMetrics.DUPLICATED_BLOCKS, duplicatedBlocks);
- context.saveMeasure(resource, new Measure(CoreMetrics.DUPLICATIONS_DATA, toXml(duplications)));
+
+ Measure data = new Measure(CoreMetrics.DUPLICATIONS_DATA, toXml(duplications))
+ .setPersistenceMode(PersistenceMode.DATABASE);
+ context.saveMeasure(resource, data);
}
private static String toXml(Iterable<CloneGroup> duplications) {