aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-01-20 23:25:47 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-01-21 12:10:18 +0100
commit1414177d9f8a71fdeb524f6720023d36caacc276 (patch)
tree35ca779fcd6066fcb5204a8b4455b8088aa4465d /sonar-core/src/main
parentc1f16f9ea23a6cc5b33f68712b6b675c792ee8cd (diff)
downloadsonarqube-1414177d9f8a71fdeb524f6720023d36caacc276.tar.gz
sonarqube-1414177d9f8a71fdeb524f6720023d36caacc276.zip
SONAR-5960 SONAR-5906 guess author and assignee of new issues
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java32
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java18
2 files changed, 50 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
index 3e67c040b32..731a4ccd80f 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
@@ -20,6 +20,9 @@
package org.sonar.core.source.db;
+import com.google.common.base.Function;
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.io.IOUtils;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
import org.sonar.core.persistence.DaoComponent;
@@ -28,6 +31,12 @@ import org.sonar.core.persistence.MyBatis;
import javax.annotation.CheckForNull;
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
public class FileSourceDao implements BatchComponent, ServerComponent, DaoComponent {
private final MyBatis mybatis;
@@ -47,6 +56,29 @@ public class FileSourceDao implements BatchComponent, ServerComponent, DaoCompon
}
}
+ public <T> void readDataStream(String fileUuid, Function<Reader, T> function) {
+ DbSession dbSession = mybatis.openSession(false);
+ Connection connection = dbSession.getConnection();
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ Reader reader = null;
+ try {
+ pstmt = connection.prepareStatement("select data from file_sources where file_uuid = ?");
+ pstmt.setString(1, fileUuid);
+ rs = pstmt.executeQuery();
+ if (rs.next()) {
+ reader = rs.getCharacterStream(1);
+ function.apply(reader);
+ }
+ } catch (SQLException e) {
+ throw new IllegalStateException("Fail to read FILE_SOURCES.DATA of file " + fileUuid, e);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ DbUtils.closeQuietly(connection, pstmt, rs);
+ MyBatis.closeQuietly(dbSession);
+ }
+ }
+
public void insert(FileSourceDto dto) {
DbSession session = mybatis.openSession(false);
try {
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
index ac965c3170b..bc5d3eacab7 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
@@ -23,6 +23,24 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
public class FileSourceDto {
+
+ public static final int CSV_INDEX_SCM_REVISION = 0;
+ public static final int CSV_INDEX_SCM_AUTHOR = 1;
+ public static final int CSV_INDEX_SCM_DATE = 2;
+ public static final int CSV_INDEX_UT_LINE_HITS = 3;
+ public static final int CSV_INDEX_UT_CONDITIONS = 4;
+ public static final int CSV_INDEX_UT_COVERED_CONDITIONS = 5;
+ public static final int CSV_INDEX_IT_LINE_HITS = 6;
+ public static final int CSV_INDEX_IT_CONDITIONS = 7;
+ public static final int CSV_INDEX_IT_COVERED_CONDITIONS = 8;
+ public static final int CSV_INDEX_OVERALL_LINE_HITS = 9;
+ public static final int CSV_INDEX_OVERALL_CONDITIONS = 10;
+ public static final int CSV_INDEX_OVERALL_COVERED_CONDITIONS = 11;
+ public static final int CSV_INDEX_HIGHLIGHTING = 12;
+ public static final int CSV_INDEX_SYMBOLS = 13;
+ public static final int CSV_INDEX_DUPLICATIONS = 14;
+ public static final int CSV_INDEX_SOURCE = 15;
+
private Long id;
private String projectUuid;
private String fileUuid;