aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java14
-rw-r--r--sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java20
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb7
-rw-r--r--sonar-server/src/main/webapp/images/inherited.pngbin0 -> 510 bytes
-rw-r--r--sonar-server/src/main/webapp/images/overrides.pngbin0 -> 520 bytes
7 files changed, 28 insertions, 29 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
index 2ca434ee7ee..854ef5c8594 100644
--- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
+++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java
@@ -169,7 +169,7 @@ public class ProfilesBackup implements Backupable {
writeNode(writer, "key", rule.getRule().getKey());
writeNode(writer, "plugin", rule.getRule().getRepositoryKey());
writeNode(writer, "level", rule.getSeverity().name());
- writeNode(writer, "inherited", rule.getInheritanceStatus().toString());
+ writeNode(writer, "inheritance", rule.getInheritance());
if (!rule.getActiveRuleParams().isEmpty()) {
writer.startNode("params");
@@ -205,8 +205,8 @@ public class ProfilesBackup implements Backupable {
ActiveRule activeRule = new ActiveRule(null, new Rule(valuesRule.get("plugin"), valuesRule.get("key")), RulePriority
.valueOf(valuesRule.get("level")));
activeRule.setActiveRuleParams(params);
- if (valuesRule.containsKey("inherited")) {
- activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.valueOf(valuesRule.get("inherited")));
+ if (valuesRule.containsKey("inheritance")) {
+ activeRule.setInheritance(valuesRule.get("inheritance"));
}
return activeRule;
}
@@ -218,9 +218,11 @@ public class ProfilesBackup implements Backupable {
}
private void writeNode(HierarchicalStreamWriter writer, String name, String value) {
- writer.startNode(name);
- writer.setValue(value);
- writer.endNode();
+ if (value != null) {
+ writer.startNode(name);
+ writer.setValue(value);
+ writer.endNode();
+ }
}
private Map<String, String> readNode(HierarchicalStreamReader reader) {
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
index a1ad040d321..98f1dc6ca76 100644
--- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
+++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
@@ -19,8 +19,6 @@
*/
package org.sonar.server.configuration;
-import org.sonar.api.rules.ActiveRuleInheritanceStatus;
-
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.profiles.RulesProfile;
@@ -122,8 +120,8 @@ public class ProfilesManager extends BaseDao {
*/
public void activatedOrChanged(int parentProfileId, int activeRuleId) {
ActiveRule parentActiveRule = getSession().getEntity(ActiveRule.class, activeRuleId);
- if (parentActiveRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) {
- parentActiveRule.setInheritanceStatus(ActiveRuleInheritanceStatus.OVERRIDDEN);
+ if (parentActiveRule.isInherited()) {
+ parentActiveRule.setInheritance(ActiveRule.OVERRIDES);
getSession().saveWithoutFlush(parentActiveRule);
}
for (RulesProfile child : getChildren(parentProfileId)) {
@@ -159,12 +157,12 @@ public class ProfilesManager extends BaseDao {
public void revert(int profileId, int activeRuleId) {
RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId);
ActiveRule activeRule = getSession().getEntity(ActiveRule.class, activeRuleId);
- if (activeRule != null && activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.OVERRIDDEN) {
+ if (activeRule != null && activeRule.doesOverride()) {
ActiveRule parentActiveRule = getParentProfile(profile).getActiveRule(activeRule.getRule());
removeActiveRule(profile, activeRule);
activeRule = (ActiveRule) parentActiveRule.clone();
activeRule.setRulesProfile(profile);
- activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.INHERITED);
+ activeRule.setInheritance(ActiveRule.INHERITED);
profile.getActiveRules().add(activeRule);
getSession().saveWithoutFlush(activeRule);
@@ -179,17 +177,17 @@ public class ProfilesManager extends BaseDao {
private void activateOrChange(RulesProfile profile, ActiveRule parentActiveRule) {
ActiveRule activeRule = profile.getActiveRule(parentActiveRule.getRule());
if (activeRule != null) {
- if (activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) {
+ if (activeRule.isInherited()) {
removeActiveRule(profile, activeRule);
} else {
- activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.OVERRIDDEN);
+ activeRule.setInheritance(ActiveRule.OVERRIDES);
getSession().saveWithoutFlush(activeRule);
return; // no need to change in children
}
}
activeRule = (ActiveRule) parentActiveRule.clone();
activeRule.setRulesProfile(profile);
- activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.INHERITED);
+ activeRule.setInheritance(ActiveRule.INHERITED);
profile.getActiveRules().add(activeRule);
getSession().saveWithoutFlush(activeRule);
@@ -201,10 +199,10 @@ public class ProfilesManager extends BaseDao {
private void deactivate(RulesProfile profile, Rule rule) {
ActiveRule activeRule = profile.getActiveRule(rule);
if (activeRule != null) {
- if (activeRule.getInheritanceStatus() == ActiveRuleInheritanceStatus.INHERITED) {
+ if (activeRule.isInherited()) {
removeActiveRule(profile, activeRule);
} else {
- activeRule.setInheritanceStatus(ActiveRuleInheritanceStatus.NO);
+ activeRule.setInheritance(null);
getSession().saveWithoutFlush(activeRule);
return; // no need to change in children
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb
index cc325a3ccbc..83bce7e376b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule.rb
@@ -101,10 +101,10 @@ class ActiveRule < ActiveRecord::Base
end
def inherited?
- inherited==1
+ inheritance=='INHERITED'
end
- def overridden?
- inherited==2
+ def overrides?
+ inheritance=='OVERRIDES'
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb
index e5511c16196..52be4b10fcd 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/_rule.html.erb
@@ -14,15 +14,15 @@
:loading => "$('levels_#{rule.id}').replace('<img src=\"#{ApplicationController.root_context}/images/loading.gif\"/>');",
:with => "'level=' + get_level_for_rule(#{rule_select_box},#{rule_check_box})")
%>
- <%= check_box_tag(check_box_id, 'yes', (!active_rule.nil?), :onclick => activate_rule, :disabled => !enable_modification || (active_rule && (active_rule.inherited? || active_rule.overridden?))) %>
+ <%= check_box_tag(check_box_id, 'yes', (!active_rule.nil?), :onclick => activate_rule, :disabled => !enable_modification || (active_rule && (active_rule.inherited? || active_rule.overrides?))) %>
<%= select_tag(select_box_id, options_for_select(RulesConfigurationController::RULE_PRIORITIES, (active_rule.nil? ? rule.priority_text : active_rule.priority_text)),
{:onchange => changel_level, :disabled => (!(enable_modification) || active_rule.nil?)}) %>
<% if active_rule %>
<% if active_rule.inherited? %>
- <img src="<%= ApplicationController.root_context -%>/images/relation-vertical-green.png" alt="Inherited from parent" title="Inherited from parent"/>
- <% elsif active_rule.overridden? %>
- <img src="<%= ApplicationController.root_context -%>/images/relation-vertical-red.png" alt="Overrides parent definition" title="Overrides parent definition"/>
+ <img src="<%= ApplicationController.root_context -%>/images/inherited.png" alt="Inherited from parent" title="Inherited from parent"/>
+ <% elsif active_rule.overrides? %>
+ <img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="Overrides parent definition"/>
<% end %>
<% end %>
</form>
@@ -56,7 +56,7 @@
<% if rule.editable? %>
<%= button_to "Edit rule", :action => 'edit', :id => profile.id, :rule_id => rule.id %>
<% end %>
- <% if active_rule && active_rule.overridden? %>
+ <% if active_rule && active_rule.overrides? %>
<%= button_to "Revert to parent definition", :action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id %><br/>
<% end %>
<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb
index c7b238473d9..62775358dde 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb
@@ -24,11 +24,10 @@
class AddColumnsForProfilesInheritance < ActiveRecord::Migration
def self.up
- add_column 'active_rules', 'inherited', :integer, :null => true
+ add_column 'active_rules', 'inheritance', :varchar, :limit => 10, :null => true
ActiveRule.reset_column_information
- ActiveRule.update_all(ActiveRule.sanitize_sql_for_assignment({:inherited => 0}))
-
- add_column 'rules_profiles', 'parent_name', :string, :limit => 40, :null => true
+
+ add_column 'rules_profiles', 'parent_name', :string, :limit => 100, :null => true
Profile.reset_column_information
end
diff --git a/sonar-server/src/main/webapp/images/inherited.png b/sonar-server/src/main/webapp/images/inherited.png
new file mode 100644
index 00000000000..e193d530e22
--- /dev/null
+++ b/sonar-server/src/main/webapp/images/inherited.png
Binary files differ
diff --git a/sonar-server/src/main/webapp/images/overrides.png b/sonar-server/src/main/webapp/images/overrides.png
new file mode 100644
index 00000000000..35186694207
--- /dev/null
+++ b/sonar-server/src/main/webapp/images/overrides.png
Binary files differ