All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.db.component.ResourceIndexMapper.xml Maven / Gradle / Ivy

There is a newer version: 6.3.1
Show newest version
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="org.sonar.db.component.ResourceIndexMapper">

  <select id="selectProjectIdsFromQueryAndViewOrSubViewUuid" parameterType="map" resultType="long">
    SELECT r.resource_id FROM resource_index r
    INNER JOIN projects copy ON copy.copy_resource_id = r.resource_id
    <where>
      AND copy.module_uuid_path LIKE #{viewUuidQuery}
      AND r.kee LIKE #{query}
    </where>
    ORDER BY r.name_size
  </select>

  <!--
  The column PROJECTS.ROOT_ID is not exact on multi-modules projects. The root id must
  be loaded from the table SNAPSHOTS
  -->
  <select id="selectResources" parameterType="map" resultType="Resource">
    select p.name as "name", p.id as "id", p.scope as "scope", p.qualifier as "qualifier", s.root_project_id as "rootId"
    from projects p, snapshots s
    <where>
      p.enabled=${_true}
      and p.copy_resource_id is null
      and p.id=s.project_id
      and s.islast=${_true}
      <if test="scopes != null">
        and p.scope in
        <foreach item="scope" index="index" collection="scopes" open="(" separator="," close=")">#{scope}</foreach>
      </if>
      <if test="qualifiers != null">
        and p.qualifier in
        <foreach item="qualifier" index="index" collection="qualifiers" open="(" separator="," close=")">#{qualifier}
        </foreach>
      </if>
      <if test="rootProjectId != null">
        and s.root_project_id=#{rootProjectId}
      </if>
      <if test="nonIndexedOnly">
        and not exists(select * from resource_index ri where ri.resource_id=p.id)
      </if>
    </where>
    order by p.id
  </select>

  <select id="selectRootProjectIds" parameterType="map" resultType="int">
    select distinct root_project_id
    from snapshots
    where islast=${_true}
    and scope='PRJ'
    and qualifier in ('TRK', 'VW', 'SVW')
  </select>

  <select id="selectMasterIndexByResourceId" parameterType="long" resultType="ResourceIndex">
    select kee as "key", resource_id as "resourceId"
    from resource_index
    where resource_id=#{id} and position=0
  </select>

  <select id="selectResourceToIndex" parameterType="long" resultType="Resource">
    select id, name, root_id as "rootId", qualifier
    from projects
    where id=#{id} and enabled=${_true}
  </select>

  <delete id="deleteByResourceId" parameterType="long">
    delete from resource_index
    where resource_id=#{id}
  </delete>

  <insert id="insert" parameterType="ResourceIndex" useGeneratedKeys="false">
    insert into resource_index (kee, position, name_size, resource_id, root_project_id, qualifier)
    values (#{key}, #{position}, #{nameSize},
    #{resourceId}, #{rootProjectId}, #{qualifier})
  </insert>

</mapper>





© 2015 - 2025 Weber Informatics LLC | Privacy Policy