aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-09-17 10:41:56 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-09-30 16:27:12 +0200
commit5af4d8ed1fe0ad9fc75bdf9aaf01410b66c4da5f (patch)
treeff0b296f7ae1cf3817bd6c82d0bce8ed2388f159 /sonar-db/src
parentf728687b5cf55977ce241695097b8e01418988e3 (diff)
downloadsonarqube-5af4d8ed1fe0ad9fc75bdf9aaf01410b66c4da5f.tar.gz
sonarqube-5af4d8ed1fe0ad9fc75bdf9aaf01410b66c4da5f.zip
SONAR-6823 WS batch/project with protobuf and new behaviors
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/FilePathWithHashDto.java10
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java3
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml4
4 files changed, 17 insertions, 4 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/FilePathWithHashDto.java b/sonar-db/src/main/java/org/sonar/db/component/FilePathWithHashDto.java
index 85e3c45ceb6..08f4394c1c5 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/FilePathWithHashDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/FilePathWithHashDto.java
@@ -26,6 +26,7 @@ public class FilePathWithHashDto {
private String moduleUuid;
private String path;
private String srcHash;
+ private String revision;
public String getSrcHash() {
return srcHash;
@@ -51,6 +52,14 @@ public class FilePathWithHashDto {
this.path = path;
}
+ public String getRevision() {
+ return revision;
+ }
+
+ public void setRevision(String revision) {
+ this.revision = revision;
+ }
+
public String getUuid() {
return uuid;
}
@@ -58,4 +67,5 @@ public class FilePathWithHashDto {
public void setUuid(String uuid) {
this.uuid = uuid;
}
+
}
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index bcfcbeac7b4..da674300494 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -191,7 +191,7 @@
</sql>
<select id="selectEnabledFilesFromProject" parameterType="map" resultType="FilePathWithHash">
- SELECT p.uuid, p.path, p.module_uuid as moduleUuid, fs.src_hash as srcHash
+ SELECT p.uuid, p.path, p.module_uuid as moduleUuid, fs.src_hash as srcHash, fs.revision
FROM projects p
INNER JOIN file_sources fs ON fs.file_uuid=p.uuid and fs.data_type='SOURCE'
<where>
@@ -202,7 +202,7 @@
</select>
<select id="selectDescendantFiles" parameterType="map" resultType="FilePathWithHash">
- SELECT p.uuid, p.path, p.module_uuid as moduleUuid, fs.src_hash as srcHash
+ SELECT p.uuid, p.path, p.module_uuid as moduleUuid, fs.src_hash as srcHash, fs.revision
FROM projects p
INNER JOIN file_sources fs ON fs.file_uuid=p.uuid and fs.data_type='SOURCE'
<include refid="modulesTreeQuery"/>
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index 1343b4d0b0d..f7125fd1d34 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -384,6 +384,7 @@ public class ComponentDaoTest {
assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java");
+ assertThat(files).extracting("revision").containsOnly("123456789");
// From module
files = underTest.selectEnabledDescendantFiles(dbSession, "EFGH");
@@ -391,6 +392,7 @@ public class ComponentDaoTest {
assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java");
+ assertThat(files).extracting("revision").containsOnly("123456789");
// From sub module
files = underTest.selectEnabledDescendantFiles(dbSession, "FGHI");
@@ -398,6 +400,7 @@ public class ComponentDaoTest {
assertThat(files).extracting("moduleUuid").containsOnly("FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/RequestContext.java");
+ assertThat(files).extracting("revision").containsOnly("123456789");
// From directory
assertThat(underTest.selectEnabledDescendantFiles(dbSession, "GHIJ")).isEmpty();
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml
index fe7f43ee5a3..703f88968ac 100644
--- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/select_module_files_tree.xml
@@ -23,7 +23,7 @@
binary_data=",,,,,,,,,,,,,,,unchanged&#13;&#10;,,,,,,,,,,,,,,,content&#13;&#10;"
line_hashes="lineEFGHI"
data_hash="dataEFGHI"
- src_hash="srcEFGHI"
+ src_hash="srcEFGHI" revision="123456789"
created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE"/>
<!-- sub module -->
@@ -50,7 +50,7 @@
binary_data=",,,,,,,,,,,,,,,unchanged&#13;&#10;,,,,,,,,,,,,,,,content&#13;&#10;"
line_hashes="lineHIJK"
data_hash="dataHIJK"
- src_hash="srcHIJK"
+ src_hash="srcHIJK" revision="123456789"
created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE"/>
</dataset>