123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866 |
- <?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.id,
- p.organization_uuid as organizationUuid,
- 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.deprecated_kee as deprecatedKey,
- p.name as name,
- p.long_name as longName,
- p.description as description,
- p.tags as tagsString,
- 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 projects p
- where
- p.kee=#{key,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByKeyAndBranchKey" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM projects 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}
- </where>
- </select>
-
- <select id="selectComponentsHavingSameKeyOrderedById" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects p
- where p.kee=#{key,jdbcType=VARCHAR}
- order BY p.id ASC
- </select>
-
- <select id="selectById" parameterType="long" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM projects p
- where p.id = #{id,jdbcType=BIGINT}
- </select>
-
- <select id="selectByUuid" parameterType="String" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM projects p
- where
- p.uuid=#{uuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByProjectUuid" parameterType="string" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects root
- inner join projects p on p.project_uuid=root.uuid and p.organization_uuid=root.organization_uuid
- where
- root.uuid=#{projectUuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByKeys" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects 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 projects 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 projects 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="selectByIds" parameterType="long" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects p
- where
- p.enabled=${_true}
- and p.id in
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id,jdbcType=BIGINT}
- </foreach>
- </select>
-
- <select id="selectByUuids" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects 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 projects 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 projects p
- INNER JOIN projects child ON
- child.root_uuid=p.uuid
- and child.enabled=${_true}
- and child.organization_uuid=p.organization_uuid
- 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 projects p
- <include refid="modulesTreeQuery"/>
- </select>
-
- <sql id="modulesTreeQuery">
- INNER JOIN projects module ON
- module.project_uuid = p.project_uuid
- and module.organization_uuid = p.organization_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>
- <when test="_databaseId == 'mysql'">
- p.module_uuid_path LIKE concat(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 projects root
- INNER JOIN projects p on
- p.project_uuid=root.uuid
- and p.organization_uuid=root.organization_uuid
- and p.enabled=${_true}
- and p.scope='FIL'
- INNER JOIN file_sources fs ON
- fs.file_uuid=p.uuid
- and fs.data_type='SOURCE'
- 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 projects p
- INNER JOIN file_sources fs ON
- fs.file_uuid=p.uuid
- and fs.data_type='SOURCE'
- <include refid="modulesTreeQuery"/>
- </select>
-
- <select id="selectProjects" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects p
- where
- p.enabled=${_true}
- AND p.scope='PRJ'
- AND p.qualifier='TRK'
- AND p.main_branch_project_uuid IS NULL
- </select>
-
- <select id="selectProjectsByOrganization" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects p
- where
- p.enabled=${_true}
- and p.scope='PRJ'
- and p.qualifier='TRK'
- and p.organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
- and p.main_branch_project_uuid IS NULL
- </select>
-
- <select id="selectComponentsByQualifiers" resultType="Component">
- SELECT
- <include refid="componentColumns"/>
- FROM projects p
- where
- <foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
- p.qualifier=#{qualifier,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="countComponentByOrganizationAndId" resultType="int">
- select
- count(1)
- from projects p
- where
- p.organization_uuid = #{organizationUuid,jdbcType=VARCHAR}
- and p.id = #{componentId,jdbcType=BIGINT}
- </select>
-
- <select id="countByNclocRanges" resultType="org.sonar.db.KeyLongValue">
- select kee as "key", sum(val) as "value"
- from (
- select '1K' as kee, 0 as val ${_from_dual}
- union
- select '5K' as kee, 0 as val ${_from_dual}
- union
- select '10K' as kee, 0 as val ${_from_dual}
- union
- select '20K' as kee, 0 as val ${_from_dual}
- union
- select '50K' as kee, 0 as val ${_from_dual}
- union
- select '100K' as kee, 0 as val ${_from_dual}
- union
- select '250K' as kee, 0 as val ${_from_dual}
- union
- select '500K' as kee, 0 as val ${_from_dual}
- union
- select '1M' as kee, 0 as val ${_from_dual}
- union
- select '+1M' as kee, 0 as val ${_from_dual}
- union
- select kee, count(1) as val
- from (
- select case
- when locs <= 1000 then '1K'
- when locs > 1000 and locs <= 5000 then '5K'
- when locs > 5000 and locs <= 10000 then '10K'
- when locs > 10000 and locs <= 20000 then '20K'
- when locs > 20000 and locs <= 50000 then '50K'
- when locs > 50000 and locs <= 100000 then '100K'
- when locs > 100000 and locs <= 250000 then '250K'
- when locs > 250000 and locs <= 500000 then '500K'
- when locs > 500000 and locs <= 1000000 then '1M'
- else '+1M'
- end as kee
- from (
- select b.project_uuid as projectUuid, max(lm.value) as locs
- from live_measures lm
- inner join metrics m on m.id = lm.metric_id
- inner join projects p on p.uuid = lm.component_uuid
- inner join project_branches b on b.uuid = p.uuid
- where m.name = 'ncloc'
- and p.enabled = ${_true}
- and p.scope = 'PRJ'
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is null
- and b.branch_type = 'LONG'
- and b.key_type = 'BRANCH'
- group by b.project_uuid
- ) alias1
- ) alias2
- group by kee
- ) alias3
- group by kee
- </select>
-
- <select id="countPublicNcloc" resultType="long">
- select coalesce(sum(locs), 0)
- from (
- select b.project_uuid, max(lm.value) as locs
- from live_measures lm
- inner join metrics m on m.id = lm.metric_id
- inner join projects p on p.uuid = lm.component_uuid
- inner join project_branches b on b.uuid = p.uuid
- where m.name = 'ncloc'
- and p.enabled = ${_true}
- and p.scope = 'PRJ'
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is null
- and b.branch_type = 'LONG'
- and b.key_type = 'BRANCH'
- group by b.project_uuid
- ) projectLocs
- </select>
-
- <select id="selectByQuery" resultType="Component">
- select
- <include refid="componentColumns"/>
- <include refid="sqlSelectByQuery"/>
- ORDER BY LOWER(p.name), p.name, p.id
- </select>
-
- <select id="countByQuery" resultType="int">
- select count(p.id)
- <include refid="sqlSelectByQuery"/>
- </select>
-
- <sql id="sqlSelectByQuery">
- from projects 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="organizationUuid!=null">
- and p.organization_uuid=#{organizationUuid,jdbcType=VARCHAR}
- </if>
- <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.componentIds!=null">
- and p.id in
- <foreach collection="query.componentIds" item="componentId" open="(" close=")" separator=",">
- #{componentId,jdbcType=BIGINT}
- </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 projects p
- <include refid="selectDescendantsJoins"/>
- <where>
- <include refid="selectDescendantsFilters"/>
- </where>
- </select>
-
- <sql id="selectDescendantsJoins">
- inner join projects 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 projects 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 projects p
- inner join projects 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 projects 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 projects p
- INNER JOIN projects 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="selectUuidsByKeyFromProjectKey" parameterType="string" resultType="KeyWithUuid">
- SELECT
- p.kee, p.uuid
- FROM
- projects p
- INNER JOIN
- projects root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
- </select>
-
- <select id="selectGhostProjects" parameterType="map" resultType="Component">
- select distinct
- <include refid="componentColumns"/>
- from projects p
- <include refid="ghostProjectClauses"/>
- </select>
-
- <select id="countGhostProjects" parameterType="map" resultType="long">
- select
- count(distinct p.id)
- from projects p
- <include refid="ghostProjectClauses"/>
- </select>
-
- <sql id="ghostProjectClauses">
- inner join snapshots s1 on s1.component_uuid = p.uuid and s1.status='U'
- left join snapshots s2 on s2.component_uuid = p.uuid and s2.status='P'
- where
- s2.id is null
- and p.qualifier='TRK'
- and p.main_branch_project_uuid is null
- and p.copy_component_uuid is null
- <if test="query!=null">
- and (
- UPPER(p.name) like #{query} ESCAPE '/'
- or UPPER(p.kee) like #{query} ESCAPE '/'
- )
- </if>
- </sql>
-
- <select id="scrollForIndexing" parameterType="map" resultType="Component" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
- select
- <include refid="componentColumns"/>
- from projects p
- where
- p.enabled=${_true}
- and p.copy_component_uuid is null
- and p.main_branch_project_uuid is null
- <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.id,
- p.uuid as uuid,
- p.kee as kee,
- p.path as path,
- fs.line_count as lineCount
- from projects p
- inner join file_sources fs on
- fs.file_uuid = p.uuid
- and fs.data_type = 'SOURCE'
- 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>
-
- <select id="selectProjectsByNameQuery" resultType="Component">
- select
- <include refid="componentColumns"/>
- from projects p
- <where>
- p.enabled=${_true}
- AND p.main_branch_project_uuid is null
- AND p.copy_component_uuid is null
- <if test="includeModules == false">
- AND p.qualifier = 'TRK'
- </if>
- <if test="includeModules == true">
- AND (p.qualifier = 'TRK' OR p.qualifier = 'BRC')
- </if>
- <if test="nameQuery != null">
- AND UPPER(p.name) like #{nameQuery,jdbcType=VARCHAR} ESCAPE '/'
- </if>
- </where>
- ORDER BY p.name
- </select>
-
- <insert id="insert" parameterType="Component" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO projects (
- organization_uuid,
- kee,
- deprecated_kee,
- uuid,
- uuid_path,
- project_uuid,
- module_uuid,
- module_uuid_path,
- main_branch_project_uuid,
- name,
- long_name,
- qualifier,
- scope,
- language,
- description,
- private,
- tags,
- root_uuid,
- path,
- copy_component_uuid,
- enabled,
- created_at,
- b_changed,
- 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 (
- #{organizationUuid,jdbcType=VARCHAR},
- #{kee,jdbcType=VARCHAR},
- #{deprecatedKey,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},
- #{tagsString, jdbcType=VARCHAR},
- #{rootUuid,jdbcType=VARCHAR},
- #{path,jdbcType=VARCHAR},
- #{copyComponentUuid,jdbcType=VARCHAR},
- #{enabled,jdbcType=BOOLEAN},
- #{createdAt,jdbcType=TIMESTAMP},
- ${_false},
- null,
- null,
- ${_false},
- null,
- null,
- null,
- null,
- null,
- null,
- null
- )
- </insert>
-
- <update id="updateTags" parameterType="Component" useGeneratedKeys="false">
- update projects set
- tags = #{tagsString,jdbcType=VARCHAR}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
- <update id="update" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
- update projects set
- b_changed = #{bChanged,jdbcType=BOOLEAN},
- 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 projects set
- b_changed = ${_true},
- 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 projects set
- 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,
- b_changed = ${_false},
- 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 projects
- set b_changed = ${_false}
- where
- project_uuid = #{projectUuid,jdbcType=VARCHAR} and
- b_changed = ${_true}
- </update>
-
- <update id="setPrivateForRootComponentUuid" parameterType="map" >
- update projects set
- private = #{isPrivate,jdbcType=BOOLEAN}
- where
- project_uuid = #{projectUuid,jdbcType=VARCHAR}
- and private <> #{isPrivate,jdbcType=BOOLEAN}
- </update>
-
- <delete id="delete" parameterType="long">
- DELETE FROM projects WHERE id=#{id,jdbcType=BIGINT}
- </delete>
-
- <select id="selectComponentKeysHavingIssuesToMerge" resultType="KeyWithUuid">
- SELECT DISTINCT p.kee as kee, p.uuid as uuid FROM projects p
- JOIN issues i
- ON p.uuid = i.component_uuid
- JOIN project_branches b
- ON i.project_uuid = b.uuid
- AND (b.branch_type = 'SHORT' OR b.branch_type = 'PULL_REQUEST')
- AND b.merge_branch_uuid = #{mergeBranchUuid,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.id = lm.metric_id
- inner join project_branches b on b.uuid = lm.component_uuid
- inner join projects p on b.project_uuid = p.uuid
- where
- m.name = 'ncloc'
- and b.key_type = 'BRANCH'
- and b.branch_type = 'LONG'
- and p.enabled = ${_true}
- and p.private = ${_true}
- and p.scope = 'PRJ'
- and p.qualifier = 'TRK'
- and p.copy_component_uuid is null
- and p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR}
- group by p.kee, p.name
- order by ncloc desc
- </select>
- </mapper>
|