aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-12-16 00:56:42 +0000
committerGodin <mandrikov@gmail.com>2010-12-16 00:56:42 +0000
commit96caf6eac13b66a73d0ee572ad3a361c38e4b53a (patch)
tree73887c03c31ac8d172f93cf3e3c79a38e144d67b
parenta8026252cd527d5aeb5897b641ee4a8df19a452c (diff)
downloadsonarqube-96caf6eac13b66a73d0ee572ad3a361c38e4b53a.tar.gz
sonarqube-96caf6eac13b66a73d0ee572ad3a361c38e4b53a.zip
SONAR-1722: Add DB columns for profiles inheritance
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java7
-rw-r--r--sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb36
5 files changed, 54 insertions, 7 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
index ff04ffb27ba..4c0ee4aa224 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
@@ -19,18 +19,19 @@
*/
package org.sonar.jpa.entity;
-import javax.persistence.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import javax.persistence.*;
+
@Entity
-@Table(name = SchemaMigration.TABLE_NAME, uniqueConstraints = {@UniqueConstraint(columnNames = {"version"})})
+@Table(name = SchemaMigration.TABLE_NAME, uniqueConstraints = { @UniqueConstraint(columnNames = { "version" }) })
public class SchemaMigration {
public final static int VERSION_UNKNOWN = -1;
- public static final int LAST_VERSION = 168;
+ public static final int LAST_VERSION = 169;
public final static String TABLE_NAME = "schema_migrations";
diff --git a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml
index 6818bf4c09e..32bf7af86df 100644
--- a/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/jpa/dao/RulesDaoTest/shouldAddActiveRulesToProfile-result.xml
@@ -1,6 +1,6 @@
<dataset>
- <rules_profiles id="1" provided="true" name="profile" default_profile="1" language="java"/>
+ <rules_profiles id="1" parent_id="[null]" provided="true" name="profile" default_profile="1" language="java"/>
<rules_categories id="1" name="category one" description="[null]"/>
@@ -10,7 +10,7 @@
<rules_parameters id="1" rule_id="1" name="param1" description="foo" param_type="r"/>
<!-- Active rule created -->
- <active_rules id="1" profile_id="1" rule_id="1" failure_level="2"/>
+ <active_rules id="1" profile_id="1" rule_id="1" failure_level="2" inherited="[null]" overrides="[null]"/>
<!-- Active rule param created -->
<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="20"/>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
index ccc5e9d2dbd..c71d1ea1835 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
@@ -29,11 +29,11 @@ import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
-import javax.persistence.*;
-
import java.util.ArrayList;
import java.util.List;
+import javax.persistence.*;
+
/**
* This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.
*/
@@ -82,6 +82,10 @@ public class RulesProfile implements Cloneable {
@OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY)
private List<ResourceModel> projects = new ArrayList<ResourceModel>();
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "parent_id", updatable = true, nullable = true)
+ private RulesProfile parentProfile;
+
/**
* @deprecated use the factory method create()
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
index de5db8d61a8..f6f8b0fef30 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
@@ -57,6 +57,12 @@ public class ActiveRule implements Cloneable {
@OneToMany(mappedBy = "activeRule", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
private List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
+ @Column(name = "inherited", updatable = true, nullable = true)
+ private Boolean inherited;
+
+ @Column(name = "overrides", updatable = true, nullable = true)
+ private Boolean overrides;
+
/**
* @deprecated visibility should be reduced to protected or package
*/
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
new file mode 100644
index 00000000000..1424404baf8
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/169_add_columns_for_profiles_inheritance.rb
@@ -0,0 +1,36 @@
+#
+# Sonar, entreprise quality control 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
+#
+
+#
+# Sonar 2.5
+#
+class AddColumnsForProfilesInheritance < ActiveRecord::Migration
+
+ def self.up
+ add_column 'active_rules', 'inherited', :boolean, :null => true
+ add_column 'active_rules', 'overrides', :boolean, :null => true
+ ActiveRule.reset_column_information
+ ActiveRule.update_all(ActiveRule.sanitize_sql_for_assignment({:inherited => false, :overrides => false}))
+
+ add_column 'rules_profiles', 'parent_id', :integer, :null => true
+ Profile.reset_column_information
+ end
+
+end