1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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>
|