diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-02-25 18:20:26 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-02-26 10:07:22 +0100 |
commit | 5003d67caf574fdfda09b178575e64da88f34333 (patch) | |
tree | 2dcd944d2ebc06857edfb342848442db4f294da1 /sonar-db | |
parent | 6940e82a6d7055a8f5f9506fa088a879e2a376d7 (diff) | |
download | sonarqube-5003d67caf574fdfda09b178575e64da88f34333.tar.gz sonarqube-5003d67caf574fdfda09b178575e64da88f34333.zip |
SONAR-7330 WS api/rules/show apply ES+DB pattern
Diffstat (limited to 'sonar-db')
3 files changed, 63 insertions, 4 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleMapper.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleMapper.java index d3c67a8abe1..cfe9e0d3c8c 100644 --- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleMapper.java @@ -38,7 +38,7 @@ public interface ActiveRuleMapper { ActiveRuleDto selectByKey(@Param("profileKey") String profileKey, @Param("repository") String repository, @Param("rule") String rule); - List<ActiveRuleDto> selectByKeys(@Param("keys") List<ActiveRuleKey> keys); + List<ActiveRuleDto> selectByKeys(@Param("keys") List<SqlActiveRuleKey> keys); List<ActiveRuleDto> selectByRuleId(int ruleId); diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/SqlActiveRuleKey.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/SqlActiveRuleKey.java new file mode 100644 index 00000000000..3eeefc33e54 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/SqlActiveRuleKey.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.db.qualityprofile; + +public class SqlActiveRuleKey implements Comparable<SqlActiveRuleKey> { + private final String qProfile; + private final String rule; + private final String repository; + + public SqlActiveRuleKey(ActiveRuleKey key) { + this.qProfile = key.qProfile(); + this.rule = key.ruleKey().rule(); + this.repository = key.ruleKey().repository(); + } + + @Override + public int compareTo(SqlActiveRuleKey o) { + int result = qProfile.compareTo(o.qProfile); + if (result != 0) { + return result; + } + result = rule.compareTo(o.rule); + if (result != 0) { + return result; + } + + return repository.compareTo(o.repository); + } + + public String getqProfile() { + return qProfile; + } + + public String getRule() { + return rule; + } + + public String getRepository() { + return repository; + } +} diff --git a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml index c542ac5cb8e..00f008aca51 100644 --- a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml @@ -96,9 +96,9 @@ <include refid="activeRuleKeyJoin"/> WHERE <foreach collection="keys" item="key" open="(" separator=" or " close=")"> - (qp.kee = #{key.qProfile()} - AND r.plugin_rule_key = #{key.ruleKey().rule()} - AND r.plugin_name = #{key.ruleKey().repository()}) + (qp.kee = #{key.qProfile} + AND r.plugin_rule_key = #{key.rule} + AND r.plugin_name = #{key.repository}) </foreach> </select> |