aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main
diff options
context:
space:
mode:
authorDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-01-23 16:08:49 +0100
committerGitHub <noreply@github.com>2017-01-23 16:08:49 +0100
commit0832a517c9b7cb70d51ba6557094a605a8a9efdc (patch)
tree2fa021674a42d7e7a0291cced2301d52e69d8489 /sonar-db/src/main
parent0584dc8d5d5d82a2035763c34afba0e12cf6e8d0 (diff)
downloadsonarqube-0832a517c9b7cb70d51ba6557094a605a8a9efdc.tar.gz
sonarqube-0832a517c9b7cb70d51ba6557094a605a8a9efdc.zip
SONAR-8238 when updating a project, clear ALL components from index
Diffstat (limited to 'sonar-db/src/main')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java11
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml13
3 files changed, 18 insertions, 8 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
index 8ec27d1c2a6..0bc027afb7a 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import javax.annotation.Nullable;
import org.apache.ibatis.session.ResultHandler;
@@ -230,10 +231,14 @@ public class ComponentDao implements Dao {
}
/**
- * Selects all enabled components. The result is not returned (since it is usually too big), but handed over to the <code>handler</code>
+ * Selects all components that are relevant for indexing. The result is not returned (since it is usually too big), but handed over to the <code>handler</code>
+ * @param session the database session
+ * @param projectUuid the project uuid, which is selected with all of its children
+ * @param handler the action to be applied to every result
*/
- public void selectAll(DbSession session, ResultHandler handler) {
- mapper(session).selectAll(handler);
+ public void selectForIndexing(DbSession session, @Nullable String projectUuid, ResultHandler handler) {
+ Objects.requireNonNull(handler);
+ mapper(session).selectForIndexing(projectUuid, handler);
}
/**
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
index 7b2e26eab24..a32a4177b58 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
@@ -116,7 +116,7 @@ public interface ComponentMapper {
long countGhostProjects(Map<String, Object> parameters);
- void selectAll(ResultHandler handler);
+ void selectForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler handler);
void insert(ComponentDto componentDto);
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index a9d12f01871..92c23601b28 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -414,11 +414,16 @@
</if>
</sql>
- <select id="selectAll" parameterType="map" resultType="Component">
- select distinct
- <include refid="componentColumns"/>
+ <select id="selectForIndexing" parameterType="map" resultType="Component">
+ select
+ <include refid="componentColumns"/>
from projects p
- where p.enabled=${_true}
+ where
+ p.enabled=${_true}
+ and p.copy_component_uuid is null
+ <if test="projectUuid != null">
+ and p.project_uuid=#{projectUuid}
+ </if>
</select>
<insert id="insert" parameterType="Component" keyColumn="id" useGeneratedKeys="true" keyProperty="id">