diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-05-05 11:52:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-05-05 14:08:04 +0200 |
commit | 65aef3937b130bde3f2f316523b350c588f38368 (patch) | |
tree | 86052ef433adbff0883bf6d6bb8bbe71999a5a46 /sonar-server | |
parent | 164d8a4c78a7f8e92dbf72f1c58a586ecb0036f8 (diff) | |
download | sonarqube-65aef3937b130bde3f2f316523b350c588f38368.tar.gz sonarqube-65aef3937b130bde3f2f316523b350c588f38368.zip |
Rename some fields in rules2
Diffstat (limited to 'sonar-server')
8 files changed, 20 insertions, 21 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/Rule.java b/sonar-server/src/main/java/org/sonar/server/rule2/Rule.java index 62f5c934c10..3278441635d 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/Rule.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/Rule.java @@ -38,7 +38,7 @@ public interface Rule { String name(); - String description(); + String htmlDescription(); /** * Default severity when activated on a Quality profile @@ -79,4 +79,6 @@ public interface Rule { Date updatedAt(); + @CheckForNull + String internalKey(); } 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 df58e6ac58e..6f1bc421f54 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 @@ -53,6 +53,11 @@ class RuleDoc implements Rule { } @Override + public String internalKey() { + return (String) fields.get(RuleField.INTERNAL_KEY.key()); + } + + @Override public String language() { return (String) fields.get(RuleField.LANGUAGE.key()); } @@ -63,8 +68,8 @@ class RuleDoc implements Rule { } @Override - public String description() { - return (String) fields.get(RuleField.DESCRIPTION.key()); + public String htmlDescription() { + return (String) fields.get(RuleField.HTML_DESCRIPTION.key()); } @Override @@ -97,7 +102,7 @@ class RuleDoc implements Rule { @Override public List<RuleParam> params() { List<RuleParam> params = new ArrayList<RuleParam>(); - if(this.fields.get(RuleField.PARAMS.key()) != null) { + if (this.fields.get(RuleField.PARAMS.key()) != null) { Map<String, Map<String, Object>> esParams = (Map<String, Map<String, Object>>) this.fields.get(RuleField.PARAMS.key()); for (final Map<String, Object> param : esParams.values()) { params.add(new RuleParam() { diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleIndex.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleIndex.java index 85e199da0c1..358c587cfe7 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/RuleIndex.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleIndex.java @@ -60,7 +60,7 @@ public class RuleIndex extends BaseIndex<RuleKey, RuleDto> { public static final Set<String> PUBLIC_FIELDS = ImmutableSet.of( RuleField.KEY.key(), RuleField.NAME.key(), - RuleField.DESCRIPTION.key(), + RuleField.HTML_DESCRIPTION.key(), RuleField.LANGUAGE.key(), RuleField.SEVERITY.key(), RuleField.STATUS.key(), @@ -70,6 +70,8 @@ public class RuleIndex extends BaseIndex<RuleKey, RuleDto> { RuleField.REPOSITORY.key(), RuleField.PARAMS.key(), RuleField.ACTIVE.key(), + RuleField.TEMPLATE.key(), + RuleField.INTERNAL_KEY.key(), RuleField.UPDATED_AT.key()); public RuleIndex(RuleNormalizer normalizer, WorkQueue workQueue, @@ -224,7 +226,7 @@ public class RuleIndex extends BaseIndex<RuleKey, RuleDto> { "_id", RuleField.NAME.key(), RuleField.NAME.key()+".search", - RuleField.DESCRIPTION.key(), + RuleField.HTML_DESCRIPTION.key(), RuleField.KEY.key(), RuleField.LANGUAGE.key(), RuleField.TAGS.key()); 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 25929e6d6d1..d39272870a4 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 @@ -49,7 +49,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { REPOSITORY("repo"), NAME("name"), CREATED_AT("createdAt"), - DESCRIPTION("desc"), + HTML_DESCRIPTION("htmlDesc"), SEVERITY("severity"), STATUS("status"), LANGUAGE("lang"), @@ -102,10 +102,6 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { public static enum ActiveRuleField { OVERRIDE("override"), INHERITANCE("inheritance"), - NOTE_CREATED("noteCreatedAt"), - NOTE_UPDATED("noteUpdatedAt"), - NOTE_DATA("noteData"), - NOTE_USER("noteUser"), PROFILE_ID("profile"), SEVERITY("severity"), PARENT_ID("parent"), @@ -166,7 +162,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { indexField(RuleField.NAME.key(), rule.getName(), document); indexField(RuleField.CREATED_AT.key(), rule.getCreatedAt(), document); indexField(RuleField.UPDATED_AT.key(), rule.getUpdatedAt(), document); - indexField(RuleField.DESCRIPTION.key(), rule.getDescription(), document); + indexField(RuleField.HTML_DESCRIPTION.key(), rule.getDescription(), document); indexField(RuleField.SEVERITY.key(), rule.getSeverityString(), document); indexField(RuleField.STATUS.key(), rule.getStatus(), document); indexField(RuleField.LANGUAGE.key(), rule.getLanguage(), document); @@ -185,10 +181,6 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { document.startObject(activeRule.getProfileId().toString()); indexField(ActiveRuleField.OVERRIDE.key(), activeRule.doesOverride(), document); indexField(ActiveRuleField.INHERITANCE.key(), activeRule.getInheritance(), document); - indexField(ActiveRuleField.NOTE_CREATED.key(), activeRule.getNoteCreatedAt(), document); - indexField(ActiveRuleField.NOTE_UPDATED.key(), activeRule.getNoteUpdatedAt(), document); - indexField(ActiveRuleField.NOTE_DATA.key(), activeRule.getNoteData(), document); - indexField(ActiveRuleField.NOTE_USER.key(), activeRule.getNoteUserLogin(), document); indexField(ActiveRuleField.PROFILE_ID.key(), activeRule.getProfileId(), document); indexField(ActiveRuleField.SEVERITY.key(), activeRule.getSeverityString(), document); indexField(ActiveRuleField.PARENT_ID.key(), activeRule.getParentId(), document); diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleQuery.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleQuery.java index 258b07d36bf..9d3dbda0111 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/RuleQuery.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleQuery.java @@ -34,7 +34,6 @@ public class RuleQuery { REPOSITORY(RuleNormalizer.RuleField.REPOSITORY), NAME(RuleNormalizer.RuleField.NAME), CREATED_AT(RuleNormalizer.RuleField.CREATED_AT), - DESCRIPTION(RuleNormalizer.RuleField.DESCRIPTION), SEVERITY(RuleNormalizer.RuleField.SEVERITY), STATUS(RuleNormalizer.RuleField.STATUS), LANGUAGE(RuleNormalizer.RuleField.LANGUAGE); diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java index 9a51b5f41f5..1559203a267 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/SearchAction.java @@ -196,8 +196,6 @@ public class SearchAction implements RequestHandler { private void writeStatistics(Results results, JsonWriter json) { json.prop("total", results.getTotal()); - // TODO replace ES time by complete time - json.prop("time", results.getTime()); } private void writeHits(Results results, JsonWriter json) { diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java b/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java index ed0dd3680e5..8b304fee289 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/ws/ShowAction.java @@ -86,9 +86,10 @@ public class ShowAction implements RequestHandler { .prop("key", rule.key().rule()) .prop("lang", rule.language()) .prop("name", rule.name()) - .prop("desc", rule.description()) + .prop("htmlDesc", rule.htmlDescription()) .prop("status", rule.status().toString()) .prop("template", rule.template()) + .prop("internalKey", rule.internalKey()) .prop("severity", rule.severity().toString()) .name("tags").beginArray().values(rule.tags()).endArray() .name("sysTags").beginArray().values(rule.systemTags()).endArray(); diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java index ea75cadbb4c..b612b66b855 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java @@ -83,7 +83,7 @@ public class RuleServiceMediumTest { assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.KEY.key())).isEqualTo(ruleKey.rule()); assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.LANGUAGE.key())).isEqualTo("js"); assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.NAME.key())).isEqualTo("Rule S001"); - assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.DESCRIPTION.key())).isEqualTo("Description S001"); + assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.HTML_DESCRIPTION.key())).isEqualTo("Description S001"); assertThat(hit.getFieldAsString(RuleNormalizer.RuleField.STATUS.key())).isEqualTo(RuleStatus.READY.toString()); assertThat(hit.getField(RuleNormalizer.RuleField.CREATED_AT.key())).isNotNull(); assertThat(hit.getField(RuleNormalizer.RuleField.UPDATED_AT.key())).isNotNull(); |