diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-12-23 12:21:14 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-12-23 12:21:14 +0100 |
commit | 676932e588e925e22da9f5b83313607258f392df (patch) | |
tree | a1ac17efa0a7f008a6e39591c3860e3ca1b36007 /sonar-core/src/main | |
parent | 193260715b52e175f6875a4e0056cebdd5d30fa3 (diff) | |
download | sonarqube-676932e588e925e22da9f5b83313607258f392df.tar.gz sonarqube-676932e588e925e22da9f5b83313607258f392df.zip |
SONAR-4535 Reindex active rule note update
Diffstat (limited to 'sonar-core/src/main')
3 files changed, 39 insertions, 15 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java index 2b8b69feed3..1ab38d9a113 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java @@ -204,23 +204,36 @@ public class ActiveRuleDao implements ServerComponent { return dtosList; } - public List<ActiveRuleParamDto> selectParamsByRuleIds(List<Integer> ids) { + public List<ActiveRuleParamDto> selectParamsByActiveRuleId(Integer activeRuleId) { SqlSession session = mybatis.openSession(); try { - return selectParamsByRuleIds(ids, session); + return selectParamsByActiveRuleId(activeRuleId, session); } finally { MyBatis.closeQuietly(session); } } - public List<ActiveRuleParamDto> selectParamsByRuleIds(Collection<Integer> ids, SqlSession session) { - if (ids.isEmpty()) { + public List<ActiveRuleParamDto> selectParamsByActiveRuleId(Integer activeRuleId, SqlSession session) { + return session.getMapper(ActiveRuleMapper.class).selectParamsByActiveRuleId(activeRuleId); + } + + public List<ActiveRuleParamDto> selectParamsByActiveRuleIds(List<Integer> activeRuleIds) { + SqlSession session = mybatis.openSession(); + try { + return selectParamsByActiveRuleIds(activeRuleIds, session); + } finally { + MyBatis.closeQuietly(session); + } + } + + public List<ActiveRuleParamDto> selectParamsByActiveRuleIds(Collection<Integer> activeRuleIds, SqlSession session) { + if (activeRuleIds.isEmpty()) { return Collections.emptyList(); } List<ActiveRuleParamDto> dtosList = newArrayList(); - List<List<Integer>> idsPartitionList = Lists.partition(newArrayList(ids), 1000); + List<List<Integer>> idsPartitionList = Lists.partition(newArrayList(activeRuleIds), 1000); for (List<Integer> idsPartition : idsPartitionList) { - List<ActiveRuleParamDto> dtos = session.selectList("org.sonar.core.qualityprofile.db.ActiveRuleMapper.selectParamsByRuleIds", newArrayList(idsPartition)); + List<ActiveRuleParamDto> dtos = session.selectList("org.sonar.core.qualityprofile.db.ActiveRuleMapper.selectParamsByActiveRuleIds", newArrayList(idsPartition)); dtosList.addAll(dtos); } return dtosList; diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java index 34050e6da9e..dd142cd99bc 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java @@ -24,6 +24,8 @@ import org.apache.ibatis.annotations.Param; import javax.annotation.CheckForNull; +import java.util.List; + public interface ActiveRuleMapper { @CheckForNull @@ -32,6 +34,8 @@ public interface ActiveRuleMapper { @CheckForNull ActiveRuleDto selectByProfileAndRule(@Param("profileId") Integer profileId, @Param("ruleId") Integer ruleId); + List<ActiveRuleParamDto> selectParamsByActiveRuleId(Integer activeRuleId); + @CheckForNull ActiveRuleParamDto selectParamById(Integer activeRuleParamId); diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml index ea158ba518f..66346a0f28e 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml @@ -106,22 +106,29 @@ <include refid="activeRuleColumns"/> from active_rules a <where> - and a.id in - <foreach collection="list" open="(" close=")" item="id" separator=","> - #{id} - </foreach> + (<foreach collection="list" item="id" open="(" separator=" or " close=")"> + a.id=#{id} + </foreach>) </where> </select> - <select id="selectParamsByRuleIds" parameterType="map" resultType="ActiveRuleParam"> + <select id="selectParamsByActiveRuleId" parameterType="Integer" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p <where> - and p.active_rule_id in - <foreach collection="list" open="(" close=")" item="id" separator=","> - #{id} - </foreach> + p.active_rule_id=#{id} + </where> + </select> + + <select id="selectParamsByActiveRuleIds" parameterType="map" resultType="ActiveRuleParam"> + select + <include refid="activeRuleParamColumns"/> + from active_rule_parameters p + <where> + (<foreach collection="list" item="id" open="(" separator=" or " close=")"> + p.active_rule_id=#{id} + </foreach>) </where> </select> </mapper> |