![JAR search and dependency download from the Maven repository](/logo.png)
org.sonar.db.component.SnapshotMapper.xml Maven / Gradle / Ivy
The newest version!
<?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.SnapshotMapper"> <sql id="snapshotColumns"> s.id, s.uuid as uuid, s.component_uuid as componentUuId, s.created_at as createdAt, s.build_date as buildDate, s.status as status, s.purge_status as purgeStatus, s.islast as last, s.version as rawVersion, s.period1_mode as periodMode, s.period1_param as periodParam, s.period1_date as periodDate </sql> <sql id="viewsSnapshotColumns"> s.uuid, s.created_at as createdAt, s.period1_date as leakDate </sql> <select id="selectByUuids" parameterType="List" resultType="Snapshot"> SELECT <include refid="snapshotColumns"/> FROM snapshots s WHERE s.uuid in <foreach collection="uuids" item="uuid" separator="," open="(" close=")"> #{uuid,jdbcType=VARCHAR} </foreach> </select> <select id="selectLastSnapshotByComponentUuid" resultType="Snapshot"> select <include refid="snapshotColumns" /> from snapshots s inner join projects p on s.component_uuid = p.project_uuid where s.islast=${_true} and p.uuid = #{componentUuid,jdbcType=VARCHAR} </select> <select id="selectLastSnapshotByRootComponentUuid" resultType="Snapshot"> select <include refid="snapshotColumns" /> from snapshots s where s.islast=${_true} and s.component_uuid = #{componentUuid,jdbcType=VARCHAR} </select> <select id="selectLastSnapshotsByRootComponentUuids" resultType="Snapshot"> select <include refid="snapshotColumns" /> from snapshots s where s.islast=${_true} and s.component_uuid in <foreach collection="componentUuids" item="componentUuid" separator="," open="(" close=")"> #{componentUuid,jdbcType=VARCHAR} </foreach> </select> <select id="selectSnapshotsByQuery" parameterType="map" resultType="Snapshot"> SELECT <include refid="snapshotColumns" /> FROM snapshots s <if test="query.componentUuid != null"> INNER JOIN projects p ON p.uuid=s.component_uuid AND p.enabled=${_true} AND s.component_uuid=#{query.componentUuid,jdbcType=VARCHAR} </if> <where> <if test="query.status != null"> AND s.status=#{query.status,jdbcType=VARCHAR} </if> <if test="query.version != null"> AND s.version=#{query.version,jdbcType=VARCHAR} </if> <if test="query.isLast != null"> AND s.islast=#{query.isLast} </if> <if test="query.createdAfter != null"> AND s.created_at>=#{query.createdAfter,jdbcType=BIGINT} </if> <if test="query.createdBefore != null"> AND s.created_at<#{query.createdBefore,jdbcType=BIGINT} </if> </where> <if test="query.sortField != null"> ORDER BY <if test="query.sortField == 'created_at'"> s.created_at </if> <if test="query.sortOrder == 'asc'"> asc </if> <if test="query.sortOrder == 'desc'"> desc </if> </if> </select> <select id="selectFinishedByComponentUuidsAndFromDates" parameterType="map" resultType="Snapshot"> select <include refid="snapshotColumns" /> from snapshots s inner join projects p on p.uuid=s.component_uuid and p.enabled=${_true} inner join project_branches pb on pb.uuid=p.uuid inner join ce_activity ca on ca.analysis_uuid = s.uuid and ca.component_uuid = pb.project_uuid where <foreach collection="componentUuidFromDatePairs" open="(" close=")" item="componentUuidFromDatePair" separator=" or "> (pb.project_uuid=#{componentUuidFromDatePair.componentUuid, jdbcType=VARCHAR} and s.created_at >= #{componentUuidFromDatePair.from, jdbcType=BIGINT}) </foreach> and s.status = 'P' and ca.status=#{ceStatus, jdbcType=VARCHAR} order by s.created_at </select> <select id="selectPreviousVersionSnapshots" parameterType="map" resultType="Snapshot"> SELECT <include refid="snapshotColumns" /> FROM snapshots s INNER JOIN events e ON s.uuid = e.analysis_uuid AND e.name <> #{lastVersion} AND e.category='Version' <where> s.component_uuid=#{componentUuid,jdbcType=VARCHAR} </where> ORDER BY e.event_date DESC </select> <select id="selectOldestSnapshots" parameterType="map" resultType="Snapshot"> SELECT <include refid="snapshotColumns" /> FROM snapshots s <where> s.component_uuid=#{componentUuid,jdbcType=VARCHAR} </where> ORDER BY s.created_at ASC </select> <select id="selectSnapshotBefore" resultType="ViewsSnapshot"> SELECT <include refid="viewsSnapshotColumns" /> FROM snapshots s <where> and s.component_uuid = #{componentUuid,jdbcType=VARCHAR} and s.status = 'P' and s.created_at < #{date,jdbcType=BIGINT} </where> order by created_at desc </select> <update id="unsetIsLastFlagForComponentUuid" parameterType="map"> update snapshots set islast = ${_false} where component_uuid = #{componentUuid,jdbcType=VARCHAR} and islast = ${_true} </update> <update id="setIsLastFlagForAnalysisUuid" parameterType="map"> update snapshots set islast = ${_true}, status = 'P' where uuid = #{analysisUuid,jdbcType=VARCHAR} </update> <update id="update" parameterType="Snapshot"> update snapshots set version = #{version, jdbcType=VARCHAR}, status = #{status, jdbcType=VARCHAR} where uuid = #{uuid,jdbcType=VARCHAR} </update> <insert id="insert" parameterType="Snapshot" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> insert into snapshots ( uuid, component_uuid, created_at, build_date, status, purge_status, islast, version, period1_mode, period1_param, period1_date) values ( #{uuid, jdbcType=VARCHAR}, #{componentUuid, jdbcType=VARCHAR}, #{createdAt, jdbcType=BIGINT}, #{buildDate, jdbcType=BIGINT}, #{status, jdbcType=VARCHAR}, #{purgeStatus, jdbcType=INTEGER}, #{last, jdbcType=BOOLEAN}, #{version, jdbcType=VARCHAR}, #{periodMode, jdbcType=VARCHAR}, #{periodParam, jdbcType=VARCHAR}, #{periodDate, jdbcType=BIGINT}) </insert> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy