aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-01-05 10:18:00 +0100
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-01-05 16:31:59 +0100
commit37d8bac5160f084c7ecb68efa4e0189eb0d03530 (patch)
tree47f1f93fbf3487eb979050e719999c869b4585b5 /server
parent71a2b3021fba98efd17c2fed4fbe9b7ac1d2b666 (diff)
downloadsonarqube-37d8bac5160f084c7ecb68efa4e0189eb0d03530.tar.gz
sonarqube-37d8bac5160f084c7ecb68efa4e0189eb0d03530.zip
SONAR-5959 Add onComponentOnly parameter to IssueQuery
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java3
3 files changed, 21 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java
index 4d831e6f9df..8bb030b3628 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java
@@ -66,6 +66,7 @@ public class IssueQuery {
private final Collection<String> assignees;
private final Collection<String> languages;
private final Collection<String> tags;
+ private final Boolean onComponentOnly;
private final Boolean assigned;
private final Boolean planned;
private final Boolean resolved;
@@ -91,6 +92,7 @@ public class IssueQuery {
this.assignees = defaultCollection(builder.assignees);
this.languages = defaultCollection(builder.languages);
this.tags = defaultCollection(builder.tags);
+ this.onComponentOnly = builder.onComponentOnly;
this.assigned = builder.assigned;
this.planned = builder.planned;
this.resolved = builder.resolved;
@@ -156,6 +158,11 @@ public class IssueQuery {
}
@CheckForNull
+ public Boolean onComponentOnly() {
+ return onComponentOnly;
+ }
+
+ @CheckForNull
public Boolean assigned() {
return assigned;
}
@@ -231,6 +238,7 @@ public class IssueQuery {
private Collection<String> assignees;
private Collection<String> languages;
private Collection<String> tags;
+ private Boolean onComponentOnly = false;
private Boolean assigned = null;
private Boolean planned = null;
private Boolean resolved = null;
@@ -311,6 +319,15 @@ public class IssueQuery {
}
/**
+ * If true, it will return only issues on the passed component(s)
+ * If false, it will return all issues on the passed component(s) and their descendants
+ */
+ public Builder onComponentOnly(@Nullable Boolean b) {
+ this.onComponentOnly = b;
+ return this;
+ }
+
+ /**
* If true, it will return all issues assigned to someone
* If false, it will return all issues not assigned to someone
*/
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
index e3759cdf7a1..28bb75ae3a0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
@@ -74,6 +74,7 @@ public class IssueQueryService implements ServerComponent {
.assignees(RubyUtils.toStrings(params.get(IssueFilterParameters.ASSIGNEES)))
.languages(RubyUtils.toStrings(params.get(IssueFilterParameters.LANGUAGES)))
.tags(RubyUtils.toStrings(params.get(IssueFilterParameters.TAGS)))
+ .onComponentOnly(RubyUtils.toBoolean(params.get(IssueFilterParameters.ON_COMPONENT_ONLY)))
.assigned(RubyUtils.toBoolean(params.get(IssueFilterParameters.ASSIGNED)))
.planned(RubyUtils.toBoolean(params.get(IssueFilterParameters.PLANNED)))
.hideRules(RubyUtils.toBoolean(params.get(IssueFilterParameters.HIDE_RULES)))
@@ -140,6 +141,7 @@ public class IssueQueryService implements ServerComponent {
.assignees(request.paramAsStrings(IssueFilterParameters.ASSIGNEES))
.languages(request.paramAsStrings(IssueFilterParameters.LANGUAGES))
.tags(request.paramAsStrings(IssueFilterParameters.TAGS))
+ .onComponentOnly(request.paramAsBoolean(IssueFilterParameters.ON_COMPONENT_ONLY))
.assigned(request.paramAsBoolean(IssueFilterParameters.ASSIGNED))
.planned(request.paramAsBoolean(IssueFilterParameters.PLANNED))
.createdAt(request.paramAsDateTime(IssueFilterParameters.CREATED_AT))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
index 2f524b4f1a6..2fb0839f50a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
@@ -29,7 +29,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.DateUtils;
-import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.DbSession;
import org.sonar.server.component.ComponentService;
import org.sonar.server.component.db.ComponentDao;
@@ -98,6 +97,7 @@ public class IssueQueryServiceTest {
map.put("assignees", newArrayList("joanna"));
map.put("languages", newArrayList("xoo"));
map.put("tags", newArrayList("tag1", "tag2"));
+ map.put("onComponentOnly", true);
map.put("assigned", true);
map.put("planned", true);
map.put("hideRules", true);
@@ -122,6 +122,7 @@ public class IssueQueryServiceTest {
assertThat(query.assignees()).containsOnly("joanna");
assertThat(query.languages()).containsOnly("xoo");
assertThat(query.tags()).containsOnly("tag1", "tag2");
+ assertThat(query.onComponentOnly()).isTrue();
assertThat(query.assigned()).isTrue();
assertThat(query.planned()).isTrue();
assertThat(query.hideRules()).isTrue();