*/
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;
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;
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);
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
@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";
*/
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);
}
}
*/
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);
}
}
--- /dev/null
+/*
+ * 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());
+ }
+}
*/
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");
}
}
}
--- /dev/null
+/*
+ * 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());
+ }
+}
*/
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
-- 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');
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;
--- /dev/null
+#
+# 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