diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-06-26 09:05:43 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-06-26 09:05:43 +0200 |
commit | 163630e0c9de6278cee233e2d79dfd21fbd9c2c0 (patch) | |
tree | 9c3e260877e84fb53042fdfdcec9c8a0050d276c /server/sonar-web/src | |
parent | 68079df6e79b96bead2fd12ae66b1223ca401cbf (diff) | |
download | sonarqube-163630e0c9de6278cee233e2d79dfd21fbd9c2c0.tar.gz sonarqube-163630e0c9de6278cee233e2d79dfd21fbd9c2c0.zip |
SONAR-6634 drop column resource_id from the manual_measures table
Diffstat (limited to 'server/sonar-web/src')
5 files changed, 39 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb index dc76a17b497..645e3a148f6 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb @@ -39,7 +39,7 @@ class ManualMeasuresController < ApplicationController def edit_form @metric=Metric.by_key(params[:metric]) - @measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', @resource.id, @metric.id]) || ManualMeasure.new + @measure=ManualMeasure.find(:first, :conditions => ['component_uuid=? and metric_id=?', @resource.uuid, @metric.id]) || ManualMeasure.new render :partial => 'manual_measures/edit_form' end @@ -74,7 +74,7 @@ class ManualMeasuresController < ApplicationController def edit verify_post_request @metric=Metric.by_key(params[:metric]) - @measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', @resource.id, @metric.id]) + @measure=ManualMeasure.find(:first, :conditions => ['component_uuid=? and metric_id=?', @resource.uuid, @metric.id]) @measure.typed_value=params[:val] @measure.description=params[:desc] @@ -93,7 +93,7 @@ class ManualMeasuresController < ApplicationController def delete verify_post_request metric=Metric.by_key(params[:metric]) - ManualMeasure.destroy_all(['resource_id=? and metric_id=?', @resource.id, metric.id]) + ManualMeasure.destroy_all(['component_uuid=? and metric_id=?', @resource.uuid, metric.id]) flash[:notice] = 'Measure successfully deleted.' redirect_to :action => 'index', :id => params[:id] end @@ -101,6 +101,6 @@ class ManualMeasuresController < ApplicationController private def load_measures - @measures=ManualMeasure.find(:all, :conditions => ['resource_id=?', @resource.id]).select { |m| m.metric.enabled } + @measures=ManualMeasure.find(:all, :conditions => ['component_uuid=?', @resource.uuid]).select { |m| m.metric.enabled } end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/manual_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/manual_measure.rb index 3bc2607c722..9131f0f1e7e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/manual_measure.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/manual_measure.rb @@ -20,8 +20,8 @@ class ManualMeasure < ActiveRecord::Base include ActionView::Helpers::NumberHelper - belongs_to :resource, :class_name => 'Project' - validates_uniqueness_of :metric_id, :scope => :resource_id + belongs_to :resource, :class_name => 'Project', :foreign_key => 'component_uuid', :primary_key => 'uuid' + validates_uniqueness_of :metric_id, :scope => :component_uuid validates_length_of :text_value, :maximum => 4000, :allow_nil => true, :allow_blank => true validates_length_of :description, :maximum => 4000, :allow_nil => true, :allow_blank => true validate :validate_metric, :validate_value diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb index 2c6c8b9cbf7..ad3fd0379ea 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb @@ -27,7 +27,7 @@ class Project < ActiveRecord::Base has_many :project_links, :foreign_key => 'component_uuid', :primary_key => 'uuid', :dependent => :delete_all, :order => 'link_type' has_many :user_roles, :foreign_key => 'resource_id' has_many :group_roles, :foreign_key => 'resource_id' - has_many :manual_measures, :foreign_key => 'resource_id' + has_many :manual_measures, :foreign_key => 'component_uuid', :primary_key => 'uuid' belongs_to :root, :class_name => 'Project', :foreign_key => 'root_id' belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_resource_id' belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id' diff --git a/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb b/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb index 29a2653ff77..098d8cccf9a 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb @@ -4,7 +4,6 @@ ActionController::Routing::Routes.draw do |map| api.resources :user_properties, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ } api.resources :projects, :only => [:index], :requirements => { :id => /.*/ } api.resources :favourites, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ } - api.resources :manual_measures, :only => [:index, :create, :destroy], :requirements => { :id => /.*/ } end map.connect 'api', :controller => 'api/java_ws', :action => 'redirect_to_ws_listing' diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/923_remove_manual_measures_resource_id.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/923_remove_manual_measures_resource_id.rb new file mode 100644 index 00000000000..00d10a2b450 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/923_remove_manual_measures_resource_id.rb @@ -0,0 +1,32 @@ +# +# 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. +# + +# +# SonarQube 5.2 +# SONAR-6634 +# +class RemoveManualMeasuresResourceId < ActiveRecord::Migration + + def self.up + remove_index 'manual_measures', :name => 'manual_measures_resource_id' + remove_column 'manual_measures', 'resource_id' + end + +end |