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.8KB

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