123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
- <mapper namespace="org.sonar.db.component.ComponentMapper">
-
- <sql id="componentColumns">
- p.uuid as uuid,
- p.uuid_path as uuidPath,
- p.project_uuid as projectUuid,
- p.module_uuid as moduleUuid,
- p.module_uuid_path as moduleUuidPath,
- p.main_branch_project_uuid as mainBranchProjectUuid,
- p.kee as kee,
- p.name as name,
- p.long_name as longName,
- p.description as description,
- p.qualifier as qualifier,
- p.scope as scope,
- p.language as language,
- p.root_uuid as rootUuid,
- p.path as path,
- p.enabled as enabled,
- p.copy_component_uuid as copyComponentUuid,
- p.private as isPrivate,
- p.created_at as createdAt
- </sql>
-
- <select id="selectByKey" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- where
- p.kee=#{key,jdbcType=VARCHAR}
- </select>
-
- <select id="selectBranchByKeyAndBranchKey" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- inner join project_branches pb on pb.uuid = p.project_uuid
- where
- (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
- and pb.kee=#{branch,jdbcType=VARCHAR}
- and (pb.branch_type='BRANCH')
- </select>
-
- <select id="selectPrByKeyAndBranchKey" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- inner join project_branches pb on pb.uuid = p.project_uuid
- where
- (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
- and pb.kee=#{branch,jdbcType=VARCHAR}
- and pb.branch_type='PULL_REQUEST'
- </select>
-
- <select id="selectByUuid" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- where
- p.uuid=#{uuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByProjectUuid" parameterType="string" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components root
- inner join components p on p.project_uuid=root.uuid
- where
- root.uuid=#{projectUuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByKeys" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.enabled=${_true}
- and p.main_branch_project_uuid is null
- and p.kee in
- <foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectByDbKeys" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.enabled=${_true}
- and p.kee in
- <foreach collection="dbKeys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectByKeysAndBranch" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- INNER JOIN project_branches pb on pb.uuid = p.project_uuid
- <where>
- p.enabled=${_true}
- AND p.kee IN
- <foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- AND pb.kee=#{branch,jdbcType=VARCHAR}
- </where>
- </select>
-
- <select id="selectByUuids" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectExistingUuids" parameterType="String" resultType="String">
- select p.uuid
- from components p
- where
- p.uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectSubProjectsByComponentUuids" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- INNER JOIN components child ON
- child.root_uuid=p.uuid
- and child.enabled=${_true}
- where
- p.enabled=${_true}
- and p.scope='PRJ'
- and child.uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectDescendantModules" parameterType="map" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- <include refid="modulesTreeQuery"/>
- </select>
-
- <sql id="modulesTreeQuery">
- INNER JOIN components module ON
- module.project_uuid = p.project_uuid
- and module.uuid = #{moduleUuid}
- and module.scope='PRJ' AND module.enabled = ${_true}
- where
- p.scope = #{scope,jdbcType=VARCHAR}
- <if test="excludeDisabled">
- and p.enabled = ${_true}
- </if>
- and
- <choose>
- <when test="_databaseId == 'mssql'">
- p.module_uuid_path LIKE module.module_uuid_path + '%'
- </when>
- <otherwise>
- p.module_uuid_path LIKE module.module_uuid_path || '%'
- </otherwise>
- </choose>
- </sql>
-
- <select id="selectEnabledFilesFromProject" parameterType="map" resultType="FilePathWithHash">
- SELECT
- p.uuid,
- p.path,
- p.module_uuid as moduleUuid,
- fs.src_hash as srcHash,
- fs.revision
- FROM components root
- INNER JOIN components p on
- p.project_uuid=root.uuid
- and p.enabled=${_true}
- and p.scope='FIL'
- INNER JOIN file_sources fs ON
- fs.file_uuid=p.uuid
- where
- root.uuid=#{projectUuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectDescendantFiles" parameterType="map" resultType="FilePathWithHash">
- SELECT
- p.uuid,
- p.path,
- p.module_uuid as moduleUuid,
- fs.src_hash as srcHash,
- fs.revision
- FROM components p
- INNER JOIN file_sources fs ON
- fs.file_uuid=p.uuid
- <include refid="modulesTreeQuery"/>
- </select>
-
- <select id="selectProjects" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.enabled=${_true}
- AND p.scope='PRJ'
- AND p.qualifier='TRK'
- AND p.main_branch_project_uuid IS NULL
- </select>
-
- <select id="selectComponentsByQualifiers" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- where
- <foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
- p.qualifier=#{qualifier,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="countEnabledModulesByProjectUuid" resultType="int">
- select
- count(1)
- from components p
- where
- p.enabled=${_true}
- and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
- and p.qualifier = 'BRC'
- </select>
-
- <select id="selectByQuery" resultType="Component">
- select
- <include refid="componentColumns"/>
- <include refid="sqlSelectByQuery"/>
- ORDER BY LOWER(p.name), p.name, p.created_at
- </select>
-
- <select id="countByQuery" resultType="int">
- select count(p.uuid)
- <include refid="sqlSelectByQuery"/>
- </select>
-
- <sql id="sqlSelectByQuery">
- from components p
- <if test="query.analyzedBefore!=null">
- inner join snapshots sa on sa.component_uuid=p.uuid
- and sa.status='P' and sa.islast=${_true} and sa.created_at < #{query.analyzedBefore,jdbcType=BIGINT}
- </if>
- where
- p.enabled=${_true}
- AND p.main_branch_project_uuid is null
- AND p.copy_component_uuid is null
- <if test="query.qualifiers!=null">
- and p.qualifier in
- <foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=",">
- #{qualifier,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.componentKeys!=null">
- and p.kee in
- <foreach collection="query.componentKeys" item="componentKey" open="(" close=")" separator=",">
- #{componentKey,jdbcType=BIGINT}
- </foreach>
- </if>
- <if test="query.componentUuids!=null">
- and p.uuid in
- <foreach collection="query.componentUuids" item="componentUuid" open="(" close=")" separator=",">
- #{componentUuid,jdbcType=BIGINT}
- </foreach>
- </if>
- <if test="query.nameOrKeyQuery!=null">
- and (
- upper(p.name) like #{query.nameOrKeyUpperLikeQuery,jdbcType=VARCHAR} escape '/'
- or
- <choose>
- <when test="query.isPartialMatchOnKey()">
- upper(p.kee) like #{query.nameOrKeyUpperLikeQuery,jdbcType=VARCHAR} escape '/'
- </when>
- <otherwise>
- p.kee = #{query.nameOrKeyQuery,jdbcType=VARCHAR}
- </otherwise>
- </choose>
- )
- </if>
- <if test="query.private!=null">
- <if test="query.private.equals(true)">
- and p.private=${_true}
- </if>
- <if test="query.private.equals(false)">
- and p.private=${_false}
- </if>
- </if>
- <if test="query.isOnProvisionedOnly()">
- and not exists(select 1 from snapshots sp where sp.component_uuid=p.uuid)
- and not exists(
- select 1 from snapshots sp
- inner join project_branches pb on sp.component_uuid = pb.uuid
- where pb.project_uuid = p.uuid
- )
- </if>
- <if test="query.anyBranchAnalyzedAfter != null">
- and (
- exists(
- -- branches of projects
- select 1 from snapshots s
- inner join project_branches pb on s.component_uuid = pb.uuid
- where pb.project_uuid = p.uuid
- and s.status='P'
- and s.islast = ${_true}
- and s.created_at >= #{query.anyBranchAnalyzedAfter,jdbcType=BIGINT}
- )
- or exists (
- -- applications, portfolios
- select 1 from snapshots s
- where s.component_uuid = p.uuid
- and s.status='P'
- and s.islast = ${_true}
- and s.created_at >= #{query.anyBranchAnalyzedAfter,jdbcType=BIGINT}
- )
- )
- </if>
- <if test="query.anyBranchAnalyzedBefore != null">
- and (
- exists(
- -- branches of projects
- select 1 from snapshots s
- inner join project_branches pb on s.component_uuid = pb.uuid
- where pb.project_uuid = p.uuid
- and s.status='P'
- and s.islast = ${_true}
- and s.created_at < #{query.anyBranchAnalyzedBefore,jdbcType=BIGINT}
- )
- or exists (
- -- applications, portfolios
- select 1 from snapshots s
- where s.component_uuid = p.uuid
- and s.status='P'
- and s.islast = ${_true}
- and s.created_at < #{query.anyBranchAnalyzedBefore,jdbcType=BIGINT}
- )
- )
- </if>
- <if test="query.createdAfter != null">
- and p.created_at >= #{query.createdAfter,jdbcType=TIMESTAMP}
- </if>
- </sql>
-
- <select id="selectDescendants" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- <include refid="selectDescendantsJoins"/>
- <where>
- <include refid="selectDescendantsFilters"/>
- </where>
- </select>
-
- <sql id="selectDescendantsJoins">
- inner join components base on base.project_uuid = p.project_uuid and base.uuid = #{baseUuid}
- <choose>
- <when test="query.getStrategy().name() == 'CHILDREN'">
- and p.uuid_path = #{baseUuidPath,jdbcType=VARCHAR}
- </when>
- <otherwise>
- and p.uuid_path like #{baseUuidPath,jdbcType=VARCHAR} ESCAPE '/'
- </otherwise>
- </choose>
- </sql>
-
- <sql id="selectDescendantsFilters">
- and p.enabled = ${_true}
- <if test="query.qualifiers != null">
- and p.qualifier in
- <foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=",">
- #{qualifier,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.scopes != null">
- and p.scope in
- <foreach collection="query.scopes" item="scope" open="(" close=")" separator=",">
- #{scope,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.nameOrKeyQuery != null">
- and (
- p.kee = #{query.nameOrKeyQuery,jdbcType=VARCHAR}
- or
- upper(p.name) like #{query.nameOrKeyUpperLikeQuery,jdbcType=VARCHAR} escape '/'
- )
- </if>
- </sql>
-
- <select id="selectUuidsForQualifiers" resultType="UuidWithProjectUuid">
- SELECT p.uuid as "uuid", p.project_uuid as "projectUuid" FROM components p
- where
- <foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
- p.qualifier=#{qualifier,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectViewKeysWithEnabledCopyOfProject" resultType="String">
- select
- distinct p.kee
- from components p
- inner join components leaf on
- leaf.qualifier = 'TRK'
- and leaf.scope = 'FIL'
- and leaf.enabled = ${_true}
- and leaf.copy_component_uuid in
- <foreach collection="projectUuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
- where
- p.enabled = ${_true}
- and p.uuid = leaf.project_uuid
- and p.scope = 'PRJ'
- and p.qualifier in ('VW', 'APP')
- </select>
-
- <select id="selectProjectsFromView" resultType="String">
- select p.copy_component_uuid
- from components p
- where
- p.enabled = ${_true}
- and p.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
- and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR}
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is not null
- </select>
-
- <select id="selectComponentsFromProjectKeyAndScope" parameterType="map" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM components p
- INNER JOIN components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
- <where>
- <if test="excludeDisabled">
- p.enabled = ${_true}
- </if>
- <if test="scope != null">
- AND p.scope=#{scope,jdbcType=VARCHAR}
- </if>
- </where>
- </select>
-
- <select id="selectEnabledComponentsWithModuleUuidFromProjectKey" resultType="ComponentWithModuleUuid">
- SELECT
- p.uuid as uuid, p.module_uuid as moduleUuid, p.path as path, p.scope as scope
- FROM
- components p
- INNER JOIN
- components root ON root.uuid=p.project_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
- </select>
-
- <select id="selectUuidsByKeyFromProjectKey" parameterType="string" resultType="KeyWithUuid">
- SELECT
- p.kee, p.uuid
- FROM
- components p
- INNER JOIN
- components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
- </select>
-
- <select id="scrollForIndexing" parameterType="map" resultType="Component" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.enabled=${_true}
- and p.copy_component_uuid is null
- and p.main_branch_project_uuid is null
- and p.scope = 'PRJ'
- and p.qualifier in ('TRK','VW','SVW','APP')
- <if test="projectUuid != null">
- and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
- </if>
- </select>
-
- <select id="scrollAllFilesForFileMove" parameterType="map" resultType="org.sonar.db.component.FileMoveRowDto" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
- select
- p.uuid as uuid,
- p.kee as kee,
- p.path as path,
- fs.line_count as lineCount
- from components p
- inner join file_sources fs on
- fs.file_uuid = p.uuid
- where
- p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
- and p.enabled = ${_true}
- and p.scope = 'FIL'
- and p.qualifier in ('FIL', 'UTS')
- and p.path is not null
- </select>
-
- <insert id="insert" parameterType="Component">
- INSERT INTO components (
- kee,
- uuid,
- uuid_path,
- project_uuid,
- module_uuid,
- module_uuid_path,
- main_branch_project_uuid,
- name,
- long_name,
- qualifier,
- scope,
- language,
- description,
- private,
- root_uuid,
- path,
- copy_component_uuid,
- enabled,
- created_at,
- b_changed,
- deprecated_kee,
- b_copy_component_uuid,
- b_description,
- b_enabled,
- b_language,
- b_long_name,
- b_module_uuid,
- b_module_uuid_path,
- b_name,
- b_path,
- b_qualifier
- )
- VALUES (
- #{kee,jdbcType=VARCHAR},
- #{uuid,jdbcType=VARCHAR},
- #{uuidPath,jdbcType=VARCHAR},
- #{projectUuid,jdbcType=VARCHAR},
- #{moduleUuid,jdbcType=VARCHAR},
- #{moduleUuidPath,jdbcType=VARCHAR},
- #{mainBranchProjectUuid, jdbcType=VARCHAR},
- #{name,jdbcType=VARCHAR},
- #{longName,jdbcType=VARCHAR},
- #{qualifier,jdbcType=VARCHAR},
- #{scope,jdbcType=VARCHAR},
- #{language,jdbcType=VARCHAR},
- #{description,jdbcType=VARCHAR},
- #{isPrivate,jdbcType=BOOLEAN},
- #{rootUuid,jdbcType=VARCHAR},
- #{path,jdbcType=VARCHAR},
- #{copyComponentUuid,jdbcType=VARCHAR},
- #{enabled,jdbcType=BOOLEAN},
- #{createdAt,jdbcType=TIMESTAMP},
- ${_false},
- null,
- null,
- null,
- ${_false},
- null,
- null,
- null,
- null,
- null,
- null,
- null
- )
- </insert>
-
- <update id="update" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
- update components set
- b_changed = #{bChanged,jdbcType=BOOLEAN},
- <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
- deprecated_kee = #{bKey,jdbcType=VARCHAR},
- b_copy_component_uuid = #{bCopyComponentUuid,jdbcType=VARCHAR},
- b_description = #{bDescription,jdbcType=VARCHAR},
- b_enabled = #{bEnabled,jdbcType=BOOLEAN},
- b_uuid_path = #{bUuidPath,jdbcType=VARCHAR},
- b_language = #{bLanguage,jdbcType=VARCHAR},
- b_long_name = #{bLongName,jdbcType=VARCHAR},
- b_module_uuid = #{bModuleUuid,jdbcType=VARCHAR},
- b_module_uuid_path = #{bModuleUuidPath,jdbcType=VARCHAR},
- b_name = #{bName,jdbcType=VARCHAR},
- b_path = #{bPath,jdbcType=VARCHAR},
- b_qualifier = #{bQualifier,jdbcType=VARCHAR}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
- <update id="updateBEnabledToFalse" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
- update components set
- b_changed = ${_true},
- <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
- deprecated_kee = kee,
- b_copy_component_uuid = copy_component_uuid,
- b_description = description,
- b_enabled = ${_false},
- b_uuid_path = uuid_path,
- b_language = language,
- b_long_name = long_name,
- b_module_uuid = module_uuid,
- b_module_uuid_path = module_uuid_path,
- b_name = name,
- b_path = path,
- b_qualifier = qualifier
- where
- uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
- </update>
-
- <update id="applyBChangesForRootComponentUuid" parameterType="string" useGeneratedKeys="false">
- update components set
- <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
- kee = deprecated_kee,
- copy_component_uuid = b_copy_component_uuid,
- description = b_description,
- enabled = b_enabled,
- uuid_path = b_uuid_path,
- language = b_language,
- long_name = b_long_name,
- module_uuid = b_module_uuid,
- module_uuid_path = b_module_uuid_path,
- name = b_name,
- path = b_path,
- qualifier = b_qualifier,
- <!-- Try to fix the scope as best as we can -->
- scope = (
- case
- when b_qualifier = 'VW' THEN 'PRJ'
- when b_qualifier = 'SVW' THEN 'PRJ'
- when b_qualifier = 'APP' THEN 'PRJ'
- when b_qualifier = 'DIR' THEN 'DIR'
- when b_qualifier = 'FIL' THEN 'FIL'
- when b_qualifier = 'UTS' THEN 'FIL'
- <!-- For the few cases where qualifier is not enough to guess the scope (like TRK), just assume the scope remains unchanged -->
- else scope
- end
- ),
- b_changed = ${_false},
- <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
- deprecated_kee = null,
- b_copy_component_uuid = null,
- b_description = null,
- b_enabled = ${_false},
- b_language = null,
- b_long_name = null,
- b_module_uuid = null,
- b_module_uuid_path = null,
- b_name = null,
- b_path = null,
- b_qualifier = null
- where
- project_uuid = #{projectUuid,jdbcType=VARCHAR} and
- b_changed = ${_true}
- </update>
-
- <update id="resetBChangedForRootComponentUuid" parameterType="map" >
- update components
- set b_changed = ${_false},
- <!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
- deprecated_kee = kee
- where
- project_uuid = #{projectUuid,jdbcType=VARCHAR} and
- b_changed = ${_true}
- </update>
-
- <update id="setPrivateForRootComponentUuid" parameterType="map" >
- update components set
- private = #{isPrivate,jdbcType=BOOLEAN}
- where
- project_uuid = #{projectUuid,jdbcType=VARCHAR}
- and private <> #{isPrivate,jdbcType=BOOLEAN}
- </update>
-
- <delete id="delete" parameterType="String">
- DELETE FROM components WHERE uuid=#{componentUuid,jdbcType=VARCHAR}
- </delete>
-
- <select id="selectAllSiblingComponentKeysHavingOpenIssues" resultType="KeyWithUuid">
- SELECT DISTINCT p.kee as kee, p.uuid as uuid FROM components p
- JOIN issues i
- ON p.uuid = i.component_uuid
- JOIN project_branches b
- ON i.project_uuid = b.uuid
- AND b.branch_type = 'PULL_REQUEST'
- AND b.merge_branch_uuid = #{referenceBranchUuid,jdbcType=VARCHAR}
- AND b.uuid != #{currentBranchUuid,jdbcType=VARCHAR}
- AND i.status != 'CLOSED'
- </select>
-
- <select id="selectPrivateProjectsWithNcloc" resultType="org.sonar.db.component.ProjectNclocDistributionDto">
- select p.kee as kee, p.name as name, max(lm.value) as ncloc
- from live_measures lm
- inner join metrics m on m.uuid = lm.metric_uuid
- inner join project_branches b on b.uuid = lm.component_uuid
- inner join components p on b.project_uuid = p.uuid
- where
- m.name = 'ncloc'
- and b.branch_type = 'BRANCH'
- and p.enabled = ${_true}
- and p.private = ${_true}
- and p.scope = 'PRJ'
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is null
- group by p.kee, p.name
- order by ncloc desc
- </select>
-
- <sql id="checkIfAnyOfComponentsWithQualifiersSql">
- select
- case when exists
- (
- select c.uuid from components c
- where c.kee in
- <foreach collection="componentKeys" open="(" close=")" item="componentKey" separator=",">
- #{componentKey,jdbcType=VARCHAR}
- </foreach>
- and c.scope = 'PRJ'
- and c.qualifier in
- <foreach collection="qualifiers" open="(" close=")" item="qualifier" separator=",">
- #{qualifier,jdbcType=VARCHAR}
- </foreach>
- )
- then 1
- else 0
- end
- </sql>
-
- <select id="checkIfAnyOfComponentsWithQualifiers" resultType="short">
- <include refid="checkIfAnyOfComponentsWithQualifiersSql"/>
- </select>
-
- <select id="checkIfAnyOfComponentsWithQualifiers" resultType="short" databaseId="oracle">
- <include refid="checkIfAnyOfComponentsWithQualifiersSql"/>
- from dual
- </select>
- </mapper>
|