diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-05-01 20:30:44 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-05-01 20:30:44 +0200 |
commit | b350d6c3cafaa10ffad8ea619d75cda5f0c88034 (patch) | |
tree | 76ee210af99d24025ce318a4658e335041e59468 /sonar-server/src/main/java/org/sonar/server | |
parent | 2f413656329e579ebc61ce9fbbf034755d5c69c4 (diff) | |
download | sonarqube-b350d6c3cafaa10ffad8ea619d75cda5f0c88034.tar.gz sonarqube-b350d6c3cafaa10ffad8ea619d75cda5f0c88034.zip |
AddedSONAR-5237 - Added ActiveRuleParam and updated IndexMediumTest
Diffstat (limited to 'sonar-server/src/main/java/org/sonar/server')
3 files changed, 24 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleDoc.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleDoc.java index 2348f893be4..9537f169f90 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/RuleDoc.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleDoc.java @@ -121,7 +121,7 @@ class RuleDoc implements Rule { @Override public String defaultValue() { - return (String) param.get(RuleNormalizer.RuleParamField.DEFAULT_VALUE.key()); + return (String) param.get(RuleNormalizer.RuleParamField.VALUE.key()); } @Override diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleNormalizer.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleNormalizer.java index dbd380c89bf..22c5dece4f3 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/RuleNormalizer.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleNormalizer.java @@ -24,6 +24,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.check.Cardinality; import org.sonar.core.qualityprofile.db.ActiveRuleDao; import org.sonar.core.qualityprofile.db.ActiveRuleDto; +import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; import org.sonar.core.rule.RuleRuleTagDto; @@ -32,7 +33,9 @@ import org.sonar.server.search.BaseNormalizer; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -78,7 +81,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { NAME("name"), TYPE("type"), DESCRIPTION("description"), - DEFAULT_VALUE("default"); + VALUE("value"); private final String key; @@ -105,7 +108,8 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { NOTE_USER("noteUser"), PROFILE_ID("profile"), SEVERITY("severity"), - PARENT_ID("parent"); + PARENT_ID("parent"), + PARAMS("params"); private final String key; @@ -171,14 +175,16 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { /* Normalize the params */ List<RuleParamDto> params = ruleDao.selectParametersByRuleId(rule.getId()); + Map<Integer, String> paramIdNameLookup = new HashMap<Integer, String>(); if (!params.isEmpty()) { document.startArray(RuleField.PARAMS.key()); for (RuleParamDto param : params) { + paramIdNameLookup.put(param.getId(), param.getName()); document.startObject(); indexField(RuleParamField.NAME.key(), param.getName(), document); indexField(RuleParamField.TYPE.key(), param.getType(), document); indexField(RuleParamField.DESCRIPTION.key(), param.getDescription(), document); - indexField(RuleParamField.DEFAULT_VALUE.key(), param.getDefaultValue(), document); + indexField(RuleParamField.VALUE.key(), param.getDefaultValue(), document); document.endObject(); } document.endArray(); @@ -199,6 +205,19 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { indexField(ActiveRuleField.PROFILE_ID.key(), activeRule.getProfileId(), document); indexField(ActiveRuleField.SEVERITY.key(), activeRule.getSeverityString(), document); indexField(ActiveRuleField.PARENT_ID.key(), activeRule.getParentId(), document); + + /* Get all activeRuleParams */ + List<ActiveRuleParamDto> activeRuleParams = activeRuleDao.selectParamsByActiveRuleId(activeRule.getId()); + if(!activeRuleParams.isEmpty()) { + document.startArray(ActiveRuleField.PARAMS.key()); + for (ActiveRuleParamDto param : activeRuleParams) { + document.startObject(); + indexField(RuleParamField.NAME.key(), param.getKey(), document); + indexField(RuleParamField.VALUE.key(), param.getValue(), document); + document.endObject(); + } + document.endArray(); + } document.endObject(); } document.endArray(); @@ -207,5 +226,4 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { /* Done normalizing for Rule */ return document.endObject(); } - } diff --git a/sonar-server/src/main/java/org/sonar/server/search/Hit.java b/sonar-server/src/main/java/org/sonar/server/search/Hit.java index 5f1bdc09480..e31ae2904b5 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/Hit.java +++ b/sonar-server/src/main/java/org/sonar/server/search/Hit.java @@ -20,7 +20,6 @@ package org.sonar.server.search; import javax.annotation.CheckForNull; -import java.util.HashMap; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; @@ -37,7 +36,7 @@ public class Hit implements Comparable<Hit> { this.rank = rank; } - public Hit(Float score){ + public Hit(Float score) { this.fields = new TreeMap<String, Object>(); this.score = score; } |