123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?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.project.ProjectMapper">
-
- <sql id="projectColumns">
- p.uuid as uuid,
- p.kee as kee,
- p.qualifier as qualifier,
- p.name as name,
- p.description as description,
- p.tags as tagsString,
- p.private as isPrivate,
- p.created_at as createdAt,
- p.updated_at as updatedAt
- </sql>
-
- <select id="selectAllProjectUuids" resultType="String">
- SELECT
- p.uuid as uuid
- FROM projects p
- where p.qualifier = 'TRK'
- </select>
-
- <select id="selectByUuid" parameterType="String" resultType="Project">
- SELECT
- <include refid="projectColumns"/>
- FROM projects p
- where
- p.uuid=#{uuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByUuids" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- where
- p.uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectProjectsByKeys" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- where
- p.qualifier='TRK' and
- p.kee in
- <foreach collection="kees" open="(" close=")" item="k" separator=",">
- #{k,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectApplicationsByKeys" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- where
- p.qualifier='APP' and
- p.kee in
- <foreach collection="kees" open="(" close=")" item="k" separator=",">
- #{k,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectProjects" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- where
- p.qualifier='TRK'
- </select>
-
- <select id="selectAll" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- </select>
-
- <select id="selectAllApplications" resultType="Project">
- select
- <include refid="projectColumns"/>
- from projects p
- where
- p.qualifier='APP'
- </select>
-
- <select id="selectProjectByKey" parameterType="String" resultType="Project">
- SELECT
- <include refid="projectColumns"/>
- FROM projects p
- where
- p.qualifier='TRK' and
- p.kee=#{key,jdbcType=VARCHAR}
- </select>
-
- <select id="selectApplicationByKey" parameterType="String" resultType="Project">
- SELECT
- <include refid="projectColumns"/>
- FROM projects p
- where
- p.qualifier='APP' and
- p.kee=#{key,jdbcType=VARCHAR}
- </select>
-
- <select id="selectProjectOrAppByKey" parameterType="String" resultType="Project">
- SELECT
- <include refid="projectColumns"/>
- FROM projects p
- where
- p.kee=#{key,jdbcType=VARCHAR}
- </select>
-
- <select id="selectProjectUuidsAssociatedToDefaultQualityProfileByLanguage" parameterType="map" resultType="string">
- select
- lm.project_uuid
- from
- live_measures lm
- inner join
- metrics m on m.uuid = lm.metric_uuid
- where
- m.name = 'ncloc_language_distribution'
- and lm.component_uuid = lm.project_uuid
- and lm.project_uuid not in (select project_uuid from project_qprofiles)
- and
- <foreach collection="languageFilters" index="index" item="languageFilter" open="(" separator=" or " close=")">
- lm.text_value like #{languageFilter, jdbcType=VARCHAR} escape '/'
- </foreach>
- </select>
-
- <insert id="insert" parameterType="Project">
- INSERT INTO projects (
- kee,
- qualifier,
- uuid,
- name,
- description,
- private,
- tags,
- created_at,
- updated_at
- )
- VALUES (
- #{kee,jdbcType=VARCHAR},
- #{qualifier,jdbcType=VARCHAR},
- #{uuid,jdbcType=VARCHAR},
- #{name,jdbcType=VARCHAR},
- #{description,jdbcType=VARCHAR},
- #{isPrivate,jdbcType=BOOLEAN},
- #{tagsString, jdbcType=VARCHAR},
- #{createdAt,jdbcType=BIGINT},
- #{updatedAt,jdbcType=BIGINT}
- )
- </insert>
-
- <update id="updateTags" parameterType="Project">
- update projects set
- tags = #{tagsString,jdbcType=VARCHAR},
- updated_at = #{updatedAt,jdbcType=BIGINT}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
- <update id="update" parameterType="Project">
- update projects set
- name = #{name,jdbcType=VARCHAR},
- description = #{description,jdbcType=VARCHAR},
- updated_at = #{updatedAt,jdbcType=BIGINT}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
- <update id="updateVisibility">
- update projects set
- private = #{isPrivate,jdbcType=BOOLEAN},
- updated_at = #{updatedAt,jdbcType=BIGINT}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
-
- <update id="updateNcloc">
- update projects set
- ncloc = #{ncloc,jdbcType=BIGINT}
- where
- uuid = #{projectUuid,jdbcType=VARCHAR}
- </update>
-
- <select id="getNclocSum" parameterType="string" resultType="long">
- select sum(ncloc) from projects where qualifier = 'TRK'
- <if test="projectUuidToExclude != null">
- and uuid <> #{projectUuidToExclude,jdbcType=VARCHAR}
- </if>
- </select>
-
- </mapper>
|