]> source.dussan.org Git - sonarqube.git/commitdiff
Create Projects and Treemap default dashboards using extension point
authorDavid Gageot <david@gageot.net>
Thu, 24 May 2012 06:22:55 +0000 (08:22 +0200)
committerDavid Gageot <david@gageot.net>
Thu, 24 May 2012 07:34:58 +0000 (09:34 +0200)
12 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectsDashboard.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/TreemapDashboard.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectsDashboardTest.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TimeMachineDashboardTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/TreemapDashboardTest.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql
sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb [new file with mode: 0644]

index c95ebe4777b7d41b82e33bcf7bb657da81812811..559927d6b0d39b6a5fdf1b5e0eaa17a697e52777 100644 (file)
  */
 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 (file)
index 0000000..3483cee
--- /dev/null
@@ -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 (file)
index 0000000..f782704
--- /dev/null
@@ -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
index 76beef5339fdb74c925615829f8bd17d7eda8d97..bc10229498a5b74b1d708360236638929b570ed1 100644 (file)
@@ -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";
index 5b92c98030eb79ad3f42052b788d33a880ef32a0..7e13f5c49951807287b81fc8216b6eeabdfe744c 100644 (file)
  */
 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);
   }
 }
index af6be55c7cb86b51b8d2f9d7ab8ad704b57bbd37..58b6763d95e6e92e8c4e7a1791f811477917a27b 100644 (file)
  */
 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 (file)
index 0000000..613263b
--- /dev/null
@@ -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());
+  }
+}
index 59463ce21f3e84f710687776f13d80bef41d627e..25fc1c297097a4a1c5173cf1d7d846ba37a7e0a7 100644 (file)
  */
 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<Widget> 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 (file)
index 0000000..44bc6c3
--- /dev/null
@@ -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());
+  }
+}
index fd07de5a93ad2c8964003c5ac7b71573cc9424dc..53221061679d4b5cdd83d124bba70df087ea73ac 100644 (file)
@@ -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
index e4bdf209fa0cd0f5bdd36a54a5a217f2ff1792e7..52fd3ebd7b6f0a3efb120beefe1cdddeaf4acb1b 100644 (file)
@@ -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 (file)
index 0000000..75dd8c7
--- /dev/null
@@ -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