aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-05-29 10:24:04 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-05-29 16:26:35 +0200
commitebc7ebb5c530d1de13a79cb3f2d873af89f37efb (patch)
tree4f5f89626ff3444c75b49fd5bb7f94caa4685d1c /sonar-plugin-api
parentbcb214c6b92e4930d9b0de4a0e18bd60fc483e98 (diff)
downloadsonarqube-ebc7ebb5c530d1de13a79cb3f2d873af89f37efb.tar.gz
sonarqube-ebc7ebb5c530d1de13a79cb3f2d873af89f37efb.zip
SONAR-3755 replace the enum IssueQuery.Sort by String constants
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java28
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java4
3 files changed, 23 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
index 26a2cbd7123..761c2b8294f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
@@ -20,15 +20,16 @@
package org.sonar.api.issue;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.web.UserRole;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Collection;
import java.util.Date;
+import java.util.Set;
/**
* @since 3.6
@@ -41,9 +42,13 @@ public class IssueQuery {
public static final int MAX_PAGE_SIZE = 500;
public static final int MAX_ISSUE_KEYS = 500;
- public static enum Sort {
- CREATION_DATE, UPDATE_DATE, CLOSE_DATE, ASSIGNEE, SEVERITY, STATUS
- }
+ public static final String SORT_BY_CREATION_DATE = "CREATION_DATE";
+ public static final String SORT_BY_UPDATE_DATE = "UPDATE_DATE";
+ public static final String SORT_BY_CLOSE_DATE = "CLOSE_DATE";
+ public static final String SORT_BY_ASSIGNEE = "ASSIGNEE";
+ public static final String SORT_BY_SEVERITY = "SEVERITY";
+ public static final String SORT_BY_STATUS = "STATUS";
+ public static final Set<String> SORTS = ImmutableSet.of(SORT_BY_CREATION_DATE, SORT_BY_UPDATE_DATE, SORT_BY_CLOSE_DATE, SORT_BY_ASSIGNEE, SORT_BY_SEVERITY, SORT_BY_STATUS);
private final Collection<String> issueKeys;
private final Collection<String> severities;
@@ -60,7 +65,7 @@ public class IssueQuery {
private final Boolean resolved;
private final Date createdAfter;
private final Date createdBefore;
- private final Sort sort;
+ private final String sort;
private final Boolean asc;
private final String requiredRole;
@@ -159,7 +164,7 @@ public class IssueQuery {
}
@CheckForNull
- public Sort sort() {
+ public String sort() {
return sort;
}
@@ -209,7 +214,7 @@ public class IssueQuery {
private Boolean resolved = null;
private Date createdAfter;
private Date createdBefore;
- private Sort sort;
+ private String sort;
private Boolean asc = false;
private Integer pageSize;
private Integer pageIndex;
@@ -305,8 +310,11 @@ public class IssueQuery {
return this;
}
- public Builder sort(@Nullable Sort sort) {
- this.sort = sort;
+ public Builder sort(@Nullable String s) {
+ if (s != null && !SORTS.contains(s)) {
+ throw new IllegalArgumentException("Bad sort field: " + s);
+ }
+ this.sort = s;
return this;
}
@@ -345,7 +353,7 @@ public class IssueQuery {
} else {
if (pageSize == null) {
pageSize = DEFAULT_PAGE_SIZE;
- } else if (pageSize<=0 || pageSize > MAX_PAGE_SIZE) {
+ } else if (pageSize <= 0 || pageSize > MAX_PAGE_SIZE) {
pageSize = MAX_PAGE_SIZE;
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java
index dd716651c38..458f123541f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java
@@ -56,8 +56,9 @@ public interface RubyIssueService extends ServerComponent {
* <li>'assigned': true to get only assigned issues, false to get only unassigned issues. By default no filtering is done.</li>
* <li>'createdAfter': match all the issues created after the given date (inclusive). Both date and datetime ISO formats are supported: 2013-05-18 or 2010-05-18T15:50:45+0100</li>
* <li>'createdBefore': match all the issues created before the given date (exclusive). Both date and datetime ISO formats are supported: 2013-05-18 or 2010-05-18T15:50:45+0100</li>
- * <li>'pageSize': TODO</li>
- * <li>'pageIndex': TODO</li>
+ * <li>'pageSize': maximum number of results per page. Default is {@link org.sonar.api.issue.IssueQuery#DEFAULT_PAGE_SIZE},
+ * except when the parameter 'components' is set. In this case there's no limit by default (all results in the same page).</li>
+ * <li>'pageIndex': index of the selected page. Default is 1.</li>
* <li>'sort': TODO</li>
* <li>'asc': TODO </li>
* </ul>
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
index fb972c40cee..5792dc0f63a 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
@@ -49,7 +49,7 @@ public class IssueQueryTest {
.assigned(true)
.createdAfter(new Date())
.createdBefore(new Date())
- .sort(IssueQuery.Sort.ASSIGNEE)
+ .sort(IssueQuery.SORT_BY_ASSIGNEE)
.pageSize(10)
.pageIndex(2)
.requiredRole(UserRole.CODEVIEWER)
@@ -67,7 +67,7 @@ public class IssueQueryTest {
assertThat(query.actionPlans()).containsOnly("AP1", "AP2");
assertThat(query.createdAfter()).isNotNull();
assertThat(query.createdBefore()).isNotNull();
- assertThat(query.sort()).isEqualTo(IssueQuery.Sort.ASSIGNEE);
+ assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_ASSIGNEE);
assertThat(query.pageSize()).isEqualTo(10);
assertThat(query.pageIndex()).isEqualTo(2);
assertThat(query.requiredRole()).isEqualTo(UserRole.CODEVIEWER);