aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-24 17:58:43 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-27 11:30:16 +0100
commit18c50b16adbb95a57c009486261ada999f40efb4 (patch)
tree9185ba705d4b3601e2753f0d071a4296de9406dc /sonar-core/src
parentab4ec0fea3f5bb7ecae9cdb2739b373046515b59 (diff)
downloadsonarqube-18c50b16adbb95a57c009486261ada999f40efb4.tar.gz
sonarqube-18c50b16adbb95a57c009486261ada999f40efb4.zip
SONAR-5755 Manage Views and Devs
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java20
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml23
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java13
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/fixture.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/shouldInsertAuthorAndDeveloper-result.xml2
7 files changed, 44 insertions, 23 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java
index a00232e92ce..398b415d87c 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java
@@ -42,8 +42,7 @@ public interface Migration50Mapper {
" LEFT OUTER JOIN snapshots s ON s.project_id = p.id AND s.islast = ${_true} " +
" WHERE " +
" p.scope = 'PRJ' " +
- " AND p.root_id IS NULL " +
- " AND p.qualifier <> 'VW' AND p.qualifier <> 'DEV' ")
+ " AND p.root_id IS NULL ")
@Result(javaType = Component.class)
@Options(statementType = StatementType.PREPARED, resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 200)
List<Component> selectRootProjects();
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java
index ba2f08e6011..3e8f8ada5e9 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java
@@ -26,6 +26,8 @@ public class ResourceDto {
private Long id;
private String uuid;
private String projectUuid;
+ private String moduleUuid;
+ private String moduleUuidPath;
private String key;
private String deprecatedKey;
private String name;
@@ -69,6 +71,24 @@ public class ResourceDto {
return this;
}
+ public String getModuleUuid() {
+ return moduleUuid;
+ }
+
+ public ResourceDto setModuleUuid(String moduleUuid) {
+ this.moduleUuid = moduleUuid;
+ return this;
+ }
+
+ public String getModuleUuidPath() {
+ return moduleUuidPath;
+ }
+
+ public ResourceDto setModuleUuidPath(String moduleUuidPath) {
+ this.moduleUuidPath = moduleUuidPath;
+ return this;
+ }
+
public String getName() {
return name;
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml
index 7cc35c05c33..337750718da 100644
--- a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml
@@ -3,25 +3,6 @@
<mapper namespace="org.sonar.core.resource.ResourceMapper">
- <sql id="resourceColumns">
- p.id,
- p.kee as key,
- p.path as path,
- p.deprecated_kee as deprecatedKey,
- p.name as name,
- p.long_name as longName,
- p.root_id as rootId,
- p.scope as scope,
- p.qualifier as qualifier,
- p.enabled as enabled,
- p.description as description,
- p.language as language,
- p.copy_resource_id as copyResourceId,
- p.person_id as personId,
- p.created_at as createdAt,
- p.authorization_updated_at as authorizationUpdatedAt
- </sql>
-
<resultMap id="snapshotResultMap" type="Snapshot">
<id property="id" column="id"/>
<result property="parentId" column="parent_snapshot_id"/>
@@ -58,6 +39,10 @@
<resultMap id="resourceResultMap" type="Resource">
<id property="id" column="id"/>
<result property="key" column="kee"/>
+ <result property="uuid" column="uuid"/>
+ <result property="projectUuid" column="project_uuid"/>
+ <result property="moduleUuid" column="module_uuid"/>
+ <result property="moduleUuidPath" column="module_uuid_path"/>
<result property="deprecatedKey" column="deprecated_kee"/>
<result property="path" column="path"/>
<result property="name" column="name"/>
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
index 3edb189acba..03e50c465e6 100644
--- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
@@ -89,6 +89,8 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
ResourceDto resource = dao.getResource(1L);
+ assertThat(resource.getUuid()).isEqualTo("ABCD");
+ assertThat(resource.getProjectUuid()).isEqualTo("ABCD");
assertThat(resource.getPath()).isNull();
assertThat(resource.getName()).isEqualTo("Struts");
assertThat(resource.getLongName()).isEqualTo("Apache Struts");
@@ -112,6 +114,17 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
}
@Test
+ public void get_uuid() {
+ setupData("fixture");
+
+ ResourceDto file = dao.getResource(4L);
+ assertThat(file.getUuid()).isEqualTo("CDEF");
+ assertThat(file.getProjectUuid()).isEqualTo("ABCD");
+ assertThat(file.getModuleUuid()).isEqualTo("BCDE");
+ assertThat(file.getModuleUuidPath()).isEqualTo("ABCD.BCDE");
+ }
+
+ @Test
public void getResource_not_found() {
setupData("fixture");
diff --git a/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java
index 3e6dfcb9437..2bb589fbfc9 100644
--- a/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java
@@ -72,7 +72,7 @@ public class AuthorDaoTest extends AbstractDaoTestCase {
setupData("shouldInsertAuthorAndDeveloper");
String login = "developer@company.net";
- ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV");
+ ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD");
dao.insertAuthorAndDeveloper(login, resourceDto);
checkTables("shouldInsertAuthorAndDeveloper",
diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/fixture.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/fixture.xml
index de0d44f007a..a9b088b9670 100644
--- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/fixture.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/fixture.xml
@@ -6,6 +6,7 @@
<!-- root project -->
<projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
+ uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="[null]"
description="the description" long_name="Apache Struts"
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
created_at="2008-12-02" authorization_updated_at="2014-09-03"/>
@@ -30,6 +31,7 @@
<!-- module -->
<projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
+ uuid="BCDE" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="ABCD"
scope="PRJ" qualifier="BRC" long_name="Struts Core"
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"
created_at="2008-12-02" authorization_updated_at="[null]"/>
@@ -45,6 +47,7 @@
<!-- directory -->
<projects long_name="org.struts" id="3" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts"
+ uuid="CDEF" project_uuid="ABCD" module_uuid="BCDE" module_uuid_path="ABCD.BCDE"
name="src/org/struts" root_id="2"
description="[null]"
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts"
@@ -61,6 +64,7 @@
<!-- file -->
<projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java"
+ uuid="CDEF" project_uuid="ABCD" module_uuid="BCDE" module_uuid_path="ABCD.BCDE"
name="RequestContext.java" root_id="2"
description="[null]"
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java"
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/shouldInsertAuthorAndDeveloper-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/shouldInsertAuthorAndDeveloper-result.xml
index 0fabfc4e1ff..fdd4549b2e4 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/shouldInsertAuthorAndDeveloper-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/shouldInsertAuthorAndDeveloper-result.xml
@@ -1,4 +1,4 @@
<dataset>
- <projects id="1" name="developer@company.net" qualifier="DEV" uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"/>
+ <projects id="1" name="developer@company.net" qualifier="DEV" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="[null]"/>
<authors id="1" person_id="1" login="developer@company.net" />
</dataset>