*/
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";
<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]"/>
<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"/>
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.
*/
@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()
*/
@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
*/
--- /dev/null
+#
+# 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