aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/java/org
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-27 09:28:59 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-30 14:53:24 +0100
commit1667ff43142ce1dedcf716f62734bf64264349d1 (patch)
tree6d6290b72268193945538417bd7e36f3c00d2040 /sonar-db/src/main/java/org
parent7a1e3ddaf9765e51e48bd1fc454ffb33b0cbde06 (diff)
downloadsonarqube-1667ff43142ce1dedcf716f62734bf64264349d1.tar.gz
sonarqube-1667ff43142ce1dedcf716f62734bf64264349d1.zip
SONAR-8648 add organization parameter to api/components/search
Diffstat (limited to 'sonar-db/src/main/java/org')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java29
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java4
2 files changed, 26 insertions, 7 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
index 9880e51467f..d475e9ead20 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -77,17 +77,37 @@ public class ComponentDao implements Dao {
}
public List<ComponentDto> selectByQuery(DbSession session, ComponentQuery query, int offset, int limit) {
- if (query.getComponentIds() != null && query.getComponentIds().isEmpty()) {
+ return selectByQueryImpl(session, null, query, offset, limit);
+ }
+
+ public List<ComponentDto> selectByQuery(DbSession dbSession, String organizationUuid, ComponentQuery query, int offset, int limit) {
+ requireNonNull(organizationUuid, "organizationUuid can't be null");
+ return selectByQueryImpl(dbSession, organizationUuid, query, offset, limit);
+ }
+
+ private static List<ComponentDto> selectByQueryImpl(DbSession session, @Nullable String organizationUuid, ComponentQuery query, int offset, int limit) {
+ Set<Long> componentIds = query.getComponentIds();
+ if (componentIds != null && componentIds.isEmpty()) {
return emptyList();
}
- return mapper(session).selectByQuery(query, new RowBounds(offset, limit));
+ return mapper(session).selectByQuery(organizationUuid, query, new RowBounds(offset, limit));
}
public int countByQuery(DbSession session, ComponentQuery query) {
- if (query.getComponentIds() != null && query.getComponentIds().isEmpty()) {
+ return countByQueryImpl(session, null, query);
+ }
+
+ public int countByQuery(DbSession session, String organizationUuid, ComponentQuery query) {
+ requireNonNull(organizationUuid, "organizationUuid can't be null");
+ return countByQueryImpl(session, organizationUuid, query);
+ }
+
+ private static int countByQueryImpl(DbSession session, @Nullable String organizationUuid, ComponentQuery query) {
+ Set<Long> componentIds = query.getComponentIds();
+ if (componentIds != null && componentIds.isEmpty()) {
return 0;
}
- return mapper(session).countByQuery(query);
+ return mapper(session).countByQuery(organizationUuid, query);
}
public List<ComponentDto> selectSubProjectsByComponentUuids(DbSession session, Collection<String> keys) {
@@ -342,5 +362,4 @@ public class ComponentDao implements Dao {
private static ComponentMapper mapper(DbSession session) {
return session.getMapper(ComponentMapper.class);
}
-
}
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
index 9c3bb96b7e5..2cddadffbd4 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java
@@ -65,9 +65,9 @@ public interface ComponentMapper {
*/
int countComponentByOrganizationAndId(@Param("organizationUuid") String organizationUuid, @Param("componentId") long componentId);
- List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
+ List<ComponentDto> selectByQuery(@Nullable @Param("organizationUuid") String organizationUuid, @Param("query") ComponentQuery query, RowBounds rowBounds);
- int countByQuery(@Param("query") ComponentQuery query);
+ int countByQuery(@Nullable @Param("organizationUuid") String organizationUuid, @Param("query") ComponentQuery query);
List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath") String baseUuidPath);