--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.startup;
+
+import org.sonar.jpa.session.DatabaseSessionFactory;
+
+public class DeleteDeprecatedMeasures {
+ public DeleteDeprecatedMeasures(DatabaseSessionFactory sessionFactory) {
+
+ }
+}
options[:status]=params[:status]\r
options[:searchtext]=params[:searchtext]\r
options[:include_parameters]=true\r
+ options[:inheritance]=params[:inheritance]\r
\r
\r
if params[:profile]\r
return\r
end\r
begin\r
- @profile = RulesProfile.find(params[:id].to_i)\r
+ @profile = Profile.find(params[:id].to_i)\r
rescue\r
redirect_to :controller => 'profiles'\r
return\r
end\r
else\r
- @profile = RulesProfile.default_profile\r
+ @profile = Profile.default_profile\r
end\r
\r
init_params()\r
@select_plugins = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()]}.sort\r
@select_priority = ANY_SELECTION + RULE_PRIORITIES\r
@select_status = [['Any',''], ["Active", STATUS_ACTIVE], ["Inactive", STATUS_INACTIVE]]\r
+ @select_inheritance = [['Any',''], ["Not inherited", 'NOT'], ["Inherited", 'INHERITED'], ["Overrides", 'OVERRIDES']]\r
\r
@rules = Rule.search(java_facade, {\r
- :profile => @profile, :status => @status, :priorities => @priorities,\r
+ :profile => @profile, :status => @status, :priorities => @priorities, :inheritance => @inheritance,\r
:plugins => @plugins, :searchtext => @searchtext, :include_parameters => true, :language => @profile.language})\r
\r
unless @searchtext.blank?\r
#\r
#\r
def activate_rule\r
- profile = RulesProfile.find(params[:id].to_i)\r
+ profile = Profile.find(params[:id].to_i)\r
if profile && !profile.provided?\r
rule=Rule.find(:first, :conditions => {:id => params[:rule_id].to_i, :enabled => true})\r
priority=params[:level]\r
active_rule.save!\r
java_facade.ruleActivatedOrChanged(profile.id, active_rule.id)\r
end\r
- active_rule.reload\r
+ if active_rule\r
+ active_rule.reload\r
+ end\r
\r
is_admin=true # security has already been checked by controller filters\r
render :update do |page|\r
#\r
def new\r
# form to duplicate a rule\r
- @profile = RulesProfile.find(params[:id].to_i)\r
+ @profile = Profile.find(params[:id].to_i)\r
@rule = Rule.find(params[:rule_id])\r
end\r
\r
#\r
def edit\r
# form to edit a rule\r
- @profile = RulesProfile.find(params[:id])\r
+ @profile = Profile.find(params[:id])\r
@rule = Rule.find(params[:rule_id])\r
if !@rule.editable?\r
redirect_to :action => 'index', :id => params[:id]\r
\r
def update_param\r
is_admin=true # security has already been checked by controller filters\r
- profile = RulesProfile.find(params[:profile_id].to_i)\r
+ profile = Profile.find(params[:profile_id].to_i)\r
rule_param = RulesParameter.find(params[:param_id].to_i)\r
active_rule = ActiveRule.find(params[:active_rule_id].to_i)\r
active_param = ActiveRuleParameter.find(params[:id].to_i) if params[:id].to_i > 0\r
@priorities = filter_any(params[:priorities]) || ['']\r
@plugins=filter_any(params[:plugins]) || ['']\r
@status=params[:rule_status] || STATUS_ACTIVE\r
+ @inheritance=params[:inheritance] || ''\r
@searchtext=params[:searchtext]\r
end\r
\r
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
#\r
class ActiveRule < ActiveRecord::Base\r
- belongs_to :rules_profile, :class_name => 'RulesProfile', :foreign_key => 'profile_id'\r
+ belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id'\r
belongs_to :rule\r
has_many :active_rule_parameters, :dependent => :destroy\r
\r
end
def validate_copy(name)
- new_rule_profile = RulesProfile.new(:name => name, :provided => false, :default_profile => false, :language => language)
+ new_rule_profile = Profile.new(:name => name, :provided => false, :default_profile => false, :language => language)
new_rule_profile.valid?
new_rule_profile.errors
end
def self.options_for_select
array=[]
- RulesProfile.find(:all, :order => 'name').each do |profile|
+ Profile.find(:all, :order => 'name').each do |profile|
label = profile.name
label = label + ' (active)' if profile.default_profile?
array<<[label, profile.id]
def self.filter(rules, options)
priorities = remove_blank(options[:priorities])
profile = options[:profile]
+ inheritance = options[:inheritance]
+
if profile
inactive = (options[:status]=='INACTIVE')
active = (options[:status]=='ACTIVE')
rules = rules.reject do |rule|
active_rule = profile.active_by_rule_id(rule.id)
- ((inactive and active_rule) or (active and active_rule.nil?))
+ ((inactive && active_rule) || (active && active_rule.nil?))
end
if priorities
rules = rules.select do |rule|
active_rule = profile.active_by_rule_id(rule.id)
- (active_rule and priorities.include?(active_rule.priority_text)) or (active_rule.nil? and priorities.include?(rule.priority_text))
+ (active_rule && priorities.include?(active_rule.priority_text)) || (active_rule.nil? && priorities.include?(rule.priority_text))
+ end
+ end
+
+ if inheritance=='NOT'
+ rules = rules.select do |rule|
+ active_rule = profile.active_by_rule_id(rule.id)
+ (active_rule.nil? || active_rule.inheritance.blank?)
+ end
+ elsif inheritance.present?
+ rules = rules.select do |rule|
+ active_rule = profile.active_by_rule_id(rule.id)
+ (active_rule && active_rule.inheritance==inheritance)
end
end
<span class="note">Status</span><br/>
<%= select_tag "rule_status", options_for_select(@select_status, @status), :id => 'search_status', :size => 6 %>
</td>
+ <% if @profile.inherited? %>
+ <td class="left" valign="top" width="1%" nowrap>
+ <span class="note">Inheritance</span><br/>
+ <%= select_tag "inheritance", options_for_select(@select_inheritance, @inheritance), :id => 'search_inheritance', :size => 6 %>
+ </td>
+ <% end %>
<td class="left" valign="top" >
<br/>
<%= submit_tag "Search", :id => 'submit_search' %>
<ul style="float: right" class="horizontal">
<li class="marginleft10">
<div class="csv">
- <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @plugins.join(','), :status => @status, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" onClick="return downloadCsv()" id="download-link" class="">Download</a>
+ <a href="<%= url_for(:controller => 'api/rules', :action => 'index', :language => @profile.language, :profile => @profile.name, :plugins => @plugins.join(','), :status => @status, :inheritance => @inheritance, :searchtext => @searchtext, :priorities => @priorities.join(','), :format => 'csv') -%>" onClick="return downloadCsv()" id="download-link" class="">Download</a>
</div>
</li>
<% if enable_modification %>