aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-05-22 18:27:11 +0200
committerDavid Gageot <david@gageot.net>2012-05-22 19:15:18 +0200
commit97d560cc74dbde31de13cecfe681a8a7c4d6b78d (patch)
tree78a26d39221175ed7c4bb036efedac46b3761882 /plugins
parent1ef7b2e5b9941924a9abdabc32fcd95081e2e66b (diff)
downloadsonarqube-97d560cc74dbde31de13cecfe681a8a7c4d6b78d.tar.gz
sonarqube-97d560cc74dbde31de13cecfe681a8a7c4d6b78d.zip
SONAR-3016 Provide default filters through extension point
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java11
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java53
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java53
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java50
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/MyFavouritesFilterTest.java40
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/ProjectFilterTest.java39
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/TreeMapFilterTest.java39
7 files changed, 285 insertions, 0 deletions
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 b99b1558fe5..c95ebe4777b 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,6 +19,12 @@
*/
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;
@@ -298,6 +304,11 @@ public final class CorePlugin extends SonarPlugin {
extensions.add(TestsViewerDefinition.class);
extensions.add(Lcom4Viewer.class);
+ // filters
+ extensions.add(ProjectFilter.class);
+ extensions.add(TreeMapFilter.class);
+ extensions.add(MyFavouritesFilter.class);
+
// widgets
extensions.add(AlertsWidget.class);
extensions.add(CoverageWidget.class);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java
new file mode 100644
index 00000000000..43e47fa0a36
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.filters;
+
+import org.sonar.api.web.Criterion;
+
+import org.sonar.api.web.Filter;
+import org.sonar.api.web.FilterColumn;
+import org.sonar.api.web.FilterTemplate;
+
+/**
+ * Default myfavourites filter.
+ *
+ * @since 3.1
+ */
+public class MyFavouritesFilter extends FilterTemplate {
+ @Override
+ public String getName() {
+ return "My favouritesBis";
+ }
+
+ @Override
+ public Filter createFilter() {
+ Filter filter = Filter.create();
+ filter.setDisplayAs(Filter.LIST);
+ filter.setFavouritesOnly(true);
+ filter.add(Criterion.create("qualifier", null, Criterion.EQ, "VW,SVW,TRK,BRC,DIR,PAC,FIL,CLA,UTS,LIB", false));
+ filter.add(FilterColumn.create("metric", "alert_status", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
+ filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false));
+
+ return filter;
+ }
+}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java
new file mode 100644
index 00000000000..c5d3086cff4
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.filters;
+
+import org.sonar.api.web.Criterion;
+import org.sonar.api.web.Filter;
+import org.sonar.api.web.FilterColumn;
+import org.sonar.api.web.FilterTemplate;
+
+/**
+ * Default projects filter.
+ *
+ * @since 3.1
+ */
+public class ProjectFilter extends FilterTemplate {
+ @Override
+ public String getName() {
+ return "ProjectsBis";
+ }
+
+ @Override
+ public Filter createFilter() {
+ Filter filter = Filter.create();
+ filter.setDisplayAs(Filter.LIST);
+ filter.add(Criterion.create("qualifier", null, Criterion.EQ, "TRK", false));
+ filter.add(FilterColumn.create("metric", "alert_status", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
+ filter.add(FilterColumn.create("version", null, FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("links", null, FilterColumn.DESC, false));
+
+ return filter;
+ }
+}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java
new file mode 100644
index 00000000000..f921a3c8267
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java
@@ -0,0 +1,50 @@
+/*
+ * 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.filters;
+
+import org.sonar.api.web.Criterion;
+
+import org.sonar.api.web.Filter;
+import org.sonar.api.web.FilterColumn;
+import org.sonar.api.web.FilterTemplate;
+
+/**
+ * Default treemap filter.
+ *
+ * @since 3.1
+ */
+public class TreeMapFilter extends FilterTemplate {
+ @Override
+ public String getName() {
+ return "TreemapBis";
+ }
+
+ @Override
+ public Filter createFilter() {
+ Filter filter = Filter.create();
+ filter.setDisplayAs(Filter.TREEMAP);
+ filter.add(Criterion.create("qualifier", null, Criterion.EQ, "TRK", false));
+ filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false));
+ filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false));
+ filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false));
+
+ return filter;
+ }
+}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/MyFavouritesFilterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/MyFavouritesFilterTest.java
new file mode 100644
index 00000000000..8b3cd981e96
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/MyFavouritesFilterTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.filters;
+
+import org.junit.Test;
+import org.sonar.api.web.Filter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class MyFavouritesFilterTest {
+ @Test
+ public void should_create_filter() {
+ MyFavouritesFilter template = new MyFavouritesFilter();
+
+ Filter filter = template.createFilter();
+
+ assertThat(template.getName()).isEqualTo("My favouritesBis");
+ assertThat(filter).isNotNull();
+ assertThat(filter.isFavouritesOnly()).isTrue();
+ assertThat(filter.getCriteria()).hasSize(1);
+ assertThat(filter.getColumns()).hasSize(5);
+ }
+}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/ProjectFilterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/ProjectFilterTest.java
new file mode 100644
index 00000000000..39196d82a5c
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/ProjectFilterTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.filters;
+
+import org.junit.Test;
+import org.sonar.api.web.Filter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class ProjectFilterTest {
+ @Test
+ public void should_create_filter() {
+ ProjectFilter template = new ProjectFilter();
+
+ Filter filter = template.createFilter();
+
+ assertThat(template.getName()).isEqualTo("ProjectsBis");
+ assertThat(filter).isNotNull();
+ assertThat(filter.getCriteria()).hasSize(1);
+ assertThat(filter.getColumns()).hasSize(7);
+ }
+}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/TreeMapFilterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/TreeMapFilterTest.java
new file mode 100644
index 00000000000..c6c13695830
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/filters/TreeMapFilterTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.filters;
+
+import org.junit.Test;
+import org.sonar.api.web.Filter;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class TreeMapFilterTest {
+ @Test
+ public void should_create_filter() {
+ TreeMapFilter template = new TreeMapFilter();
+
+ Filter filter = template.createFilter();
+
+ assertThat(template.getName()).isEqualTo("TreemapBis");
+ assertThat(filter).isNotNull();
+ assertThat(filter.getCriteria()).hasSize(1);
+ assertThat(filter.getColumns()).hasSize(3);
+ }
+}