aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml')
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml69
1 files changed, 69 insertions, 0 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml
new file mode 100644
index 00000000000..82afc7fa85d
--- /dev/null
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ResourceIndexerMapper.xml
@@ -0,0 +1,69 @@
+<?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.ResourceIndexerMapper">
+
+ <!--
+ 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>
+