diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-11-25 16:18:04 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-11-25 16:30:58 +0100 |
commit | f1199464b99d54b520a4a3534879bfce8af1d91d (patch) | |
tree | e8733056c6369cd2918977d2880a1bbab35a8c8d /sonar-core | |
parent | 59b40f60adfc5bea1fbe0d41356981a666cebdd7 (diff) | |
download | sonarqube-f1199464b99d54b520a4a3534879bfce8af1d91d.tar.gz sonarqube-f1199464b99d54b520a4a3534879bfce8af1d91d.zip |
SONAR-5868 Add WS to fetch line hashes for issue tracking
Diffstat (limited to 'sonar-core')
5 files changed, 29 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java index c097fd6e167..a6dd902d982 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java @@ -36,6 +36,7 @@ import org.sonar.core.resource.ResourceDao; import org.sonar.core.resource.ResourceIndexerDao; import org.sonar.core.resource.ResourceKeyUpdaterDao; import org.sonar.core.rule.RuleDao; +import org.sonar.core.source.db.FileSourceDao; import org.sonar.core.source.db.SnapshotDataDao; import org.sonar.core.source.db.SnapshotSourceDao; import org.sonar.core.technicaldebt.db.CharacteristicDao; @@ -61,6 +62,7 @@ public final class DaoUtils { AuthorizationDao.class, DashboardDao.class, DuplicationDao.class, + FileSourceDao.class, GraphDao.class, GroupMembershipDao.class, IssueDao.class, 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 63dcf2631d3..c6c6ea16d6a 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 @@ -66,4 +66,8 @@ public class FileSourceDao implements BatchComponent, ServerComponent { } } + @CheckForNull + public String selectLineHashes(String fileUuid, DbSession session) { + return session.getMapper(FileSourceMapper.class).selectLineHashes(fileUuid); + } } diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java index 916d662d212..2fd054897eb 100644 --- a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java @@ -34,4 +34,7 @@ public interface FileSourceMapper { void insert(FileSourceDto dto); void update(FileSourceDto dto); + + @CheckForNull + String selectLineHashes(String fileUuid); } diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml index d7b65c501ea..3e68f7fdb2d 100644 --- a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml @@ -30,5 +30,11 @@ where id = #{id} </update> + <select id="selectLineHashes" parameterType="string" resultType="String"> + SELECT line_hashes + FROM file_sources + WHERE file_uuid = #{fileUuid} + </select> + </mapper> diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java index 0487d80b379..8e4e0274048 100644 --- a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java @@ -24,6 +24,7 @@ import org.junit.Before; import org.junit.Test; import org.sonar.api.utils.DateUtils; import org.sonar.core.persistence.AbstractDaoTestCase; +import org.sonar.core.persistence.DbSession; import java.util.Date; @@ -52,6 +53,19 @@ public class FileSourceDaoTest extends AbstractDaoTestCase { } @Test + public void selectLineHashes() throws Exception { + DbSession session = getMyBatis().openSession(false); + String lineHashes = null; + try { + lineHashes = dao.selectLineHashes("ab12", session); + } finally { + session.close(); + } + + assertThat(lineHashes).isEqualTo("truc"); + } + + @Test public void insert() throws Exception { dao.insert(new FileSourceDto().setProjectUuid("prj").setFileUuid("file").setData("bla bla") .setDataHash("hash2") |