From 676932e588e925e22da9f5b83313607258f392df Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 23 Dec 2013 12:21:14 +0100 Subject: SONAR-4535 Reindex active rule note update --- .../core/qualityprofile/db/ActiveRuleDao.java | 25 ++++++++++++++++------ .../core/qualityprofile/db/ActiveRuleMapper.java | 4 ++++ .../core/qualityprofile/db/ActiveRuleMapper.xml | 25 ++++++++++++++-------- 3 files changed, 39 insertions(+), 15 deletions(-) (limited to 'sonar-core/src/main') 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 selectParamsByRuleIds(List ids) { + public List selectParamsByActiveRuleId(Integer activeRuleId) { SqlSession session = mybatis.openSession(); try { - return selectParamsByRuleIds(ids, session); + return selectParamsByActiveRuleId(activeRuleId, session); } finally { MyBatis.closeQuietly(session); } } - public List selectParamsByRuleIds(Collection ids, SqlSession session) { - if (ids.isEmpty()) { + public List selectParamsByActiveRuleId(Integer activeRuleId, SqlSession session) { + return session.getMapper(ActiveRuleMapper.class).selectParamsByActiveRuleId(activeRuleId); + } + + public List selectParamsByActiveRuleIds(List activeRuleIds) { + SqlSession session = mybatis.openSession(); + try { + return selectParamsByActiveRuleIds(activeRuleIds, session); + } finally { + MyBatis.closeQuietly(session); + } + } + + public List selectParamsByActiveRuleIds(Collection activeRuleIds, SqlSession session) { + if (activeRuleIds.isEmpty()) { return Collections.emptyList(); } List dtosList = newArrayList(); - List> idsPartitionList = Lists.partition(newArrayList(ids), 1000); + List> idsPartitionList = Lists.partition(newArrayList(activeRuleIds), 1000); for (List idsPartition : idsPartitionList) { - List dtos = session.selectList("org.sonar.core.qualityprofile.db.ActiveRuleMapper.selectParamsByRuleIds", newArrayList(idsPartition)); + List 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 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 @@ from active_rules a - and a.id in - - #{id} - + ( + a.id=#{id} + ) - select from active_rule_parameters p - and p.active_rule_id in - - #{id} - + p.active_rule_id=#{id} + + + + -- cgit v1.2.3