aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-17 12:47:39 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-17 12:47:39 +0000
commit325aadeb23265541e1b9d54caa1c76b2d278970d (patch)
tree4dca44482124489581285e764e305264c508269f
parent483e55684694fde66f26e82ba21c3d042feefbbd (diff)
downloadsonarqube-325aadeb23265541e1b9d54caa1c76b2d278970d.tar.gz
sonarqube-325aadeb23265541e1b9d54caa1c76b2d278970d.zip
add methods JRubyFacade.getRuleRepositories() and getRuleRepository(String key)
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rules/RulesConsole.java20
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb13
3 files changed, 19 insertions, 22 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rules/RulesConsole.java b/sonar-server/src/main/java/org/sonar/server/rules/RulesConsole.java
index c7505386ce6..62bd8867a73 100644
--- a/sonar-server/src/main/java/org/sonar/server/rules/RulesConsole.java
+++ b/sonar-server/src/main/java/org/sonar/server/rules/RulesConsole.java
@@ -21,17 +21,19 @@ package org.sonar.server.rules;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
-import org.apache.commons.lang.StringUtils;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.sonar.api.ServerComponent;
import org.sonar.api.rules.RuleRepository;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
public final class RulesConsole implements ServerComponent {
- private List<RuleRepository> repositories = new ArrayList<RuleRepository>();
+ private List<RuleRepository> repositories = Lists.newArrayList();
+ private Map<String, RuleRepository> repositoryByKey = Maps.newHashMap();
private ListMultimap<String, RuleRepository> repositoriesByLanguage = ArrayListMultimap.create();
@@ -46,6 +48,7 @@ public final class RulesConsole implements ServerComponent {
}
for (RuleRepository repository : this.repositories) {
repositoriesByLanguage.put(repository.getLanguage(), repository);
+ repositoryByKey.put(repository.getKey(), repository);
}
}
@@ -53,12 +56,11 @@ public final class RulesConsole implements ServerComponent {
return repositoriesByLanguage.get(language);
}
+ public List<RuleRepository> getRepositories() {
+ return repositories;
+ }
+
public RuleRepository getRepository(String key) {
- for (RuleRepository repository : repositories) {
- if (StringUtils.equals(key, repository.getKey())) {
- return repository;
- }
- }
- return null;
+ return repositoryByKey.get(key);
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
index 98f8ff8dce8..880fec3b984 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
@@ -128,6 +128,14 @@ public class JRubyFacade {
/* PROFILES CONSOLE : RULES AND METRIC THRESHOLDS */
+ public List<RuleRepository> getRuleRepositories() {
+ return getContainer().getComponent(RulesConsole.class).getRepositories();
+ }
+
+ public RuleRepository getRuleRepository(String repositoryKey) {
+ return getContainer().getComponent(RulesConsole.class).getRepository(repositoryKey);
+ }
+
public List<RuleRepository> getRuleRepositoriesByLanguage(String languageKey) {
return getContainer().getComponent(RulesConsole.class).getRepositoriesByLanguage(languageKey);
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
index 308bc2a239f..2f6a0353a46 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
@@ -21,17 +21,4 @@ module ProfilesHelper
def languages
controller.java_facade.getLanguages()
end
-
- def projects_tooltip(profile)
- html=nil
- if profile.projects.size>0
- html='<ul>'
- profile.projects.each do |project|
- html+="<li style='white-space: nowrap'>#{escape_javascript project.name}</li>"
- end
- html+='</ul>'
- html
- end
- html
- end
end \ No newline at end of file