aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-01-31 16:38:09 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-02-01 14:13:03 +0100
commitf294cc4de25fd978a8d532283078852a7fb2830e (patch)
tree2309c0687f87c4bd36b9f1c851a3f4bde307049e /sonar-plugin-api
parent62e070ba1bbdd436914a02a790ab541644063d90 (diff)
downloadsonarqube-f294cc4de25fd978a8d532283078852a7fb2830e.tar.gz
sonarqube-f294cc4de25fd978a8d532283078852a7fb2830e.zip
SONAR-6395 Remove measure filter extension point
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java161
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java101
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/FilterTemplate.java45
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/web/FilterColumnTest.java44
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/web/FilterTest.java101
5 files changed, 0 insertions, 452 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java
deleted file mode 100644
index dbc6c68fcbd..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-package org.sonar.api.web;
-
-import com.google.common.base.Preconditions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Definition of a filter.
- *
- * <p>Its name can be retrieved using the i18n mechanism, using the keys "filter.&lt;id&gt;.name".
- *
- * @since 3.1
- */
-public final class Filter {
- public static final String LIST = "list";
- public static final String TREEMAP = "treemap";
-
- private boolean favouritesOnly;
- private String displayAs;
- private int pageSize;
- private List<Criterion> criteria;
- private List<FilterColumn> columns;
-
- private Filter() {
- displayAs = LIST;
- criteria = new ArrayList<>();
- columns = new ArrayList<>();
- }
-
- /**
- * Creates a new {@link Filter}.
- */
- public static Filter create() {
- return new Filter();
- }
-
- /**
- * Get the list of {@link Criterion} used to narrow down the results of this {@link Filter}.
- *
- * @return the criteria
- */
- public List<Criterion> getCriteria() {
- return criteria;
- }
-
- /**
- * Add a {@link Criterion} to the list used to narrow down the results of this {@link Filter}.
- *
- * @return this filter
- */
- public Filter add(Criterion criterion) {
- this.criteria.add(criterion);
- return this;
- }
-
- /**
- * Get the list of {@link FilterColumn} displayed by this {@link Filter}.
- *
- * @return this columns
- */
- public List<FilterColumn> getColumns() {
- return columns;
- }
-
- /**
- * Add a {@link FilterColumn} to the list of columns displayed by this {@link Filter}.
- *
- * @return this filter
- */
- public Filter add(FilterColumn column) {
- this.columns.add(column);
- return this;
- }
-
- /**
- * The {@link Filter} can be configured to return only favourites.
- *
- * @return <code>true</code> if favourites only are returned
- */
- public boolean isFavouritesOnly() {
- return favouritesOnly;
- }
-
- /**
- * The {@link Filter} can be configured to return only favourites.
- */
- public Filter setFavouritesOnly(boolean favouritesOnly) {
- this.favouritesOnly = favouritesOnly;
- return this;
- }
-
- /**
- * Get the type of display used by this {@link Filter}.
- *
- * <p>Can be either {@code #LIST} or {@code #TREEMAP}
- *
- * @return the display type
- */
- public String getDisplayAs() {
- return displayAs;
- }
-
- /**
- * Set the type of display used by this {@link Filter}.
- *
- * <p>Can be either {@code #LIST} or {@code #TREEMAP}
- *
- * @return this filter
- * @throws IllegalArgumentException if {@code displayAs} is not {@code #LIST} or {@code #TREEMAP}
- */
- public Filter setDisplayAs(String displayAs) {
- Preconditions.checkArgument(LIST.equals(displayAs) || TREEMAP.equals(displayAs), "Default display should be either %s or %s, not %s", LIST, TREEMAP, displayAs);
- this.displayAs = displayAs;
- return this;
- }
-
- /**
- * Get the size of a page displayed this {@link Filter}.
- *
- * <p>The page size is between <code>20</code> and <code>200</code> (included)
- *
- * @return the display type
- */
- public int getPageSize() {
- return pageSize;
- }
-
- /**
- * Set the size of a page displayed this {@link Filter}.
- *
- * <p>The page size should be between <code>20</code> and <code>200</code> (included)
- *
- * @return the display type
- * @throws IllegalArgumentException if {@code pageSize} is not lower than {@code 20} or greater than {@code 200}
- */
- public Filter setPageSize(int pageSize) {
- Preconditions.checkArgument((pageSize >= 20) && (pageSize <= 200), "page size should be between 20 and 200");
- this.pageSize = pageSize;
- return this;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java
deleted file mode 100644
index b95e3dfcaf9..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterColumn.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-package org.sonar.api.web;
-
-import com.google.common.collect.ImmutableSortedSet;
-
-import java.util.Set;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Definition of a {@link Filter} column.
- *
- * @since 3.1
- */
-public final class FilterColumn {
- public static final String ASC = "ASC";
- public static final String DESC = "DESC";
- public static final Set<String> DIRECTIONS = ImmutableSortedSet.of(ASC, DESC);
-
- private final String family;
- private final String key;
- private final String sortDirection;
- private final boolean variation;
-
- private FilterColumn(String family, String key, String sortDirection, boolean variation) {
- Preconditions.checkArgument(DIRECTIONS.contains(sortDirection), "Valid directions are %s, not '%s'", DIRECTIONS, sortDirection);
-
- this.family = family;
- this.key = key;
- this.sortDirection = sortDirection;
- this.variation = variation;
- }
-
- /**
- * Creates a new {@link FilterColumn}.
- *
- * <p>Valid values for the {@code sortDirection} are {@code #ASC}, {@code #DESC}
- *
- * <p>When the @{see Filter} is persisted, a validation is made on the {@code family} and the {@code key}.
- * They should point to a valid column description.
- *
- * @throws IllegalArgumentException if {@code sortDirection} is not valid
- */
- public static FilterColumn create(String family, String key, String sortDirection, boolean variation) {
- return new FilterColumn(family, key, sortDirection, variation);
- }
-
- /**
- * Get the the column's family.
- *
- * @return the family
- */
- public String getFamily() {
- return family;
- }
-
- /**
- * Get the the column's key.
- *
- * @return the key
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Get the the column's sort direction.
- *
- * @return the sort direction
- */
- public String getSortDirection() {
- return sortDirection;
- }
-
- /**
- * A column can be based on the variation of a value rather than on the value itself.
- *
- * @return <code>true</code> when the variation is used rather than the value
- */
- public boolean isVariation() {
- return variation;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterTemplate.java
deleted file mode 100644
index 67e106d9069..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/FilterTemplate.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-package org.sonar.api.web;
-
-import org.sonar.api.ExtensionPoint;
-import org.sonar.api.server.ServerSide;
-
-/**
- * This extension point must be implemented to define a new filter.
- *
- * @since 3.1
- */
-@ServerSide
-@ExtensionPoint
-public abstract class FilterTemplate {
-
- /**
- * Returns the {@link Filter} object that represents the filter to use.
- *
- * @return the filter
- */
- public abstract Filter createFilter();
-
- /**
- * Filter name
- */
- public abstract String getName();
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterColumnTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterColumnTest.java
deleted file mode 100644
index 4922ebe1c85..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterColumnTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-package org.sonar.api.web;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class FilterColumnTest {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @Test
- public void should_accept_valid_direction() {
- FilterColumn.create("", "", "ASC", false);
- FilterColumn.create("", "", "DESC", false);
- }
-
- @Test
- public void should_fail_on_invalid_direction() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Valid directions are [ASC, DESC], not 'UNKNOWN'");
-
- FilterColumn.create("", "", "UNKNOWN", false);
- }
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterTest.java
deleted file mode 100644
index 2c867b8fbbb..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/web/FilterTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-package org.sonar.api.web;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class FilterTest {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @Test
- public void should_create_filter() {
- Filter filter = Filter.create()
- .setDisplayAs("list")
- .setFavouritesOnly(true)
- .setPageSize(100);
-
- assertThat(filter.getDisplayAs()).isEqualTo("list");
- assertThat(filter.isFavouritesOnly()).isTrue();
- assertThat(filter.getPageSize()).isEqualTo(100);
- }
-
- @Test
- public void should_add_criteria() {
- Criterion criterion1 = Criterion.createForQualifier("A");
- Criterion criterion2 = Criterion.createForQualifier("A");
- Filter filter = Filter.create()
- .add(criterion1)
- .add(criterion2);
-
- assertThat(filter.getCriteria()).containsExactly(criterion1, criterion2);
- }
-
- @Test
- public void should_add_columns() {
- FilterColumn column1 = FilterColumn.create("", "", "ASC", false);
- FilterColumn column2 = FilterColumn.create("", "", "DESC", false);
- Filter filter = Filter.create()
- .add(column1)
- .add(column2);
-
- assertThat(filter.getColumns()).containsExactly(column1, column2);
- }
-
- @Test
- public void should_accept_valid_periods() {
- Filter.create().setDisplayAs("list");
- Filter.create().setDisplayAs("treemap");
- }
-
- @Test
- public void should_fail_on_invalid_display() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Default display should be either list or treemap, not <invalid>");
-
- Filter.create().setDisplayAs("<invalid>");
- }
-
- @Test
- public void should_accept_valid_pageSize() {
- Filter.create().setPageSize(20);
- Filter.create().setPageSize(200);
- }
-
- @Test
- public void should_fail_on_pageSize_too_small() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("page size should be between 20 and 200");
-
- Filter.create().setPageSize(19);
- }
-
- @Test
- public void should_fail_on_pageSize_too_high() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("page size should be between 20 and 200");
-
- Filter.create().setPageSize(201);
- }
-}