diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-05-21 17:30:43 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-05-21 17:41:08 +0200 |
commit | db30e4ece39c2dfd0c41b4d9eb612d5b494afd18 (patch) | |
tree | 759cefdab7022de255290fc0264334b276571100 /sonar-core/src | |
parent | a27d5efd0aa3ce834ee20bccd5044c3c36a3467a (diff) | |
download | sonarqube-db30e4ece39c2dfd0c41b4d9eb612d5b494afd18.tar.gz sonarqube-db30e4ece39c2dfd0c41b4d9eb612d5b494afd18.zip |
SONAR-6259 Use component caches to get id or uuid
Diffstat (limited to 'sonar-core/src')
4 files changed, 19 insertions, 10 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java index 93a2feb82ee..1e64ff9e9ed 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java @@ -135,12 +135,11 @@ public class ComponentDto implements Component { /** * Return the path from the project to the last modules */ - @CheckForNull public String moduleUuidPath() { return moduleUuidPath; } - public ComponentDto setModuleUuidPath(@Nullable String moduleUuidPath) { + public ComponentDto setModuleUuidPath(String moduleUuidPath) { this.moduleUuidPath = moduleUuidPath; return this; } diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java index be3f2b12412..424b8a269bf 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java @@ -96,7 +96,7 @@ public interface ComponentMapper { /** * Return all components of a project */ - List<ComponentDto> selectComponentsFromProjectUuid(@Param("projectUuid") String projectUuid); + List<ComponentDto> selectComponentsFromProjectKey(@Param("projectKey") String projectKey); /** * Return technical projects from a view or a sub-view diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml index f7690f358a0..ad195fe0815 100644 --- a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml @@ -213,11 +213,11 @@ </where> </select> - <select id="selectComponentsFromProjectUuid" parameterType="map" resultType="Component"> + <select id="selectComponentsFromProjectKey" parameterType="map" resultType="Component"> SELECT <include refid="componentColumns"/> FROM projects p + INNER JOIN projects root ON root.uuid=p.project_uuid AND root.kee=#{projectKey} <where> - AND p.project_uuid=#{projectUuid} AND p.enabled=${_true} </where> </select> @@ -285,7 +285,7 @@ #{createdAt,jdbcType=TIMESTAMP}, #{authorizationUpdatedAt,jdbcType=BIGINT}) </insert> - <insert id="update" parameterType="Component"> + <insert id="update" parameterType="Component" useGeneratedKeys="false"> UPDATE projects SET kee=#{kee,jdbcType=VARCHAR}, deprecated_kee=#{deprecatedKey,jdbcType=VARCHAR}, diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java b/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java index a2dae090bdc..bf5d14b0200 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/DbTester.java @@ -62,7 +62,12 @@ import java.math.BigDecimal; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; -import java.sql.*; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.util.List; import java.util.Map; import java.util.Properties; @@ -198,7 +203,7 @@ public class DbTester extends ExternalResource { throw new IllegalStateException("No results for " + sql); } catch (Exception e) { - throw new IllegalStateException("Fail to execute sql: " + sql); + throw new IllegalStateException("Fail to execute sql: " + sql, e); } } @@ -209,7 +214,7 @@ public class DbTester extends ExternalResource { ResultSet rs = stmt.executeQuery()) { return getHashMap(rs); } catch (Exception e) { - throw new IllegalStateException("Fail to execute sql: " + selectSql); + throw new IllegalStateException("Fail to execute sql: " + selectSql, e); } } @@ -237,7 +242,12 @@ public class DbTester extends ExternalResource { doClobFree(clob); } else if (value instanceof BigDecimal) { // In Oracle, INTEGER types are mapped as BigDecimal - value = ((BigDecimal) value).longValue(); + BigDecimal bgValue = ((BigDecimal)value); + if (bgValue.scale() == 0) { + value = bgValue.longValue(); + } else { + value = bgValue.doubleValue(); + } } else if (value instanceof Integer) { // To be consistent, all INTEGER types are mapped as Long value = ((Integer) value).longValue(); |