aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-10-28 12:07:23 -0500
committersonartech <sonartech@sonarsource.com>2021-11-09 20:03:15 +0000
commite8905886d0e77cc080022dff7e0df79e4823e5de (patch)
tree899ad2f2961d3de1070605ceb66b8e69ef4aa222
parent2dd9ce1a7271e6448e546d21eb59a2ac41127c08 (diff)
downloadsonarqube-e8905886d0e77cc080022dff7e0df79e4823e5de.tar.gz
sonarqube-e8905886d0e77cc080022dff7e0df79e4823e5de.zip
SONAR-15498 Compute manually selected projects in portfolio
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java19
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDto.java10
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml8
-rw-r--r--server/sonar-db-dao/src/schema/schema-sq.ddl4
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfolios.java2
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTable.java49
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfoliosTest.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest.java53
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest/schema.sql41
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java11
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java1
12 files changed, 167 insertions, 39 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
index 881fad42933..788fe06929a 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
@@ -165,7 +165,7 @@ public class PersistComponentsStep implements ComputationStep {
super(
CrawlerDepthLimit.LEAVES,
PRE_ORDER,
- new SimpleStackElementFactory<ComponentDtoHolder>() {
+ new SimpleStackElementFactory<>() {
@Override
public ComponentDtoHolder createForAny(Component component) {
return new ComponentDtoHolder();
@@ -191,42 +191,37 @@ public class PersistComponentsStep implements ComputationStep {
@Override
public void visitProject(Component project, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForProject(project);
- path.current().setDto(persistAndPopulateCache(project, dto));
+ path.current().setDto(persistComponent(dto));
}
@Override
public void visitDirectory(Component directory, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForDirectory(directory, path);
- path.current().setDto(persistAndPopulateCache(directory, dto));
+ path.current().setDto(persistComponent(dto));
}
@Override
public void visitFile(Component file, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForFile(file, path);
- persistAndPopulateCache(file, dto);
+ persistComponent(dto);
}
@Override
public void visitView(Component view, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForView(view);
- path.current().setDto(persistAndPopulateCache(view, dto));
+ path.current().setDto(persistComponent(dto));
}
@Override
public void visitSubView(Component subView, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForSubView(subView, path);
- path.current().setDto(persistAndPopulateCache(subView, dto));
+ path.current().setDto(persistComponent(dto));
}
@Override
public void visitProjectView(Component projectView, Path<ComponentDtoHolder> path) {
ComponentDto dto = createForProjectView(projectView, path);
- persistAndPopulateCache(projectView, dto);
- }
-
- private ComponentDto persistAndPopulateCache(Component component, ComponentDto dto) {
- ComponentDto projectDto = persistComponent(dto);
- return projectDto;
+ persistComponent(dto);
}
private ComponentDto persistComponent(ComponentDto componentDto) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDto.java
index 48195cc50ea..9009ad5ae82 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/PortfolioDto.java
@@ -33,7 +33,7 @@ public class PortfolioDto {
private String name;
private String description;
private boolean isPrivate = false;
- private String branchName;
+ private String branchKey;
private String rootUuid;
private String parentUuid;
@@ -71,12 +71,12 @@ public class PortfolioDto {
}
@CheckForNull
- public String getBranchName() {
- return branchName;
+ public String getBranchKey() {
+ return branchKey;
}
- public void setBranchName(@Nullable String branchName) {
- this.branchName = branchName;
+ public void setBranchKey(@Nullable String branchKey) {
+ this.branchKey = branchKey;
}
public String getSelectionMode() {
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml
index a07f7f293a7..d25f5a4b6a8 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/portfolio/PortfolioMapper.xml
@@ -8,7 +8,7 @@
p.name as name,
p.description as description,
p.private as isPrivate,
- p.branch_name as branchName,
+ p.branch_key as branchKey,
p.root_uuid as rootUuid,
p.parent_uuid as parentUuid,
p.selection_mode as selectionMode,
@@ -227,7 +227,7 @@
private,
root_uuid,
parent_uuid,
- branch_name,
+ branch_key,
selection_mode,
selection_expression,
created_at,
@@ -241,7 +241,7 @@
#{isPrivate,jdbcType=BOOLEAN},
#{rootUuid,jdbcType=VARCHAR},
#{parentUuid,jdbcType=VARCHAR},
- #{branchName,jdbcType=VARCHAR},
+ #{branchKey,jdbcType=VARCHAR},
#{selectionMode,jdbcType=VARCHAR},
#{selectionExpression,jdbcType=VARCHAR},
#{createdAt,jdbcType=BIGINT},
@@ -432,7 +432,7 @@
selection_mode = #{selectionMode,jdbcType=VARCHAR},
selection_expression = #{selectionExpression,jdbcType=VARCHAR},
parent_uuid = #{parentUuid,jdbcType=VARCHAR},
- branch_name = #{branchName,jdbcType=VARCHAR},
+ branch_key = #{branchKey,jdbcType=VARCHAR},
root_uuid = #{rootUuid,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=BIGINT}
where
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl
index f2720a1e7e1..eb874b033a9 100644
--- a/server/sonar-db-dao/src/schema/schema-sq.ddl
+++ b/server/sonar-db-dao/src/schema/schema-sq.ddl
@@ -199,7 +199,7 @@ CREATE INDEX "CTM_MESSAGE_TYPE" ON "CE_TASK_MESSAGE"("MESSAGE_TYPE");
CREATE TABLE "COMPONENTS"(
"UUID" VARCHAR(50) NOT NULL,
- "KEE" VARCHAR(400),
+ "KEE" VARCHAR(1000),
"DEPRECATED_KEE" VARCHAR(400),
"NAME" VARCHAR(2000),
"LONG_NAME" VARCHAR(2000),
@@ -602,7 +602,7 @@ CREATE TABLE "PORTFOLIOS"(
"SELECTION_EXPRESSION" VARCHAR(4000),
"CREATED_AT" BIGINT NOT NULL,
"UPDATED_AT" BIGINT NOT NULL,
- "BRANCH_NAME" VARCHAR(255)
+ "BRANCH_KEY" VARCHAR(255)
);
ALTER TABLE "PORTFOLIOS" ADD CONSTRAINT "PK_PORTFOLIOS" PRIMARY KEY("UUID");
CREATE UNIQUE INDEX "UNIQ_PORTFOLIOS_KEE" ON "PORTFOLIOS"("KEE");
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfolios.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfolios.java
index e546d9f4b6b..e9697c41a88 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfolios.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfolios.java
@@ -29,7 +29,7 @@ import org.sonar.server.platform.db.migration.step.DdlChange;
public class AddBranchToPortfolios extends DdlChange {
private static final String TABLE_NAME = "portfolios";
- private static final String COLUMN_NAME = "branch_name";
+ private static final String COLUMN_NAME = "branch_key";
public AddBranchToPortfolios(Database db) {
super(db);
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTable.java
new file mode 100644
index 00000000000..be802b6087a
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTable.java
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info 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.server.platform.db.migration.version.v92;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AlterKeeInComponentsTable extends DdlChange {
+ private static final String TABLE = "components";
+
+ private static final VarcharColumnDef columnDefinition = newVarcharColumnDefBuilder()
+ .setColumnName("kee")
+ .setIsNullable(true)
+ .setLimit(1000)
+ .build();
+
+ public AlterKeeInComponentsTable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new AlterColumnsBuilder(getDialect(), TABLE)
+ .updateColumn(columnDefinition)
+ .build());
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java
index 9eb256422a0..778bea48082 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v92/DbVersion92.java
@@ -33,8 +33,10 @@ public class DbVersion92 implements DbVersion {
.add(6105, "Create qgate_group_permissions Table", CreateQGateGroupPermissionsTable.class)
.add(6106, "Create column sonarlint_ad_seen in 'users'", AddSonarlintAdSeenColumnInUsersTable.class)
.add(6107, "Upsert value of sonarlint_ad_seen in 'users'", UpsertSonarlintAdSeenValue.class)
- .add(6108, "Create table 'portfolio_proj_branches'", CreatePortfolioProjectBranchesTable.class)
- .add(6109, "Add column 'branch_name' to table 'portfolios'", AddBranchToPortfolios.class)
+ .add(6108, "Change size of column 'kee' in 'components'", AlterKeeInComponentsTable.class)
+ .add(6109, "Create table 'portfolio_proj_branches'", CreatePortfolioProjectBranchesTable.class)
+ .add(6110, "Add column 'branch_key' to table 'portfolios'", AddBranchToPortfolios.class)
+ .add(6111, "Change size of column 'kee' in 'components'", AlterKeeInComponentsTable.class)
;
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfoliosTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfoliosTest.java
index 9952f7f2fe0..da47fe6e09f 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfoliosTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AddBranchToPortfoliosTest.java
@@ -27,7 +27,7 @@ import org.sonar.db.CoreDbTester;
public class AddBranchToPortfoliosTest {
private static final String TABLE_NAME = "portfolios";
- private static final String COLUMN_NAME = "branch_name";
+ private static final String COLUMN_NAME = "branch_key";
@Rule
public final CoreDbTester db = CoreDbTester.createForSchema(AddBranchToPortfoliosTest.class, "schema.sql");
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest.java
new file mode 100644
index 00000000000..b7b973ed825
--- /dev/null
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest.java
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info 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.server.platform.db.migration.version.v92;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static java.sql.Types.VARCHAR;
+
+public class AlterKeeInComponentsTableTest {
+ private final String TABLE = "components";
+ private final String COLUMN = "kee";
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(AlterKeeInComponentsTableTest.class, "schema.sql");
+
+ private final DdlChange underTest = new AlterKeeInComponentsTable(db.database());
+
+ @Test
+ public void selection_expression_column_is_altered() throws SQLException {
+ underTest.execute();
+
+ db.assertColumnDefinition(TABLE, COLUMN, VARCHAR, 1000, true);
+ }
+
+ @Test
+ public void migration_is_reentrant() throws SQLException {
+ underTest.execute();
+ underTest.execute();
+
+ db.assertColumnDefinition(TABLE, COLUMN, VARCHAR, 1000, true);
+ }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest/schema.sql
new file mode 100644
index 00000000000..520824c5490
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v92/AlterKeeInComponentsTableTest/schema.sql
@@ -0,0 +1,41 @@
+CREATE TABLE "COMPONENTS"(
+ "UUID" VARCHAR(50) NOT NULL,
+ "KEE" VARCHAR(400),
+ "DEPRECATED_KEE" VARCHAR(400),
+ "NAME" VARCHAR(2000),
+ "LONG_NAME" VARCHAR(2000),
+ "DESCRIPTION" VARCHAR(2000),
+ "ENABLED" BOOLEAN DEFAULT TRUE NOT NULL,
+ "SCOPE" VARCHAR(3),
+ "QUALIFIER" VARCHAR(10),
+ "PRIVATE" BOOLEAN NOT NULL,
+ "ROOT_UUID" VARCHAR(50) NOT NULL,
+ "LANGUAGE" VARCHAR(20),
+ "COPY_COMPONENT_UUID" VARCHAR(50),
+ "PATH" VARCHAR(2000),
+ "UUID_PATH" VARCHAR(1500) NOT NULL,
+ "PROJECT_UUID" VARCHAR(50) NOT NULL,
+ "MODULE_UUID" VARCHAR(50),
+ "MODULE_UUID_PATH" VARCHAR(1500),
+ "MAIN_BRANCH_PROJECT_UUID" VARCHAR(50),
+ "B_CHANGED" BOOLEAN,
+ "B_NAME" VARCHAR(500),
+ "B_LONG_NAME" VARCHAR(500),
+ "B_DESCRIPTION" VARCHAR(2000),
+ "B_ENABLED" BOOLEAN,
+ "B_QUALIFIER" VARCHAR(10),
+ "B_LANGUAGE" VARCHAR(20),
+ "B_COPY_COMPONENT_UUID" VARCHAR(50),
+ "B_PATH" VARCHAR(2000),
+ "B_UUID_PATH" VARCHAR(1500),
+ "B_MODULE_UUID" VARCHAR(50),
+ "B_MODULE_UUID_PATH" VARCHAR(1500),
+ "CREATED_AT" TIMESTAMP
+);
+CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE");
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID");
+CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID");
+CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER");
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID");
+CREATE INDEX "PROJECTS_UUID" ON "COMPONENTS"("UUID");
+CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID");
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java
index 88655168a3c..8c16c4463ea 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java
@@ -27,7 +27,6 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
public class SearchRequest {
- private List<String> actionPlans;
private List<String> additionalFields;
private Boolean asc;
private Boolean assigned;
@@ -72,16 +71,6 @@ public class SearchRequest {
}
@CheckForNull
- public List<String> getActionPlans() {
- return actionPlans;
- }
-
- public SearchRequest setActionPlans(@Nullable List<String> actionPlans) {
- this.actionPlans = actionPlans;
- return this;
- }
-
- @CheckForNull
public List<String> getAdditionalFields() {
return additionalFields;
}
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
index 9b9b0e49fd7..09313ee6909 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
@@ -536,7 +536,6 @@ public class IssueIndex {
if (onApplicationBranch) {
allFilters.addFilter("__view", new SimpleFieldFilterScope("view"), createViewFilter(singletonList(query.branchUuid())));
} else {
- allFilters.addFilter("__is_main_branch", new SimpleFieldFilterScope(FIELD_ISSUE_IS_MAIN_BRANCH), createTermFilter(FIELD_ISSUE_IS_MAIN_BRANCH, Boolean.toString(true)));
allFilters.addFilter("__view", new SimpleFieldFilterScope("view"), createViewFilter(viewUuids));
}
}