diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-09-28 16:47:05 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-09-28 16:47:26 +0200 |
commit | 358e30eaf1fb461650dd8f9ce26f9e4dc92bf0e2 (patch) | |
tree | 35a49968e63625d40c016aa5a8722e991d71e627 /sonar-server | |
parent | 898047bd8c53136e1f5eb83540ea8055d43a4586 (diff) | |
download | sonarqube-358e30eaf1fb461650dd8f9ce26f9e4dc92bf0e2.tar.gz sonarqube-358e30eaf1fb461650dd8f9ce26f9e4dc92bf0e2.zip |
SONAR-2602 Fix compatibility with Oracle
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb | 21 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb | 12 |
2 files changed, 23 insertions, 10 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index a9bb3d3a20e..397f70a7926 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -23,9 +23,6 @@ class Profile < ActiveRecord::Base has_many :alerts, :dependent => :delete_all has_many :active_rules, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :dependent => :destroy, :include => ['rule'] has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :include => ['active_rule_parameters', 'active_rule_note'] - has_many :projects, :class_name => 'Project', :finder_sql => %q( - select prj.* from projects prj, properties prop where prj.id=prop.resource_id and prop.resource_id is not null and prop.prop_key='sonar.profile.#{language}' and prop.text_value='#{name}' - ) has_many :changes, :class_name => 'ActiveRuleChange', :dependent => :destroy has_many :children, :class_name => 'Profile', :finder_sql => %q( select c.* from rules_profiles c where c.parent_name='#{name}' and c.language='#{language}' @@ -183,12 +180,30 @@ class Profile < ActiveRecord::Base self end + def projects? + !projects.empty? + end + + def projects + @projects ||= + begin + Project.find(:all, + :conditions => ['id in (select prop.resource_id from properties prop where prop.resource_id is not null and prop.prop_key=? and prop.text_value=?)', "sonar.profile.#{language}", name]) + end + end + + def sorted_projects + Api::Utils.insensitive_sort(projects){|p| p.name} + end + def add_project_id(project_id) Property.set("sonar.profile.#{language}", name, project_id) + @projects = nil end def remove_projects Property.clear_for_resources("sonar.profile.#{language}", name) + @projects = nil end def self.reset_default_profile_for_project_id(lang, project_id) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb index df77976eb84..fc19e5201a8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb @@ -18,8 +18,8 @@ })</script> </form> - <% unless @profile.projects.empty? %> - <table class="data"> + <% if @profile.projects? %> + <table class="data" id="projects-table"> <thead> <tr> <th></th> @@ -27,7 +27,7 @@ </tr> </thead> <tbody> - <% @profile.projects.each do |project| %> + <% @profile.sorted_projects.each do |project| %> <tr class="<%= cycle('even', 'odd') -%>"> <td class="thin"> <%= link_to_action message('remove'), @@ -50,12 +50,10 @@ </tr> </tfoot> </table> - - <% end %> <% else %> - <% if @profile.projects.empty? %> + <% if !@profile.projects? %> <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p> <% else %> <p><%= message('quality_profiles.projects_warning') -%></p> @@ -67,7 +65,7 @@ </tr> </thead> <tbody> - <% @profile.projects.each do |project| %> + <% @profile.sorted_projects.each do |project| %> <tr class="<%= cycle('even', 'odd') -%>"> <td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td> </tr> |