From 486169ddd0dba69431c6e85c1be073bdaf1b795b Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Tue, 1 Jul 2014 10:09:26 +0200 Subject: [PATCH] SONAR-5007 - Added legacy ID field to Rule for RuleFinder --- .../src/main/java/org/sonar/api/rules/Rule.java | 3 ++- .../main/java/org/sonar/server/rule/DefaultRuleFinder.java | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java index 0b7ac65d5c7..45328b52e49 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java @@ -511,8 +511,9 @@ public class Rule { /** * For definition of rule only */ - public void setTags(String[] tags) { + public Rule setTags(String[] tags) { this.tags = tags; + return this; } /** diff --git a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java index 395822f832d..be224ea5b0f 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java @@ -25,6 +25,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RulePriority; +import org.sonar.server.rule.index.RuleDoc; import org.sonar.server.rule.index.RuleIndex; import org.sonar.server.rule.index.RuleQuery; import org.sonar.server.search.IndexClient; @@ -107,7 +108,8 @@ public class DefaultRuleFinder implements RuleFinder { private org.sonar.api.rules.Rule toRule(Rule rule) { org.sonar.api.rules.Rule apiRule = new org.sonar.api.rules.Rule(); - apiRule.setName(rule.name()) + apiRule + .setName(rule.name()) .setLanguage(rule.language()) .setKey(rule.key().rule()) .setConfigKey(rule.internalKey()) @@ -122,7 +124,8 @@ public class DefaultRuleFinder implements RuleFinder { .setDefaultSubCharacteristicKey(rule.defaultDebtSubCharacteristicKey()) .setCharacteristicKey(rule.debtCharacteristicKey()) .setSubCharacteristicKey(rule.debtSubCharacteristicKey()) - .setTags(rule.tags().toArray(new String[rule.tags().size()])); + .setTags(rule.tags().toArray(new String[rule.tags().size()])) + .setId(((RuleDoc) rule).id()); List apiParams = newArrayList(); for (RuleParam param : rule.params()) { -- 2.39.5