From 28ad4901ffc85a84d1b0a7458ae48e54a7b0a2b4 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 25 May 2012 16:10:46 +0200 Subject: [PATCH] SONAR-2706 add Review#getRuleName() --- .../core/review/workflow/review/DefaultReview.java | 11 +++++++++++ .../core/review/workflow/review/ImmutableReview.java | 10 +++++----- .../org/sonar/core/review/workflow/review/Review.java | 2 ++ .../src/main/webapp/WEB-INF/app/models/rule.rb | 8 ++++++-- .../main/webapp/WEB-INF/app/models/rule_failure.rb | 1 + 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java index 51a52790000..2c6519e38bc 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java +++ b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/DefaultReview.java @@ -39,6 +39,7 @@ public final class DefaultReview implements MutableReview { private Long reviewId; private String ruleRepositoryKey; private String ruleKey; + private String ruleName; private Long line; private boolean switchedOff = false; private boolean manual = false; @@ -85,6 +86,15 @@ public final class DefaultReview implements MutableReview { return this; } + public String getRuleName() { + return ruleName; + } + + public DefaultReview setRuleName(String s) { + this.ruleName = s; + return this; + } + public Long getLine() { return line; } @@ -210,6 +220,7 @@ public final class DefaultReview implements MutableReview { clone.setReviewId(reviewId); clone.setRuleKey(ruleKey); clone.setRuleRepositoryKey(ruleRepositoryKey); + clone.setRuleName(ruleName); clone.setSeverity(severity); clone.setStatus(status); clone.setSwitchedOff(switchedOff); diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java index 1f3b7e9e022..35c8f01a470 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java +++ b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/ImmutableReview.java @@ -24,9 +24,9 @@ import java.util.Map; public class ImmutableReview implements Review { private Long violationId; private Long reviewId; - private Long ruleId; private String ruleRepositoryKey; private String ruleKey; + private String ruleName; private Long line; private boolean switchedOff = false; private boolean manual = false; @@ -52,12 +52,12 @@ public class ImmutableReview implements Review { this.reviewId = reviewId; } - public Long getRuleId() { - return ruleId; + public String getRuleName() { + return ruleName; } - void setRuleId(Long ruleId) { - this.ruleId = ruleId; + void setRuleName(String s) { + this.ruleName = s; } public String getRuleRepositoryKey() { diff --git a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java index 95c8e28080a..777b6c5da96 100644 --- a/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java +++ b/sonar-core/src/main/java/org/sonar/core/review/workflow/review/Review.java @@ -27,6 +27,8 @@ public interface Review { String getRuleKey(); + String getRuleName(); + boolean isSwitchedOff(); String getMessage(); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb index 71fbd6a411f..4cde503c03d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb @@ -69,13 +69,17 @@ class Rule < ActiveRecord::Base name.downcase<=>other.name.downcase end - def name - @l10n_name ||= + def name(l10n=true) + if l10n + @l10n_name ||= begin result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName(I18n.locale, repository_key, plugin_rule_key) result = read_attribute(:name) unless result result end + else + read_attribute(:name) + end end def name=(value) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index 5121cd144c1..6ae29910d0b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -280,6 +280,7 @@ class RuleFailure < ActiveRecord::Base java_review.setSeverity(violation.severity.to_s) java_review.setRuleKey(violation.rule.plugin_rule_key) java_review.setRuleRepositoryKey(violation.rule.repository_key) + java_review.setRuleName(violation.rule.name(false)) # rule name is not localized java_review.setSwitchedOff(violation.switched_off||false) java_review.setMessage(violation.message) java_review.setLine(violation.line) -- 2.39.5