From 7994ab1cd1740e5b25842bc99cd05209e9813520 Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Fri, 25 Jun 2021 09:18:27 +0200 Subject: [PATCH] SONAR-10762 Drop Manual Measure from portfolios --- .../report-custom-measures.xml | 22 ----- .../view-custom-measures.xml | 22 ----- .../org/sonar/db/purge/PurgeCommands.java | 10 -- .../java/org/sonar/db/purge/PurgeMapper.java | 2 - .../db/measure/custom/CustomMeasureMapper.xml | 99 ------------------- .../org/sonar/db/purge/PurgeMapper.xml | 7 -- .../java/org/sonar/db/purge/PurgeDaoTest.java | 5 - .../sonar/server/ui/ws/ComponentAction.java | 2 - .../platform/ws/l10n-index-example.json | 1 - .../sonar/server/ui/ws/component-example.json | 1 - .../server/ui/ws/ComponentActionTest.java | 2 - .../return_configuration_for_admin.json | 1 - ..._configuration_for_quality_gate_admin.json | 1 - ...nfiguration_for_quality_profile_admin.json | 1 - ...urn_configuration_with_all_properties.json | 1 - .../ws/client/views/ManualMeasureRequest.java | 71 ------------- .../ws/client/views/ViewsService.java | 17 ---- 17 files changed, 265 deletions(-) delete mode 100644 server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/report-custom-measures.xml delete mode 100644 server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/view-custom-measures.xml delete mode 100644 server/sonar-db-dao/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/views/ManualMeasureRequest.java diff --git a/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/report-custom-measures.xml b/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/report-custom-measures.xml deleted file mode 100644 index 507508f8587..00000000000 --- a/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/report-custom-measures.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/view-custom-measures.xml b/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/view-custom-measures.xml deleted file mode 100644 index c3dbc637c01..00000000000 --- a/server/sonar-ce-task-projectanalysis/src/test/resources/org/sonar/ce/task/projectanalysis/step/CustomMeasuresCopyStepTest/view-custom-measures.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java index 55d68363c8b..a4f366c7c98 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -229,11 +229,6 @@ class PurgeCommands { uuidsPartitions.forEach(purgeMapper::deletePropertiesByComponentUuids); session.commit(); profiler.stop(); - - profiler.start("deleteByRootAndModulesOrSubviews (manual_measures)"); - uuidsPartitions.forEach(purgeMapper::deleteManualMeasuresByComponentUuids); - session.commit(); - profiler.stop(); } void deleteDisabledComponentsWithoutIssues(List disabledComponentsWithoutIssue) { @@ -247,11 +242,6 @@ class PurgeCommands { session.commit(); profiler.stop(); - profiler.start("deleteDisabledComponentsWithoutIssues (manual_measures)"); - uuidsPartitions.forEach(purgeMapper::deleteManualMeasuresByComponentUuids); - session.commit(); - profiler.stop(); - profiler.start("deleteDisabledComponentsWithoutIssues (projects)"); uuidsPartitions.forEach(purgeMapper::deleteComponentsByUuids); session.commit(); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java index 41c87deb1a9..4d7c72313f1 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -78,8 +78,6 @@ public interface PurgeMapper { void deleteUserRolesByComponentUuid(@Param("rootUuid") String rootUuid); - void deleteManualMeasuresByComponentUuids(@Param("componentUuids") List componentUuids); - void deleteEventsByComponentUuid(@Param("componentUuid") String componentUuid); void deleteEventComponentChangesByComponentUuid(@Param("componentUuid") String componentUuid); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml deleted file mode 100644 index c2dc6a9be5b..00000000000 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/custom/CustomMeasureMapper.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - m.uuid, - m.metric_uuid as metricUuid, - m.component_uuid as componentUuid, - m.value, - m.text_value as textValue, - m.user_uuid as userUuid, - m.description, - m.created_at as createdAt, - m.updated_at as updatedAt - - - - - - - - - - - - INSERT INTO manual_measures ( - uuid, metric_uuid, component_uuid, value, text_value, user_uuid, description, created_at, updated_at - ) - VALUES ( - #{uuid, jdbcType=VARCHAR}, - #{metricUuid, jdbcType=VARCHAR}, - #{componentUuid, jdbcType=VARCHAR}, - #{value, jdbcType=DOUBLE}, - #{textValue, jdbcType=VARCHAR}, - #{userUuid, jdbcType=VARCHAR}, - #{description, jdbcType=VARCHAR}, - #{createdAt, jdbcType=BIGINT}, - #{updatedAt, jdbcType=BIGINT} - ) - - - - update manual_measures - set value = #{value, jdbcType=DOUBLE}, - text_value = #{textValue, jdbcType=VARCHAR}, - description = #{description, jdbcType=VARCHAR}, - user_uuid = #{userUuid, jdbcType=VARCHAR}, - updated_at = #{updatedAt, jdbcType=BIGINT} - where uuid = #{uuid} - - - - delete from manual_measures - where metric_uuid in - - #{metricUuid} - - - - - delete from manual_measures - where uuid=#{uuid} - - - - - - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml index e2e04898f38..75c93120ff2 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml @@ -256,13 +256,6 @@ component_uuid = #{rootUuid,jdbcType=INTEGER} - - delete from manual_measures where component_uuid in - - #{componentUuid,jdbcType=VARCHAR} - - - delete from events where diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index a6346864bb3..6157294c7a9 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -1611,11 +1611,6 @@ public class PurgeDaoTest { db.getSession().commit(); } - private Stream getComponentUuidsOfManualMeasures() { - return db.select("select component_uuid as \"COMPONENT_UUID\" from manual_measures").stream() - .map(row -> (String) row.get("COMPONENT_UUID")); - } - private Stream getResourceIdOfProperties() { return db.select("select component_uuid as \"uuid\" from properties").stream() .map(row -> (String) row.get("uuid")); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java index ab048d25484..c52ec34432a 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java @@ -286,7 +286,6 @@ public class ComponentAction implements NavigationWsAction { private void writeConfigPageAccess(JsonWriter json, boolean isProjectAdmin, ComponentDto component) { boolean isProject = Qualifiers.PROJECT.equals(component.qualifier()); - boolean showManualMeasures = isProjectAdmin && !Qualifiers.DIRECTORY.equals(component.qualifier()); boolean showBackgroundTasks = isProjectAdmin && (isProject || Qualifiers.VIEW.equals(component.qualifier()) || Qualifiers.APP.equals(component.qualifier())); boolean isQualityProfileAdmin = userSession.hasPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES); boolean isQualityGateAdmin = userSession.hasPermission(GlobalPermission.ADMINISTER_QUALITY_GATES); @@ -298,7 +297,6 @@ public class ComponentAction implements NavigationWsAction { json.prop("showSettings", isProjectAdmin && componentTypeHasProperty(component, PROPERTY_CONFIGURABLE)); json.prop("showQualityProfiles", isProject && (isProjectAdmin || isQualityProfileAdmin)); json.prop("showQualityGates", isProject && (isProjectAdmin || isQualityGateAdmin)); - json.prop("showManualMeasures", showManualMeasures); json.prop("showLinks", isProjectAdmin && isProject); json.prop("showPermissions", isProjectAdmin && componentTypeHasProperty(component, PROPERTY_HAS_ROLE_POLICY) && (isGlobalAdmin || allowChangingPermissionsByProjectAdmins)); diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json index e4ce8a21d1d..e2b31870b6e 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/platform/ws/l10n-index-example.json @@ -96,7 +96,6 @@ "rule.php.S101.param.format": "Regular expression used to check the class names against.", "select2.tooShort": "Please enter at least {0} characters", "widget.custom_measures.property.metric10.name": "Metric 10", - "manual_measures.save_button": "Save", "issue_filter.sharing": "Sharing", "widget.measure_filter_cloud.property.colorMetric.name": "Color Metric", "dashboard.TimeMachine.name": "Time Machine", diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/ui/ws/component-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/ui/ws/component-example.json index b8c00a6257f..db129fcf724 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/ui/ws/component-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/ui/ws/component-example.json @@ -37,7 +37,6 @@ "showSettings": true, "showQualityProfiles": true, "showQualityGates": true, - "showManualMeasures": true, "showLinks": true, "showPermissions": true, "showHistory": true, diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java index 4ea440392d4..fa84b71e132 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java @@ -451,7 +451,6 @@ public class ComponentActionTest { " \"showSettings\": true,\n" + " \"showQualityProfiles\": true,\n" + " \"showQualityGates\": true,\n" + - " \"showManualMeasures\": true,\n" + " \"showLinks\": true,\n" + " \"showPermissions\": true,\n" + " \"showHistory\": true,\n" + @@ -480,7 +479,6 @@ public class ComponentActionTest { " \"showSettings\": true,\n" + " \"showQualityProfiles\": true,\n" + " \"showQualityGates\": true,\n" + - " \"showManualMeasures\": true,\n" + " \"showLinks\": true,\n" + " \"showPermissions\": false,\n" + " \"showHistory\": true,\n" + diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_admin.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_admin.json index 804191d9aa8..31847f32a6a 100644 --- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_admin.json +++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_admin.json @@ -3,7 +3,6 @@ "showSettings": true, "showQualityProfiles": true, "showQualityGates": true, - "showManualMeasures": true, "showLinks": true, "showPermissions": true, "showHistory": true, diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_gate_admin.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_gate_admin.json index 893e9dfc04a..3b7f460cc5c 100644 --- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_gate_admin.json +++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_gate_admin.json @@ -3,7 +3,6 @@ "showSettings": false, "showQualityProfiles": false, "showQualityGates": true, - "showManualMeasures": false, "showLinks": false, "showPermissions": false, "showHistory": false, diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_profile_admin.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_profile_admin.json index 8a8dd68ca93..c08cdaff46b 100644 --- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_profile_admin.json +++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_for_quality_profile_admin.json @@ -3,7 +3,6 @@ "showSettings": false, "showQualityProfiles": true, "showQualityGates": false, - "showManualMeasures": false, "showLinks": false, "showPermissions": false, "showHistory": false, diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_with_all_properties.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_with_all_properties.json index 48844dacf26..115f3521456 100644 --- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_with_all_properties.json +++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_configuration_with_all_properties.json @@ -3,7 +3,6 @@ "showSettings": true, "showQualityProfiles": true, "showQualityGates": true, - "showManualMeasures": true, "showLinks": true, "showPermissions": true, "showHistory": true, diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ManualMeasureRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ManualMeasureRequest.java deleted file mode 100644 index 2e9924ef403..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ManualMeasureRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.sonarqube.ws.client.views; - -import javax.annotation.Generated; - -/** - * This is part of the internal API. - * This is a POST request. - * @see Further information about this action online (including a response example) - * @since 1.0 - */ -@Generated("sonar-ws-generator") -public class ManualMeasureRequest { - - private String key; - private String measure; - private String value; - - /** - * This is a mandatory parameter. - */ - public ManualMeasureRequest setKey(String key) { - this.key = key; - return this; - } - - public String getKey() { - return key; - } - - /** - * This is a mandatory parameter. - */ - public ManualMeasureRequest setMeasure(String measure) { - this.measure = measure; - return this; - } - - public String getMeasure() { - return measure; - } - - /** - */ - public ManualMeasureRequest setValue(String value) { - this.value = value; - return this; - } - - public String getValue() { - return value; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ViewsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ViewsService.java index dd9c49a294b..52ba65115e0 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ViewsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/views/ViewsService.java @@ -193,23 +193,6 @@ public class ViewsService extends BaseService { ).content(); } - /** - * - * This is part of the internal API. - * This is a POST request. - * @see Further information about this action online (including a response example) - * @since 1.0 - */ - public void manualMeasure(ManualMeasureRequest request) { - call( - new PostRequest(path("manual_measure")) - .setParam("key", request.getKey()) - .setParam("measure", request.getMeasure()) - .setParam("value", request.getValue()) - .setMediaType(MediaTypes.JSON) - ).content(); - } - /** * * This is part of the internal API. -- 2.39.5