aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/java/org/sonar
diff options
context:
space:
mode:
authorCody Simms <141657208+cody-simms-sonarsource@users.noreply.github.com>2024-12-18 09:58:49 -0600
committersonartech <sonartech@sonarsource.com>2024-12-18 20:03:11 +0000
commitab3125728559f0d37ae3210610335c210dac02ba (patch)
tree9e10fdb801ba57c5f931fef505722dc5201fba4f /server/sonar-db-dao/src/main/java/org/sonar
parentec0d8ad9cdb8097ddee68ceada41abd0b2632032 (diff)
downloadsonarqube-ab3125728559f0d37ae3210610335c210dac02ba.tar.gz
sonarqube-ab3125728559f0d37ae3210610335c210dac02ba.zip
SONAR-23936 Query all portfolio projects at once rather than recursively
Co-authored-by: Duarte Meneses <duarte.meneses@sonarsource.com>
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org/sonar')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java34
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java10
2 files changed, 29 insertions, 15 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
index 437961a5470..59dcb3ede0c 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -61,7 +61,8 @@ public class ComponentDao implements Dao {
}
public ComponentDto selectOrFailByUuid(DbSession session, String uuid) {
- return selectByUuid(session, uuid).orElseThrow(() -> new RowNotFoundException(String.format("Component with uuid '%s' not found", uuid)));
+ return selectByUuid(session, uuid).orElseThrow(() -> new RowNotFoundException(String.format("Component with uuid '%s' not found",
+ uuid)));
}
public List<ComponentDto> selectByUuids(DbSession session, Collection<String> uuids) {
@@ -99,18 +100,24 @@ public class ComponentDao implements Dao {
*/
/**
- * @throws IllegalArgumentException if parameter query#getComponentIds() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
- * @throws IllegalArgumentException if parameter query#getComponentKeys() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
- * @throws IllegalArgumentException if parameter query#getMainComponentUuids() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getComponentIds() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getComponentKeys() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getMainComponentUuids() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
*/
public List<ComponentDto> selectByQuery(DbSession dbSession, ComponentQuery query, Pagination pagination) {
return selectByQueryImpl(dbSession, query, pagination);
}
/**
- * @throws IllegalArgumentException if parameter query#getComponentIds() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
- * @throws IllegalArgumentException if parameter query#getComponentKeys() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
- * @throws IllegalArgumentException if parameter query#getMainComponentUuids() has more than {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getComponentIds() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getComponentKeys() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
+ * @throws IllegalArgumentException if parameter query#getMainComponentUuids() has more than
+ * {@link org.sonar.db.DatabaseUtils#PARTITION_SIZE_FOR_ORACLE} values
*/
public int countByQuery(DbSession session, ComponentQuery query) {
return countByQueryImpl(session, query);
@@ -158,7 +165,8 @@ public class ComponentDao implements Dao {
/**
* If no branch or pull request is provided, returns components in the main branch
*/
- public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys, @Nullable String branch, @Nullable String pullRequest) {
+ public List<ComponentDto> selectByKeys(DbSession session, Collection<String> keys, @Nullable String branch,
+ @Nullable String pullRequest) {
checkState(branch == null || pullRequest == null, "Can't set both branch and pull request");
return executeLargeInputs(keys, subKeys -> mapper(session).selectByKeysAndBranchOrPr(subKeys, branch, pullRequest));
}
@@ -250,8 +258,10 @@ public class ComponentDao implements Dao {
* Returns components with open issues from P/Rs that use a certain branch as reference (reference branch).
* Excludes components from the current branch.
*/
- public List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(DbSession dbSession, String referenceBranchUuid, String currentBranchUuid) {
- return mapper(dbSession).selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(referenceBranchUuid, currentBranchUuid);
+ public List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(DbSession dbSession,
+ String referenceBranchUuid, String currentBranchUuid) {
+ return mapper(dbSession).selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(referenceBranchUuid,
+ currentBranchUuid);
}
/**
@@ -329,7 +339,8 @@ public class ComponentDao implements Dao {
mapper(session).setPrivateForBranchUuid(branchUuid, isPrivate);
}
- public void setPrivateForBranchUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey, String componentName) {
+ public void setPrivateForBranchUuid(DbSession session, String branchUuid, boolean isPrivate, String qualifier, String componentKey,
+ String componentName) {
ComponentNewValue componentNewValue = new ComponentNewValue(branchUuid, componentName, componentKey, isPrivate, qualifier);
//TODO we should log change to the visibility in EntityDao, not ComponentDao
auditPersister.updateComponentVisibility(session, componentNewValue);
@@ -351,5 +362,4 @@ public class ComponentDao implements Dao {
checkThatNotTooManyConditions(query.getComponentKeys(), "Too many component keys in query");
checkThatNotTooManyConditions(query.getComponentUuids(), "Too many component UUIDs in query");
}
-
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
index 7b61364c650..7d26dc3d09f 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
@@ -33,7 +33,8 @@ public interface ComponentMapper {
List<ComponentDto> selectByKeyCaseInsensitive(@Param("key") String key);
@CheckForNull
- ComponentDto selectByKeyAndBranchOrPr(@Param("key") String key, @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest") String pullRequest);
+ ComponentDto selectByKeyAndBranchOrPr(@Param("key") String key, @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest"
+ ) String pullRequest);
@CheckForNull
ComponentDto selectByUuid(@Param("uuid") String uuid);
@@ -58,7 +59,8 @@ public interface ComponentMapper {
int countByQuery(@Param("query") ComponentQuery query);
- List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath") String baseUuidPath);
+ List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath"
+ ) String baseUuidPath);
List<ComponentDto> selectChildren(@Param("branchUuid") String branchUuid, @Param("uuidPaths") Set<String> uuidPaths);
@@ -111,5 +113,7 @@ public interface ComponentMapper {
List<KeyWithUuidDto> selectComponentsFromBranchesThatHaveOpenIssues(@Param("branchUuids") List<String> branchUuids);
- short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys, @Param("qualifiers") Set<String> qualifiers);
+ short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys,
+ @Param("qualifiers") Set<String> qualifiers);
+
}