aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-10 22:11:54 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-16 22:22:43 +0200
commit5ea3ec70ab758986b223f84b7de16a65e8fec527 (patch)
treeffc7b4165f9ceda6ee9c26eea3e14b5bc69ec6d9
parentefa7cbf67fc688806609b21eb78f560e2102c5ec (diff)
downloadsonarqube-5ea3ec70ab758986b223f84b7de16a65e8fec527.tar.gz
sonarqube-5ea3ec70ab758986b223f84b7de16a65e8fec527.zip
SONAR-6716 Remove temporary creation of tables for "filters"
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/115_create_filters.rb63
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb32
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb95
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/304_add_key_to_filters.rb62
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_filters.rb44
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/360_move_existing_measure_filters.rb153
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/361_move_filter_widgets.rb64
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/362_drop_filter_tables.rb32
8 files changed, 0 insertions, 545 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/115_create_filters.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/115_create_filters.rb
deleted file mode 100644
index 5e716cc17ad..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/115_create_filters.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 2.2
-#
-class CreateFilters < ActiveRecord::Migration
-
- def self.up
- create_table 'filters' do |t|
- t.column 'name', :string, :limit => 100
- t.column 'user_id', :integer, :null => true
- t.column 'shared', :boolean, :null => true
- t.column 'favourites', :boolean, :null => true
- t.column 'resource_id', :integer, :null => true
- t.column 'default_view', :string, :limit => 20, :null => true
- t.column 'page_size', :integer, :null => true
- t.column 'kee', :string, :limit => 100, :null => true
- end
-
- create_table 'filter_columns' do |t|
- t.column 'filter_id', :integer
- t.column 'family', :string, :limit => 100, :null => true
- t.column 'kee', :string, :limit => 100, :null => true
- t.column 'sort_direction', :string, :limit => 5, :null => true
- t.column 'order_index', :integer, :null => true
- end
-
- create_table 'criteria' do |t|
- t.column 'filter_id', :integer
- t.column 'family', :string, :limit => 100, :null => true
- t.column 'kee', :string, :limit => 100, :null => true
- t.column 'operator', :string, :limit => 20, :null => true
- t.column 'value', :decimal, :null => true, :precision => 30, :scale => 20
- t.column 'text_value', :string, :null => 200, :null => true
- end
-
- create_table 'active_filters' do |t|
- t.column 'filter_id', :integer
- t.column 'user_id', :integer, :null => true
- t.column 'order_index', :integer, :null => true
- end
-
- end
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb
deleted file mode 100644
index 791f6e9bfd4..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 2.5
-#
-class AddPeriodsToFilters < ActiveRecord::Migration
-
- def self.up
- add_column :filters, :period_index, :integer, :null => true
- add_column :filter_columns, :variation, :boolean, :null => true
- add_column :criteria, :variation, :boolean, :null => true
- end
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb
deleted file mode 100644
index 0d0eef8c13a..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.1
-#
-class CreateGlobalDashboardsForFilter < ActiveRecord::Migration
- class ActiveFilter < ActiveRecord::Base
- end
-
- class Dashboard < ActiveRecord::Base
- end
-
- class ActiveDashboard < ActiveRecord::Base
- end
-
- class Widget < ActiveRecord::Base
- end
-
- class WidgetProperty < ActiveRecord::Base
- end
-
- class Filter < ActiveRecord::Base
- end
-
- def self.up
- dashboard_per_filter = create_global_dashboards()
-
- activate_dashboards(dashboard_per_filter)
-
- drop_table('active_filters')
- end
-
- def self.create_global_dashboards
- dashboards = {}
-
- Filter.find(:all).each do |filter|
- dashboard = Dashboard.create(:user_id => filter.user_id,
- :name => filter.name,
- :description => '',
- :column_layout => '100%',
- :shared => filter.shared,
- :is_global => true)
-
- widget = Widget.create(:dashboard_id => dashboard.id,
- :widget_key => 'filter',
- :name => 'Filter',
- :column_index => 1,
- :row_index => 1,
- :configured => true)
-
- WidgetProperty.create(:widget_id => widget.id,
- :kee => 'filter',
- :text_value => filter.id)
-
- dashboards[filter.id] = dashboard
- end
-
- dashboards
- end
-
- def self.activate_dashboards(dashboard_per_filter)
- ActiveFilter.find(:all).each do |activeFilter|
- filter = Filter.find_by_id(activeFilter.filter_id)
- if filter
- dashboard = dashboard_per_filter[filter.id]
-
- if !filter.favourites || activeFilter.user_id
- ActiveDashboard.create(:dashboard_id => dashboard.id,
- :user_id => activeFilter.user_id,
- :order_index => activeFilter.order_index)
- end
- end
- end
- end
-
-end
-
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/304_add_key_to_filters.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/304_add_key_to_filters.rb
deleted file mode 100644
index fde42554acf..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/304_add_key_to_filters.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.1
-#
-class AddKeyToFilters < ActiveRecord::Migration
- class WidgetProperty < ActiveRecord::Base
- end
-
- class Filter < ActiveRecord::Base
- end
-
- def self.up
- keys = add_key_column_to_filters()
- use_key_in_widget_properties(keys)
- end
-
- def self.add_key_column_to_filters
- keys = {}
-
- begin
- add_column 'filters', 'kee', :string, :null => true, :limit => 100
- rescue
- # Assume the column was already added by a previous migration
- end
-
- Filter.reset_column_information
- Filter.find(:all).each do |filter|
- keys[filter.id]=filter.user_id ? filter.id : filter.name
- filter.kee=keys[filter.id]
- filter.save
- end
-
- keys
- end
-
- def self.use_key_in_widget_properties(keys)
- WidgetProperty.find(:all, :conditions => {:kee => 'filter'}).each do |property|
- property.text_value=keys[property.text_value.to_i]
- property.save
- end
- end
-
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_filters.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_filters.rb
deleted file mode 100644
index 4a310cedd99..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_filters.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.1
-#
-class IgnoreLoadedFilters < ActiveRecord::Migration
- class Filter < ActiveRecord::Base
- end
-
- class LoadedTemplate < ActiveRecord::Base
- end
-
- def self.up
- mark_filter_as_loaded('Projects')
- mark_filter_as_loaded('Treemap')
- mark_filter_as_loaded('My favourites')
- end
-
- def self.mark_filter_as_loaded(name)
- if Filter.find(:first, :conditions => {:name => name, :user_id => nil})
- unless LoadedTemplate.find(:first, :conditions => {:kee => name, :template_type => 'FILTER'})
- LoadedTemplate.create(:kee => name, :template_type => 'FILTER').save
- end
- end
- end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/360_move_existing_measure_filters.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/360_move_existing_measure_filters.rb
deleted file mode 100644
index e689632f625..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/360_move_existing_measure_filters.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.4
-#
-class MoveExistingMeasureFilters < ActiveRecord::Migration
-
- # the new table
- class MeasureFilter < ActiveRecord::Base
- end
-
- # the old tables
- class FilterColumn < ActiveRecord::Base
- set_table_name 'filter_columns'
- end
- class Criteria < ActiveRecord::Base
- set_table_name 'criteria'
- end
- class Resource < ActiveRecord::Base
- set_table_name 'projects'
- end
- class OldFilter < ActiveRecord::Base
- set_table_name 'filters'
- end
-
- def self.up
- old_filters = OldFilter.find(:all)
- say_with_time "Move #{old_filters.size} measure filters" do
- old_filters.each do |old_filter|
- move(old_filter)
- end
- end
- end
-
- private
-
- def self.move(old_filter)
- new_filter = MeasureFilter.new
- new_filter.name = old_filter.name
- new_filter.user_id = old_filter.user_id
- new_filter.shared = (old_filter.shared || old_filter.user_id.nil?)
- data = []
- data << 'onFavourites=true' if old_filter.favourites
- data << "baseId=#{old_filter.resource_id}" if old_filter.resource_id
- data << "pageSize=#{old_filter.page_size}" if old_filter.page_size
- data << "display=#{old_filter.default_view || 'list'}"
-
- move_columns(old_filter, data)
- move_criteria(old_filter, data)
-
- new_filter.data = data.join('|') unless data.empty?
- new_filter.save
- end
-
- def self.move_columns(old_filter, data)
- columns = []
- metric_columns = []
- asc = nil
- sort = nil
- old_columns = FilterColumn.find(:all, :conditions => ['filter_id=?', old_filter.id], :order => 'order_index')
- old_columns.each do |old_column|
- column_key = old_column.family
- if old_column.kee
- column_key += ":#{old_column.kee}"
- column_key += ":#{old_filter.period_index}" if old_column.variation && old_filter.period_index
- end
- if old_column.family=='metric'
- metric_columns << old_column.kee
- end
- columns << column_key
- if old_column.sort_direction=='ASC'
- asc = true
- sort = column_key
- elsif old_column.sort_direction=='DESC'
- asc = false
- sort = column_key
- end
- end
- if old_filter.default_view=='treemap'
- data << "tmSize=#{metric_columns[0]}" if metric_columns.size>0
- data << "tmColor=#{metric_columns[1]}" if metric_columns.size>1
- else
- data << "cols=#{columns.join(',')}" unless columns.empty?
- if sort
- data << "sort=#{sort}"
- data << "asc=#{asc}"
- end
- end
- end
-
- def self.move_criteria(old_filter, data)
- old_criteria = Criteria.find(:all, :conditions => ['filter_id=?', old_filter.id])
- metric_criteria_id=1
-
- old_criteria.each do |old|
- if old.family=='qualifier' && old.text_value.present?
- data << "qualifiers=#{old.text_value}"
- elsif old.family=='name' && old.text_value.present?
- data << "nameSearch=#{old.text_value}"
- elsif old.family=='key' && old.text_value.present?
- data << "keyRegexp=#{old.text_value}"
- elsif old.family=='language' && old.text_value.present?
- data << "languages=#{old.text_value}"
- elsif old.family=='date' && old.value && old.operator.present?
- data << "ageMaxDays=#{old.value.to_i}" if old.operator=='>='
- data << "ageMinDays=#{old.value.to_i}" if old.operator=='<'
- elsif old.family=='metric' && old.kee && old.operator && old.value
- data << "c#{metric_criteria_id}_metric=#{old.kee}"
- data << "c#{metric_criteria_id}_op=#{operator_code(old.operator)}"
- data << "c#{metric_criteria_id}_val=#{old.value}"
- data << "c#{metric_criteria_id}_period=#{old_filter.period_index}" if old_filter.period_index && (old.variation || old.kee.start_with?('new_'))
- metric_criteria_id += 1
- elsif old.family=='direct-children' && old.text_value=='true'
- data << "onBaseComponents=true"
- end
- end
- end
-
- def self.operator_code(old_operator)
- case old_operator
- when '='
- 'eq'
- when '<'
- 'lt'
- when '<='
- 'lte'
- when '>'
- 'gt'
- when '>='
- 'gte'
- else
- 'eq'
- end
- end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/361_move_filter_widgets.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/361_move_filter_widgets.rb
deleted file mode 100644
index fbb63da4c5c..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/361_move_filter_widgets.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.4
-#
-class MoveFilterWidgets < ActiveRecord::Migration
-
- class MeasureFilter < ActiveRecord::Base
- end
-
- class OldFilter < ActiveRecord::Base
- set_table_name :filters
- end
-
- class Widget < ActiveRecord::Base
- end
-
- class WidgetProperty < ActiveRecord::Base
- end
-
- class Dashboard < ActiveRecord::Base
- end
-
- def self.up
- widgets = Widget.find(:all, :conditions => ["widget_key='filter'"])
- say_with_time "Update #{widgets.size} widgets" do
- widgets.each do |widget|
- dashboard = Dashboard.find_by_id(widget.dashboard_id)
- widget_property = WidgetProperty.find(:first, :conditions => {:widget_id => widget.id, :kee => 'filter'})
- if dashboard && widget_property && widget_property.text_value
- old_filter = OldFilter.find_by_kee(widget_property.text_value)
- if old_filter
- filter = MeasureFilter.find(:first, :conditions => ['name=? and user_id=?', old_filter.name, old_filter.user_id]) if old_filter.user_id
- filter = MeasureFilter.find(:first, :conditions => ['name=? and user_id is null', old_filter.name]) unless filter
- if filter
- widget_property.text_value=filter.id.to_s
- widget_property.save
- widget.widget_key=(filter.data.include?('display=treemap') ? 'measure_filter_treemap' : 'measure_filter_list')
- widget.save
- end
- end
- end
- end
- end
- end
-end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/362_drop_filter_tables.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/362_drop_filter_tables.rb
deleted file mode 100644
index 51c42eb7531..00000000000
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/362_drop_filter_tables.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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 3.4
-#
-class DropFilterTables < ActiveRecord::Migration
-
- def self.up
- drop_table('filter_columns')
- drop_table('criteria')
- drop_table('filters')
- end
-
-end