*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 491;
+ public static final int LAST_VERSION = 492;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('489');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('490');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('491');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('492');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"UPDATED_AT" TIMESTAMP
);
-CREATE TABLE "ACTIVE_RULE_NOTES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "ACTIVE_RULE_ID" INTEGER,
- "USER_LOGIN" VARCHAR(40),
- "DATA" CLOB(2147483647),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "RULE_NOTES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "RULE_ID" INTEGER,
- "USER_LOGIN" VARCHAR(40),
- "DATA" CLOB(2147483647),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
CREATE TABLE "AUTHORS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"PERSON_ID" INTEGER,
CREATE INDEX "INDEX_ACTION_PLANS_ON_PROJET_ID" ON "ACTION_PLANS" ("PROJECT_ID");
-CREATE INDEX "INDEX_ACTIVE_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_NOTES" ("ACTIVE_RULE_ID");
-
-CREATE INDEX "INDEX_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "RULE_NOTES" ("RULE_ID");
-
CREATE UNIQUE INDEX "UNIQ_SEMAPHORE_CHECKSUMS" ON "SEMAPHORES" ("CHECKSUM");
CREATE INDEX "SEMAPHORE_NAMES" ON "SEMAPHORES" ("NAME");
"#{qProfileRule.repositoryKey().to_s}:#{qProfileRule.key().to_s}"
end
+ def html_text(text)
+ Api::Utils.markdown_to_html(text)
+ end
+
+ def plain_text(text)
+ Api::Utils.convert_string_to_unix_newlines(text)
+ end
+
end
belongs_to :rules_profile, :class_name => 'Profile', :foreign_key => 'profile_id'
belongs_to :rule
has_many :active_rule_parameters, :dependent => :destroy
- has_one :active_rule_note
- alias_attribute :note, :active_rule_note
def level
failure_level
+++ /dev/null
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2013 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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 this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-class ActiveRuleNote < ActiveRecord::Base
- belongs_to :active_rule
- alias_attribute :text, :data
-
- validates_presence_of :active_rule, :message => "can't be empty"
- validates_presence_of :user_login, :message => "can't be empty"
- validates_length_of :data, :minimum => 1
-
- def user
- @user ||=
- begin
- user_login ? User.first(:conditions => ['login=?', user_login]) : nil
- end
- end
-
- def html_text
- Api::Utils.markdown_to_html(text)
- end
-
- def plain_text
- Api::Utils.convert_string_to_unix_newlines(text)
- end
-
-end
has_many :rules_parameters, :inverse_of => :rule
has_many :active_rules, :inverse_of => :rule
belongs_to :parent, :class_name => 'Rule', :foreign_key => 'parent_id'
- has_one :rule_note, :inverse_of => :rule
- alias_attribute :note, :rule_note
=begin TODO Uncomment these lines to make rule read-only when Rule facade is complete
def read_only?
+++ /dev/null
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2013 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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 this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-class RuleNote < ActiveRecord::Base
- belongs_to :rule
- alias_attribute :text, :data
-
- validates_presence_of :rule, :message => "can't be empty"
- validates_presence_of :user_login, :message => "can't be empty"
-
- def user
- @user ||=
- begin
- user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil
- end
- end
-
- def html_text
- Api::Utils.markdown_to_html(text)
- end
-
- def plain_text
- Api::Utils.convert_string_to_unix_newlines(text)
- end
-
-end
href="#!"><%=message('delete')-%></a>
<% end %>
</cite>
- <p><%= note.data -%></p>
+ <p><%= html_text(note.data) -%></p>
</blockquote>
<% elsif profiles_administrator? %>
<a href="#" onclick="$j('#<%= active_note_form_div_id -%>').show();$j('#<%= active_note_detail_div_id -%>').hide();$j('#<%= active_note_textarea_id -%>').focus(); return false;"
<tr>
<td class="width100" colspan="2">
<textarea name="note" id="<%= active_note_textarea_id -%>" rows="10" style="width:100%"
- onkeyup="if (this.value=='') $j('#<%= submit_active_note_update_button_id -%>').prop('disabled', true); else $j('#<%= submit_active_note_update_button_id -%>').prop('disabled', false);"><%= h(note.data) unless note.nil? -%></textarea>
+ onkeyup="if (this.value=='') $j('#<%= submit_active_note_update_button_id -%>').prop('disabled', true); else $j('#<%= submit_active_note_update_button_id -%>').prop('disabled', false);"><%= h(plain_text(note.data)) unless note.nil? -%></textarea>
</td>
</tr>
<tr>
<% end %>
</div>
- <% unless rule.ruleNote.nil? %>
- <p><%= rule.ruleNote.data -%></p>
+ <% if rule.ruleNote && !rule.ruleNote.data.strip.blank? %>
+ <p><%= html_text(rule.ruleNote.data) -%></p>
<% end %>
<% if profiles_administrator? %>
</tr>
<tr>
<td class="width100" colspan="2">
- <textarea name="text" id="<%= note_textarea_id -%>" rows="10" style="width:100%"><%= h(note.data) if note -%></textarea>
+ <textarea name="text" id="<%= note_textarea_id -%>" rows="10" style="width:100%"><%= h(plain_text(note.data)) if note -%></textarea>
</td>
</tr>
<tr>
--- /dev/null
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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 this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# Sonar 4.2
+# SONAR-4923
+#
+class RemoveRuleNotesAndActiveRuleNotes < ActiveRecord::Migration
+
+ class Project < ActiveRecord::Base
+ end
+
+ def self.up
+ remove_index_quietly(:active_rule_notes, 'arn_active_rule_id')
+ drop_table(:active_rule_notes)
+
+ remove_index_quietly(:rule_notes, 'rule_notes_rule_id')
+ drop_table(:rule_notes)
+ end
+
+ def self.remove_index_quietly(table, name)
+ begin
+ remove_index(table, :name => name)
+ rescue
+ # probably already removed
+ end
+ end
+
+end