You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="org.sonar.db.project.ProjectMapper">
  4. <sql id="projectColumns">
  5. p.uuid as uuid,
  6. p.kee as kee,
  7. p.qualifier as qualifier,
  8. p.name as name,
  9. p.description as description,
  10. p.tags as tagsString,
  11. p.private as isPrivate,
  12. p.created_at as createdAt,
  13. p.updated_at as updatedAt
  14. </sql>
  15. <select id="selectAllProjectUuids" resultType="String">
  16. SELECT
  17. p.uuid as uuid
  18. FROM projects p
  19. where p.qualifier = 'TRK'
  20. </select>
  21. <select id="selectByUuid" parameterType="String" resultType="Project">
  22. SELECT
  23. <include refid="projectColumns"/>
  24. FROM projects p
  25. where
  26. p.uuid=#{uuid,jdbcType=VARCHAR}
  27. </select>
  28. <select id="selectByUuids" resultType="Project">
  29. select
  30. <include refid="projectColumns"/>
  31. from projects p
  32. where
  33. p.uuid in
  34. <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
  35. #{uuid,jdbcType=VARCHAR}
  36. </foreach>
  37. </select>
  38. <select id="selectProjectsByKeys" resultType="Project">
  39. select
  40. <include refid="projectColumns"/>
  41. from projects p
  42. where
  43. p.qualifier='TRK' and
  44. p.kee in
  45. <foreach collection="kees" open="(" close=")" item="k" separator=",">
  46. #{k,jdbcType=VARCHAR}
  47. </foreach>
  48. </select>
  49. <select id="selectApplicationsByKeys" resultType="Project">
  50. select
  51. <include refid="projectColumns"/>
  52. from projects p
  53. where
  54. p.qualifier='APP' and
  55. p.kee in
  56. <foreach collection="kees" open="(" close=")" item="k" separator=",">
  57. #{k,jdbcType=VARCHAR}
  58. </foreach>
  59. </select>
  60. <select id="selectProjects" resultType="Project">
  61. select
  62. <include refid="projectColumns"/>
  63. from projects p
  64. where
  65. p.qualifier='TRK'
  66. </select>
  67. <select id="selectAll" resultType="Project">
  68. select
  69. <include refid="projectColumns"/>
  70. from projects p
  71. </select>
  72. <select id="selectAllApplications" resultType="Project">
  73. select
  74. <include refid="projectColumns"/>
  75. from projects p
  76. where
  77. p.qualifier='APP'
  78. </select>
  79. <select id="selectProjectByKey" parameterType="String" resultType="Project">
  80. SELECT
  81. <include refid="projectColumns"/>
  82. FROM projects p
  83. where
  84. p.qualifier='TRK' and
  85. p.kee=#{key,jdbcType=VARCHAR}
  86. </select>
  87. <select id="selectApplicationByKey" parameterType="String" resultType="Project">
  88. SELECT
  89. <include refid="projectColumns"/>
  90. FROM projects p
  91. where
  92. p.qualifier='APP' and
  93. p.kee=#{key,jdbcType=VARCHAR}
  94. </select>
  95. <select id="selectProjectOrAppByKey" parameterType="String" resultType="Project">
  96. SELECT
  97. <include refid="projectColumns"/>
  98. FROM projects p
  99. where
  100. p.kee=#{key,jdbcType=VARCHAR}
  101. </select>
  102. <select id="selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage" parameterType="map" resultType="string">
  103. select
  104. lm.project_uuid
  105. from
  106. live_measures lm
  107. inner join
  108. metrics m on m.uuid = lm.metric_uuid
  109. where
  110. m.name = 'ncloc_language_distribution'
  111. and lm.component_uuid = lm.project_uuid
  112. and lm.project_uuid not in (select project_uuid from project_qprofiles)
  113. and
  114. <foreach collection="languageFilters" index="index" item="languageFilter" open="(" separator=" or " close=")">
  115. lm.text_value like #{languageFilter, jdbcType=VARCHAR} escape '/'
  116. </foreach>
  117. </select>
  118. <insert id="insert" parameterType="Project">
  119. INSERT INTO projects (
  120. kee,
  121. qualifier,
  122. uuid,
  123. name,
  124. description,
  125. private,
  126. tags,
  127. created_at,
  128. updated_at
  129. )
  130. VALUES (
  131. #{kee,jdbcType=VARCHAR},
  132. #{qualifier,jdbcType=VARCHAR},
  133. #{uuid,jdbcType=VARCHAR},
  134. #{name,jdbcType=VARCHAR},
  135. #{description,jdbcType=VARCHAR},
  136. #{isPrivate,jdbcType=BOOLEAN},
  137. #{tagsString, jdbcType=VARCHAR},
  138. #{createdAt,jdbcType=BIGINT},
  139. #{updatedAt,jdbcType=BIGINT}
  140. )
  141. </insert>
  142. <update id="updateTags" parameterType="Project">
  143. update projects set
  144. tags = #{tagsString,jdbcType=VARCHAR},
  145. updated_at = #{updatedAt,jdbcType=BIGINT}
  146. where
  147. uuid = #{uuid,jdbcType=VARCHAR}
  148. </update>
  149. <update id="update" parameterType="Project">
  150. update projects set
  151. name = #{name,jdbcType=VARCHAR},
  152. description = #{description,jdbcType=VARCHAR},
  153. updated_at = #{updatedAt,jdbcType=BIGINT}
  154. where
  155. uuid = #{uuid,jdbcType=VARCHAR}
  156. </update>
  157. <update id="updateVisibility">
  158. update projects set
  159. private = #{isPrivate,jdbcType=BOOLEAN},
  160. updated_at = #{updatedAt,jdbcType=BIGINT}
  161. where
  162. uuid = #{uuid,jdbcType=VARCHAR}
  163. </update>
  164. <update id="updateNcloc">
  165. update projects set
  166. ncloc = #{ncloc,jdbcType=BIGINT}
  167. where
  168. uuid = #{projectUuid,jdbcType=VARCHAR}
  169. </update>
  170. <select id="getNclocSum" parameterType="string" resultType="long">
  171. select sum(ncloc) from projects where qualifier = 'TRK'
  172. <if test="projectUuidToExclude != null">
  173. and uuid &lt;&gt; #{projectUuidToExclude,jdbcType=VARCHAR}
  174. </if>
  175. </select>
  176. </mapper>