aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-09 17:22:55 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-12 16:06:20 +0100
commit4ad73a8ade0de8d42b34480d387e77156017929c (patch)
treee0467a793330c880e8b0abbdf9b73a12ed7c2eae /server/sonar-web
parent5dd1589424e001336559168dd702ba73b7fd44ba (diff)
downloadsonarqube-4ad73a8ade0de8d42b34480d387e77156017929c.tar.gz
sonarqube-4ad73a8ade0de8d42b34480d387e77156017929c.zip
SONAR-6262 Add project_links.component_uuid column
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb10
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/project_link.rb2
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/900_add_project_links_component_uuid.rb31
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/901_feed_project_links_component_uuid.rb31
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/902_remove_project_links_project_id.rb31
6 files changed, 102 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
index bed5b3abdf9..255f6355966 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb
@@ -288,18 +288,22 @@ class MeasureFilter < ActiveRecord::Base
if require_links?
project_ids = []
+ project_uuids = []
+ project_id_by_uuid = {}
rows_by_project_id = {}
snapshots.each do |snapshot|
project_ids << snapshot.project_id
+ project_uuids << snapshot.project.uuid
+ project_id_by_uuid[snapshot.project.uuid] = snapshot.project_id
rows_by_project_id[snapshot.project_id] = rows_by_snapshot_id[snapshot.id]
end
links = []
- project_ids.each_slice(999) do |safe_for_oracle_ids|
- links.concat(ProjectLink.all(:conditions => {:project_id => safe_for_oracle_ids}, :order => 'link_type'))
+ project_uuids.each_slice(999) do |safe_for_oracle_uuids|
+ links.concat(ProjectLink.all(:conditions => {:component_uuid => safe_for_oracle_uuids}, :order => 'link_type'))
end
links.each do |link|
- rows_by_project_id[link.project_id].add_link(link)
+ rows_by_project_id[project_id_by_uuid[link.component_uuid]].add_link(link)
end
end
end
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 9b8d332ec12..f8d83a5640b 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
@@ -24,7 +24,7 @@ class Project < ActiveRecord::Base
has_many :snapshots
has_many :processed_snapshots, :class_name => 'Snapshot', :conditions => "status='#{Snapshot::STATUS_PROCESSED}' AND qualifier<>'LIB'", :order => 'created_at asc'
has_many :events, :foreign_key => 'resource_id', :order => 'event_date DESC'
- has_many :project_links, :dependent => :delete_all, :order => 'link_type'
+ 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'
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_link.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_link.rb
index 794722faa18..66bd78f004c 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_link.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_link.rb
@@ -18,7 +18,7 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
class ProjectLink < ActiveRecord::Base
- belongs_to :project
+ belongs_to :project, :foreign_key => 'uuid', :primary_key => 'component_uuid'
LINK_HOMEPAGE = "homepage"
LINK_CONTINUOUS_INTEGRATION = "ci"
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/900_add_project_links_component_uuid.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/900_add_project_links_component_uuid.rb
new file mode 100644
index 00000000000..97da0c9b437
--- /dev/null
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/900_add_project_links_component_uuid.rb
@@ -0,0 +1,31 @@
+#
+# 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-6262
+#
+class AddProjectLinksComponentUuid < ActiveRecord::Migration
+
+ def self.up
+ add_column 'project_links', 'component_uuid', :string, :limit => 50
+ end
+
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/901_feed_project_links_component_uuid.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/901_feed_project_links_component_uuid.rb
new file mode 100644
index 00000000000..e35cedf1125
--- /dev/null
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/901_feed_project_links_component_uuid.rb
@@ -0,0 +1,31 @@
+#
+# 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-6262
+#
+class FeedProjectLinksComponentUuid < ActiveRecord::Migration
+
+ def self.up
+ execute_java_migration('org.sonar.server.db.migrations.v52.FeedProjectLinksComponentUuid')
+ end
+
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/902_remove_project_links_project_id.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/902_remove_project_links_project_id.rb
new file mode 100644
index 00000000000..6130008512e
--- /dev/null
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/902_remove_project_links_project_id.rb
@@ -0,0 +1,31 @@
+#
+# 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-6262
+#
+class RemoveProjectLinksProjectId < ActiveRecord::Migration
+
+ def self.up
+ remove_column 'project_links', 'project_id'
+ end
+
+end