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.

ProjectAlmSettingMapper.xml 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.alm.setting.ProjectAlmSettingMapper">
  4. <sql id="sqlColumns">
  5. p.uuid as uuid,
  6. p.project_uuid as projectUuid,
  7. p.alm_setting_uuid as almSettingUuid,
  8. p.alm_repo as almRepo,
  9. p.alm_slug as almSlug,
  10. p.summary_comment_enabled as summaryCommentEnabled,
  11. p.monorepo as monorepo,
  12. p.created_at as createdAt,
  13. p.updated_at as updatedAt
  14. </sql>
  15. <select id="selectAlmTypeAndUrlByProject" parameterType="string" resultType="org.sonar.db.alm.setting.ProjectAlmKeyAndProject">
  16. select
  17. pas.project_uuid as "projectUuid",
  18. alm_settings.alm_id as "almId",
  19. alm_settings.url as "url"
  20. from
  21. project_alm_settings pas
  22. inner join
  23. alm_settings alm_settings on pas.alm_setting_uuid = alm_settings.uuid
  24. </select>
  25. <select id="selectByProjectUuid" parameterType="string" resultType="org.sonar.db.alm.setting.ProjectAlmSettingDto">
  26. select <include refid="sqlColumns"/>
  27. from
  28. project_alm_settings p
  29. where
  30. p.project_uuid = #{projectUuid, jdbcType=VARCHAR}
  31. </select>
  32. <select id="selectByAlmSettingAndSlugs" parameterType="string" resultType="org.sonar.db.alm.setting.ProjectAlmSettingDto">
  33. select <include refid="sqlColumns"/>
  34. from
  35. project_alm_settings p
  36. where
  37. alm_setting_uuid=#{almSettingUuid, jdbcType=VARCHAR}
  38. and alm_slug in
  39. <foreach collection="slugs" open="(" close=")" item="slug" separator=",">
  40. #{slug, jdbcType=VARCHAR}
  41. </foreach>
  42. </select>
  43. <select id="selectByAlmSettingAndRepos" parameterType="string" resultType="org.sonar.db.alm.setting.ProjectAlmSettingDto">
  44. select <include refid="sqlColumns"/>
  45. from
  46. project_alm_settings p
  47. where
  48. alm_setting_uuid=#{almSettingUuid, jdbcType=VARCHAR}
  49. and alm_repo in
  50. <foreach collection="repos" open="(" close=")" item="repo" separator=",">
  51. #{repo, jdbcType=VARCHAR}
  52. </foreach>
  53. </select>
  54. <sql id="selectByAlmSql">
  55. select <include refid="sqlColumns"/>
  56. from
  57. project_alm_settings p
  58. inner join
  59. alm_settings alm_settings on p.alm_setting_uuid = alm_settings.uuid
  60. where
  61. alm_settings.alm_id=#{alm, jdbcType=VARCHAR}
  62. </sql>
  63. <select id="selectByAlm" parameterType="string" resultType="org.sonar.db.alm.setting.ProjectAlmSettingDto">
  64. <include refid="selectByAlmSql"/>
  65. </select>
  66. <select id="selectByProjectUuidsAndAlm" parameterType="map" resultType="org.sonar.db.alm.setting.ProjectAlmSettingDto">
  67. <include refid="selectByAlmSql"/>
  68. and p.project_uuid in
  69. <foreach collection="projectUuids" open="(" close=")" item="projectUuid" separator=",">
  70. #{projectUuid, jdbcType=VARCHAR}
  71. </foreach>
  72. </select>
  73. <insert id="insert" parameterType="Map" useGeneratedKeys="false">
  74. INSERT INTO project_alm_settings
  75. (
  76. uuid,
  77. project_uuid,
  78. alm_setting_uuid,
  79. alm_repo,
  80. alm_slug,
  81. summary_comment_enabled,
  82. monorepo,
  83. created_at,
  84. updated_at
  85. )
  86. VALUES (
  87. #{uuid, jdbcType=VARCHAR},
  88. #{dto.projectUuid, jdbcType=VARCHAR},
  89. #{dto.almSettingUuid, jdbcType=VARCHAR},
  90. #{dto.almRepo, jdbcType=VARCHAR},
  91. #{dto.almSlug, jdbcType=VARCHAR},
  92. #{dto.summaryCommentEnabled, jdbcType=BOOLEAN},
  93. #{dto.monorepo, jdbcType=BOOLEAN},
  94. #{now, jdbcType=BIGINT},
  95. #{now, jdbcType=BIGINT}
  96. )
  97. </insert>
  98. <!-- Oracle -->
  99. <insert id="insert" parameterType="Map" useGeneratedKeys="false" databaseId="oracle">
  100. INSERT INTO project_alm_settings
  101. (
  102. uuid,
  103. project_uuid,
  104. alm_setting_uuid,
  105. alm_repo,
  106. alm_slug,
  107. summary_comment_enabled,
  108. monorepo,
  109. created_at,
  110. updated_at
  111. )
  112. VALUES (
  113. #{uuid, jdbcType=VARCHAR},
  114. #{dto.projectUuid, jdbcType=VARCHAR},
  115. #{dto.almSettingUuid, jdbcType=VARCHAR},
  116. #{dto.almRepo, jdbcType=VARCHAR},
  117. #{dto.almSlug, jdbcType=VARCHAR},
  118. #{dto.summaryCommentEnabled, jdbcType=NUMERIC},
  119. #{dto.monorepo, jdbcType=NUMERIC},
  120. #{now, jdbcType=BIGINT},
  121. #{now, jdbcType=BIGINT}
  122. )
  123. </insert>
  124. <update id="update" parameterType="map">
  125. UPDATE project_alm_settings
  126. SET
  127. alm_setting_uuid = #{dto.almSettingUuid, jdbcType=VARCHAR},
  128. alm_repo = #{dto.almRepo, jdbcType=VARCHAR},
  129. alm_slug = #{dto.almSlug, jdbcType=VARCHAR},
  130. summary_comment_enabled = #{dto.summaryCommentEnabled, jdbcType=BOOLEAN},
  131. monorepo = #{dto.monorepo, jdbcType=BOOLEAN},
  132. updated_at = #{now, jdbcType=BIGINT}
  133. WHERE
  134. project_uuid = #{dto.projectUuid, jdbcType=VARCHAR}
  135. </update>
  136. <!-- Oracle -->
  137. <update id="update" parameterType="map" databaseId="oracle">
  138. UPDATE project_alm_settings
  139. SET
  140. alm_setting_uuid = #{dto.almSettingUuid, jdbcType=VARCHAR},
  141. alm_repo = #{dto.almRepo, jdbcType=VARCHAR},
  142. alm_slug = #{dto.almSlug, jdbcType=VARCHAR},
  143. summary_comment_enabled = #{dto.summaryCommentEnabled, jdbcType=NUMERIC},
  144. monorepo = #{dto.monorepo, jdbcType=NUMERIC},
  145. updated_at = #{now, jdbcType=BIGINT}
  146. WHERE
  147. project_uuid = #{dto.projectUuid, jdbcType=VARCHAR}
  148. </update>
  149. <select id="countByAlmSettingUuid" parameterType="map" resultType="int">
  150. SELECT
  151. count(1)
  152. FROM
  153. project_alm_settings p
  154. WHERE
  155. alm_setting_uuid = #{almSettingUuid, jdbcType=VARCHAR}
  156. </select>
  157. <delete id="deleteByAlmSettingUuid" parameterType="String">
  158. DELETE FROM project_alm_settings WHERE alm_setting_uuid = #{almSettingUuid, jdbcType=VARCHAR}
  159. </delete>
  160. <delete id="deleteByProjectUuid" parameterType="String">
  161. DELETE FROM project_alm_settings WHERE project_uuid = #{projectUuid, jdbcType=VARCHAR}
  162. </delete>
  163. </mapper>