From: David Gageot Date: Thu, 24 May 2012 06:22:55 +0000 (+0200) Subject: Create Projects and Treemap default dashboards using extension point X-Git-Tag: 3.1~88 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d9538939baa6cd86340505da1f4283ac12a94cb8;p=sonarqube.git Create Projects and Treemap default dashboards using extension point --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index c95ebe4777b..559927d6b0d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -19,12 +19,6 @@ */ package org.sonar.plugins.core; -import org.sonar.plugins.core.filters.MyFavouritesFilter; - -import org.sonar.plugins.core.filters.TreeMapFilter; - -import org.sonar.plugins.core.filters.ProjectFilter; - import com.google.common.collect.Lists; import org.sonar.api.CoreProperties; import org.sonar.api.Extension; @@ -44,8 +38,13 @@ import org.sonar.plugins.core.charts.XradarChart; import org.sonar.plugins.core.colorizers.JavaColorizerFormat; import org.sonar.plugins.core.dashboards.DefaultDashboard; import org.sonar.plugins.core.dashboards.HotspotsDashboard; +import org.sonar.plugins.core.dashboards.ProjectsDashboard; import org.sonar.plugins.core.dashboards.ReviewsDashboard; import org.sonar.plugins.core.dashboards.TimeMachineDashboard; +import org.sonar.plugins.core.dashboards.TreemapDashboard; +import org.sonar.plugins.core.filters.MyFavouritesFilter; +import org.sonar.plugins.core.filters.ProjectFilter; +import org.sonar.plugins.core.filters.TreeMapFilter; import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; import org.sonar.plugins.core.sensors.BranchCoverageDecorator; import org.sonar.plugins.core.sensors.CheckAlertThresholds; @@ -341,6 +340,8 @@ public final class CorePlugin extends SonarPlugin { extensions.add(HotspotsDashboard.class); extensions.add(ReviewsDashboard.class); extensions.add(TimeMachineDashboard.class); + extensions.add(ProjectsDashboard.class); + extensions.add(TreemapDashboard.class); // chart extensions.add(XradarChart.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectsDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectsDashboard.java new file mode 100644 index 00000000000..3483cee4866 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectsDashboard.java @@ -0,0 +1,52 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * 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 + */ +package org.sonar.plugins.core.dashboards; + +import org.sonar.plugins.core.widgets.FilterWidget; + +import org.sonar.api.web.Dashboard.Widget; + +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; + +/** + * Projects global dashboard for Sonar + * + * @since 3.1 + */ +public final class ProjectsDashboard extends DashboardTemplate { + @Override + public String getName() { + return "Projects"; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create(); + dashboard.setGlobal(true); + dashboard.setLayout(DashboardLayout.ONE_COLUMN); + + Widget filterWidget = dashboard.addWidget("filter", 1); + filterWidget.setProperty(FilterWidget.FILTER, "Projects"); + + return dashboard; + } +} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/TreemapDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/TreemapDashboard.java new file mode 100644 index 00000000000..f782704c4eb --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/TreemapDashboard.java @@ -0,0 +1,52 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * 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 + */ +package org.sonar.plugins.core.dashboards; + +import org.sonar.plugins.core.widgets.FilterWidget; + +import org.sonar.api.web.Dashboard.Widget; + +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.api.web.DashboardTemplate; + +/** + * Treemap global dashboard for Sonar + * + * @since 3.1 + */ +public final class TreemapDashboard extends DashboardTemplate { + @Override + public String getName() { + return "Treemap"; + } + + @Override + public Dashboard createDashboard() { + Dashboard dashboard = Dashboard.create(); + dashboard.setGlobal(true); + dashboard.setLayout(DashboardLayout.ONE_COLUMN); + + Widget filterWidget = dashboard.addWidget("filter", 1); + filterWidget.setProperty(FilterWidget.FILTER, "Treemap"); + + return dashboard; + } +} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java index 76beef5339f..bc10229498a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java @@ -32,9 +32,10 @@ import static org.sonar.api.web.WidgetScope.*; @WidgetCategory({"Filters", "Global"}) @WidgetScope(GLOBAL) @WidgetProperties({ - @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, optional = false) + @WidgetProperty(key = FilterWidget.FILTER, type = WidgetPropertyType.FILTER, optional = false) }) public class FilterWidget extends AbstractRubyTemplate implements RubyRailsWidget { + public static final String FILTER = "filter"; public String getId() { return "filter"; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java index 5b92c98030e..7e13f5c4995 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java @@ -19,20 +19,31 @@ */ package org.sonar.plugins.core.dashboards; -import org.hamcrest.core.Is; import org.junit.Test; import org.sonar.api.web.Dashboard; import org.sonar.api.web.DashboardLayout; +import org.sonar.plugins.core.CorePlugin; -import static org.junit.Assert.assertThat; +import static org.fest.assertions.Assertions.assertThat; public class DefaultDashboardTest { + DefaultDashboard template = new DefaultDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Dashboard"); + } + @Test - public void shouldCreateDashboard() { - DefaultDashboard template = new DefaultDashboard(); + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + + @Test + public void should_create_dashboard() { Dashboard dashboard = template.createDashboard(); - assertThat(template.getName(), Is.is("Dashboard")); - assertThat(dashboard.getLayout(), Is.is(DashboardLayout.TWO_COLUMNS)); - assertThat(dashboard.getWidgets().size(), Is.is(11)); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(11); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java index af6be55c7cb..58b6763d95e 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java @@ -19,20 +19,31 @@ */ package org.sonar.plugins.core.dashboards; -import org.hamcrest.core.Is; import org.junit.Test; import org.sonar.api.web.Dashboard; import org.sonar.api.web.DashboardLayout; +import org.sonar.plugins.core.CorePlugin; -import static org.junit.Assert.assertThat; +import static org.fest.assertions.Assertions.assertThat; public class HotspotsDashboardTest { + HotspotsDashboard template = new HotspotsDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Hotspots"); + } + @Test - public void shouldCreateDashboard() { - HotspotsDashboard template = new HotspotsDashboard(); - Dashboard hotspots = template.createDashboard(); - assertThat(template.getName(), Is.is("Hotspots")); - assertThat(hotspots.getLayout(), Is.is(DashboardLayout.TWO_COLUMNS)); - assertThat(hotspots.getWidgets().size(), Is.is(8)); + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + + @Test + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(8); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectsDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectsDashboardTest.java new file mode 100644 index 00000000000..613263b3434 --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectsDashboardTest.java @@ -0,0 +1,55 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * 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 + */ +package org.sonar.plugins.core.dashboards; + +import org.sonar.plugins.core.CorePlugin; + +import com.google.common.collect.Iterables; +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.Dashboard.Widget; +import org.sonar.plugins.core.filters.ProjectFilter; +import org.sonar.plugins.core.widgets.FilterWidget; + +import static org.fest.assertions.Assertions.assertThat; + +public class ProjectsDashboardTest { + ProjectsDashboard template = new ProjectsDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Projects"); + } + + @Test + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + + @Test + public void should_create_global_dashboard_with_one_filter() { + Dashboard dashboard = template.createDashboard(); + Widget widget = Iterables.getOnlyElement(dashboard.getWidgets()); + + assertThat(dashboard.isGlobal()).isTrue(); + assertThat(widget.getId()).isEqualTo(new FilterWidget().getId()); + assertThat(widget.getProperty("filter")).isEqualTo(new ProjectFilter().getName()); + } +} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TimeMachineDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TimeMachineDashboardTest.java index 59463ce21f3..25fc1c29709 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TimeMachineDashboardTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TimeMachineDashboardTest.java @@ -19,28 +19,37 @@ */ package org.sonar.plugins.core.dashboards; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -import java.util.Collection; - import org.junit.Test; import org.sonar.api.web.Dashboard; import org.sonar.api.web.Dashboard.Widget; import org.sonar.api.web.DashboardLayout; +import org.sonar.plugins.core.CorePlugin; + +import static org.fest.assertions.Assertions.assertThat; public class TimeMachineDashboardTest { + TimeMachineDashboard template = new TimeMachineDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("TimeMachine"); + } + + @Test + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + @Test - public void shouldCreateDashboard() { - TimeMachineDashboard template = new TimeMachineDashboard(); - Dashboard hotspots = template.createDashboard(); - assertThat(template.getName(), is("TimeMachine")); - assertThat(hotspots.getLayout(), is(DashboardLayout.TWO_COLUMNS)); - Collection widgets = hotspots.getWidgets(); - assertThat(widgets.size(), is(7)); - for (Widget widget : widgets) { + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(7); + + for (Widget widget : dashboard.getWidgets()) { if (widget.getId().equals("time_machine")) { - assertThat(widget.getProperty("displaySparkLine"), is("true")); + assertThat(widget.getProperty("displaySparkLine")).isEqualTo("true"); } } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TreemapDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TreemapDashboardTest.java new file mode 100644 index 00000000000..44bc6c34b17 --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TreemapDashboardTest.java @@ -0,0 +1,55 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * 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 + */ +package org.sonar.plugins.core.dashboards; + +import org.sonar.plugins.core.CorePlugin; + +import com.google.common.collect.Iterables; +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.Dashboard.Widget; +import org.sonar.plugins.core.filters.TreeMapFilter; +import org.sonar.plugins.core.widgets.FilterWidget; + +import static org.fest.assertions.Assertions.assertThat; + +public class TreemapDashboardTest { + TreemapDashboard template = new TreemapDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Treemap"); + } + + @Test + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + + @Test + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + Widget widget = Iterables.getOnlyElement(dashboard.getWidgets()); + + assertThat(dashboard.isGlobal()).isTrue(); + assertThat(widget.getId()).isEqualTo(new FilterWidget().getId()); + assertThat(widget.getProperty("filter")).isEqualTo(new TreeMapFilter().getName()); + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index fd07de5a93a..53221061679 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -35,7 +35,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 304; + public static final int LAST_VERSION = 305; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql index e4bdf209fa0..52fd3ebd7b6 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql @@ -1,23 +1,13 @@ -- All the rows inserted during Rails migrations. Rows inserted during server startup tasks (Java) are excluded : rules, profiles, metrics, ... -INSERT INTO DASHBOARDS(ID, USER_ID, NAME, DESCRIPTION, COLUMN_LAYOUT, SHARED, IS_GLOBAL) VALUES (1, null, 'Projects', null, '100%', true, true); -INSERT INTO DASHBOARDS(ID, USER_ID, NAME, DESCRIPTION, COLUMN_LAYOUT, SHARED, IS_GLOBAL) VALUES (2, null, 'Treemap', null, '100%', true, true); -INSERT INTO DASHBOARDS(ID, USER_ID, NAME, DESCRIPTION, COLUMN_LAYOUT, SHARED, IS_GLOBAL) VALUES (3, null, 'My favourites', null, '100%', true, true); -ALTER TABLE DASHBOARDS ALTER COLUMN ID RESTART WITH 4; - -INSERT INTO ACTIVE_DASHBOARDS(ID, DASHBOARD_ID, USER_ID, ORDER_INDEX) VALUES (1, 1, null, 1); -INSERT INTO ACTIVE_DASHBOARDS(ID, DASHBOARD_ID, USER_ID, ORDER_INDEX) VALUES (2, 2, null, 2); -ALTER TABLE ACTIVE_DASHBOARDS ALTER COLUMN ID RESTART WITH 3; +INSERT INTO DASHBOARDS(ID, USER_ID, NAME, DESCRIPTION, COLUMN_LAYOUT, SHARED, IS_GLOBAL) VALUES (1, null, 'My favourites', null, '100%', true, true); +ALTER TABLE DASHBOARDS ALTER COLUMN ID RESTART WITH 2; INSERT INTO WIDGETS(ID, DASHBOARD_ID, WIDGET_KEY, NAME, DESCRIPTION, COLUMN_INDEX, ROW_INDEX, CONFIGURED, RESOURCE_ID) VALUES (1, 1, 'filter', 'Filter', null, 1, 1, true , null); -INSERT INTO WIDGETS(ID, DASHBOARD_ID, WIDGET_KEY, NAME, DESCRIPTION, COLUMN_INDEX, ROW_INDEX, CONFIGURED, RESOURCE_ID) VALUES (2, 2, 'filter', 'Filter', null, 1, 1, true , null); -INSERT INTO WIDGETS(ID, DASHBOARD_ID, WIDGET_KEY, NAME, DESCRIPTION, COLUMN_INDEX, ROW_INDEX, CONFIGURED, RESOURCE_ID) VALUES (3, 3, 'filter', 'Filter', null, 1, 1, true , null); -ALTER TABLE WIDGETS ALTER COLUMN ID RESTART WITH 4; +ALTER TABLE WIDGETS ALTER COLUMN ID RESTART WITH 2; -INSERT INTO WIDGET_PROPERTIES(ID, WIDGET_ID, KEE, TEXT_VALUE) VALUES (1, 1, 'filter', 'Projects'); -INSERT INTO WIDGET_PROPERTIES(ID, WIDGET_ID, KEE, TEXT_VALUE) VALUES (2, 2, 'filter', 'Treemap'); -INSERT INTO WIDGET_PROPERTIES(ID, WIDGET_ID, KEE, TEXT_VALUE) VALUES (3, 3, 'filter', 'My favourites'); -ALTER TABLE WIDGET_PROPERTIES ALTER COLUMN ID RESTART WITH 4; +INSERT INTO WIDGET_PROPERTIES(ID, WIDGET_ID, KEE, TEXT_VALUE) VALUES (1, 1, 'filter', 'My favourites'); +ALTER TABLE WIDGET_PROPERTIES ALTER COLUMN ID RESTART WITH 2; INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (1, 1, null, 'admin'); INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'default-admin'); @@ -179,6 +169,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('301'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('302'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('303'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('304'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('305'); 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; diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb new file mode 100644 index 00000000000..75dd8c7a7be --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb @@ -0,0 +1,43 @@ +# +# Sonar, open source software quality management tool. +# Copyright (C) 2008-2012 SonarSource +# 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 3.1 +# +class IgnoreLoadedDashboards < ActiveRecord::Migration + class Dashboard < ActiveRecord::Base + end + + class LoadedTemplate < ActiveRecord::Base + end + + def self.up + mark_dashboard_as_loaded('Projects') + mark_dashboard_as_loaded('Treemap') + end + + def self.mark_dashboard_as_loaded(name) + if Dashboard.find(:first, :conditions => {:name => name, :user_id => nil}) + unless LoadedTemplate.find(:first, :conditions => {:kee => name, :template_type => 'DASHBOARD'}) + LoadedTemplate.create(:kee => name, :template_type => 'DASHBOARD').save + end + end + end +end