From 81c539e66ba0b32109ca48fd61ab8dc54d8d95e5 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 10 Jun 2015 18:31:13 +0200 Subject: SONAR-6557 Drop dependencies table --- .../org/sonar/core/design/FileDependencyDto.java | 105 --------------------- .../java/org/sonar/core/design/package-info.java | 23 ----- .../sonar/core/persistence/DatabaseVersion.java | 5 +- .../java/org/sonar/core/persistence/MyBatis.java | 9 +- .../java/org/sonar/core/purge/PurgeCommands.java | 21 +---- .../java/org/sonar/core/purge/PurgeMapper.java | 12 +-- .../org/sonar/core/design/FileDependencyMapper.xml | 38 -------- .../org/sonar/core/persistence/rows-h2.sql | 1 + .../org/sonar/core/persistence/schema-h2.ddl | 24 ----- .../resources/org/sonar/core/purge/PurgeMapper.xml | 21 ----- .../org/sonar/core/purge/PurgeCommandsTest.java | 8 +- .../shouldDeleteSnapshot-result.xml | 3 - .../PurgeCommandsTest/shouldDeleteSnapshot.xml | 9 -- .../shouldPurgeSnapshot-result.xml | 16 ---- .../PurgeCommandsTest/shouldPurgeSnapshot.xml | 16 ---- 15 files changed, 13 insertions(+), 298 deletions(-) delete mode 100644 sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java delete mode 100644 sonar-core/src/main/java/org/sonar/core/design/package-info.java delete mode 100644 sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml (limited to 'sonar-core') diff --git a/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java b/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java deleted file mode 100644 index 1c5fa2e3bb0..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.core.design; - -public final class FileDependencyDto { - - private Long id; - private String fromComponentUuid; - private String fromParentUuid; - private String toComponentUuid; - private String toParentUuid; - private Long rootProjectSnapshotId; - private Integer weight; - private Long createdAt; - - public Long getId() { - return id; - } - - public FileDependencyDto setId(Long id) { - this.id = id; - return this; - } - - public String getFromComponentUuid() { - return fromComponentUuid; - } - - public FileDependencyDto setFromComponentUuid(String fromComponentUuid) { - this.fromComponentUuid = fromComponentUuid; - return this; - } - - public String getFromParentUuid() { - return fromParentUuid; - } - - public FileDependencyDto setFromParentUuid(String fromParentUuid) { - this.fromParentUuid = fromParentUuid; - return this; - } - - public Long getRootProjectSnapshotId() { - return rootProjectSnapshotId; - } - - public FileDependencyDto setRootProjectSnapshotId(Long rootProjectSnapshotId) { - this.rootProjectSnapshotId = rootProjectSnapshotId; - return this; - } - - public String getToComponentUuid() { - return toComponentUuid; - } - - public FileDependencyDto setToComponentUuid(String toComponentUuid) { - this.toComponentUuid = toComponentUuid; - return this; - } - - public String getToParentUuid() { - return toParentUuid; - } - - public FileDependencyDto setToParentUuid(String toParentUuid) { - this.toParentUuid = toParentUuid; - return this; - } - - public Integer getWeight() { - return weight; - } - - public FileDependencyDto setWeight(Integer weight) { - this.weight = weight; - return this; - } - - public Long getCreatedAt() { - return createdAt; - } - - public FileDependencyDto setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - return this; - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/design/package-info.java b/sonar-core/src/main/java/org/sonar/core/design/package-info.java deleted file mode 100644 index 23d1da72558..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/design/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.core.design; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index f7d7ee524ed..8f2dd4a04aa 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -34,10 +34,10 @@ import org.sonar.api.server.ServerSide; @ServerSide public class DatabaseVersion { - public static final int LAST_VERSION = 919; + public static final int LAST_VERSION = 922; /** - * List of all the tables.n + * List of all the tables. * This list is hardcoded because we didn't succeed in using java.sql.DatabaseMetaData#getTables() in the same way * for all the supported databases, particularly due to Oracle results. */ @@ -51,7 +51,6 @@ public class DatabaseVersion { "authors", "characteristics", "dashboards", - "dependencies", "duplications_index", "events", "file_sources", diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index 4c00dfa35f9..7a646a05c29 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -36,8 +36,8 @@ import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.apache.ibatis.type.JdbcType; import org.slf4j.LoggerFactory; import org.sonar.api.batch.BatchSide; -import org.sonar.api.server.ServerSide; import org.sonar.api.database.model.MeasureModel; +import org.sonar.api.server.ServerSide; import org.sonar.core.activity.db.ActivityDto; import org.sonar.core.activity.db.ActivityMapper; import org.sonar.core.cluster.WorkQueue; @@ -53,8 +53,6 @@ import org.sonar.core.component.db.SnapshotMapper; import org.sonar.core.computation.db.AnalysisReportDto; import org.sonar.core.computation.db.AnalysisReportMapper; import org.sonar.core.config.Logback; -import org.sonar.core.measure.custom.db.CustomMeasureDto; -import org.sonar.core.measure.custom.db.CustomMeasureMapper; import org.sonar.core.dashboard.ActiveDashboardDto; import org.sonar.core.dashboard.ActiveDashboardMapper; import org.sonar.core.dashboard.DashboardDto; @@ -63,7 +61,6 @@ import org.sonar.core.dashboard.WidgetDto; import org.sonar.core.dashboard.WidgetMapper; import org.sonar.core.dashboard.WidgetPropertyDto; import org.sonar.core.dashboard.WidgetPropertyMapper; -import org.sonar.core.design.FileDependencyMapper; import org.sonar.core.duplication.DuplicationMapper; import org.sonar.core.duplication.DuplicationUnitDto; import org.sonar.core.event.EventDto; @@ -80,6 +77,8 @@ import org.sonar.core.issue.db.IssueFilterFavouriteDto; import org.sonar.core.issue.db.IssueFilterFavouriteMapper; import org.sonar.core.issue.db.IssueFilterMapper; import org.sonar.core.issue.db.IssueMapper; +import org.sonar.core.measure.custom.db.CustomMeasureDto; +import org.sonar.core.measure.custom.db.CustomMeasureMapper; import org.sonar.core.measure.db.MeasureDto; import org.sonar.core.measure.db.MeasureFilterDto; import org.sonar.core.measure.db.MeasureFilterMapper; @@ -249,7 +248,7 @@ public class MyBatis { loadMapper(conf, "org.sonar.core.permission.PermissionMapper"); Class[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class, - FileDependencyMapper.class, DuplicationMapper.class, + DuplicationMapper.class, IssueMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class, IsAliveMapper.class, LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java index b8c9c49edd5..e34957e39f9 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java @@ -21,9 +21,8 @@ package org.sonar.core.purge; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; -import org.apache.ibatis.session.SqlSession; - import java.util.List; +import org.apache.ibatis.session.SqlSession; class PurgeCommands { @@ -156,8 +155,6 @@ class PurgeCommands { List> snapshotIdsPartition = Lists.partition(snapshotIds, MAX_SNAPSHOTS_PER_QUERY); - deleteSnapshotDependencies(snapshotIdsPartition); - deleteSnapshotDuplications(snapshotIdsPartition); profiler.start("deleteSnapshotEvents (events)"); @@ -191,8 +188,6 @@ class PurgeCommands { // note that events are not deleted List> snapshotIdsPartition = Lists.partition(snapshotIds, MAX_SNAPSHOTS_PER_QUERY); - deleteSnapshotDependencies(snapshotIdsPartition); - deleteSnapshotDuplications(snapshotIdsPartition); profiler.start("deleteSnapshotWastedMeasures (project_measures)"); @@ -220,20 +215,6 @@ class PurgeCommands { profiler.stop(); } - private void deleteSnapshotDependencies(final List> snapshotIdsPartition) { - profiler.start("deleteSnapshotDependencies (dependencies)"); - for (List partSnapshotIds : snapshotIdsPartition) { - // SONAR-4586 - // On MsSQL, the maximum number of parameters allowed in a query is 2000, so we have to execute 3 queries instead of one with 3 or - // inside - purgeMapper.deleteSnapshotDependenciesFromSnapshotId(partSnapshotIds); - purgeMapper.deleteSnapshotDependenciesToSnapshotId(partSnapshotIds); - purgeMapper.deleteSnapshotDependenciesProjectSnapshotId(partSnapshotIds); - } - session.commit(); - profiler.stop(); - } - public void deleteFileSources(String rootUuid) { profiler.start("deleteFileSources (file_sources)"); purgeMapper.deleteFileSourcesByProjectUuid(rootUuid); diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index 3c5e7131463..5850596aaf7 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -19,11 +19,9 @@ */ package org.sonar.core.purge; -import org.apache.ibatis.annotations.Param; - -import javax.annotation.Nullable; - import java.util.List; +import javax.annotation.Nullable; +import org.apache.ibatis.annotations.Param; public interface PurgeMapper { @@ -37,12 +35,6 @@ public interface PurgeMapper { void deleteSnapshot(@Param("snapshotIds") List snapshotIds); - void deleteSnapshotDependenciesFromSnapshotId(@Param("snapshotIds") List snapshotIds); - - void deleteSnapshotDependenciesToSnapshotId(@Param("snapshotIds") List snapshotIds); - - void deleteSnapshotDependenciesProjectSnapshotId(@Param("snapshotIds") List snapshotIds); - void deleteSnapshotDuplications(@Param("snapshotIds") List snapshotIds); void deleteSnapshotEvents(@Param("snapshotIds") List snapshotIds); diff --git a/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml b/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml deleted file mode 100644 index 2d66c12a62c..00000000000 --- a/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - d.id as id, - d.from_component_uuid as fromComponentUuid, - d.to_component_uuid as toComponentUuid, - d.from_parent_uuid as fromParentUuid, - d.to_parent_uuid as toParentUuid, - d.root_project_snapshot_id as rootProjectSnapshotId, - d.dep_weight as "weight", - d.created_at as "createdAt" - - - - - - - - INSERT INTO dependencies (from_component_uuid, to_component_uuid, from_parent_uuid, to_parent_uuid, root_project_snapshot_id, dep_weight, created_at) - VALUES (#{fromComponentUuid,jdbcType=VARCHAR}, #{toComponentUuid,jdbcType=VARCHAR}, #{fromParentUuid,jdbcType=VARCHAR}, #{toParentUuid,jdbcType=BOOLEAN}, - #{rootProjectSnapshotId,jdbcType=VARCHAR}, #{weight,jdbcType=VARCHAR}, #{createdAt,jdbcType=VARCHAR}) - - - diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 724e611a1f3..87fa2131d12 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -341,6 +341,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('918'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('919'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('920'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('921'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('922'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index 3670c426c1f..362aa97b831 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -3,24 +3,6 @@ CREATE TABLE "GROUPS_USERS" ( "GROUP_ID" INTEGER ); -CREATE TABLE "DEPENDENCIES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "FROM_SNAPSHOT_ID" INTEGER, - "FROM_COMPONENT_UUID" VARCHAR(50), - "FROM_PARENT_UUID" VARCHAR(50), - "TO_SNAPSHOT_ID" INTEGER, - "TO_COMPONENT_UUID" VARCHAR(50), - "TO_PARENT_UUID" VARCHAR(50), - "DEP_USAGE" VARCHAR(30), - "DEP_WEIGHT" INTEGER, - "PROJECT_SNAPSHOT_ID" INTEGER, - "ROOT_PROJECT_SNAPSHOT_ID" INTEGER, - "PARENT_DEPENDENCY_ID" BIGINT, - "FROM_SCOPE" VARCHAR(3), - "TO_SCOPE" VARCHAR(3), - "CREATED_AT" BIGINT -); - CREATE TABLE "CHARACTERISTICS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(100), @@ -586,12 +568,6 @@ CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); -CREATE INDEX "DEPS_TO_SID" ON "DEPENDENCIES" ("TO_SNAPSHOT_ID"); - -CREATE INDEX "DEPS_FROM_SID" ON "DEPENDENCIES" ("FROM_SNAPSHOT_ID"); - -CREATE INDEX "DEPS_PRJ_SID" ON "DEPENDENCIES" ("PROJECT_SNAPSHOT_ID"); - CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index 454cebefd32..ae7a29fc062 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -103,27 +103,6 @@ - - delete from dependencies where from_snapshot_id in - - #{snapshotId} - - - - - delete from dependencies where to_snapshot_id in - - #{snapshotId} - - - - - delete from dependencies where project_snapshot_id in - - #{snapshotId} - - - delete from duplications_index where snapshot_id in diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java index 693ea65a447..337df8294cc 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java @@ -19,14 +19,13 @@ */ package org.sonar.core.purge; +import java.util.List; import org.apache.ibatis.session.SqlSession; import org.junit.Before; import org.junit.Test; import org.sonar.core.persistence.AbstractDaoTestCase; import org.sonar.core.persistence.MyBatis; -import java.util.List; - import static com.google.common.collect.Lists.newArrayList; public class PurgeCommandsTest extends AbstractDaoTestCase { @@ -51,7 +50,7 @@ public class PurgeCommandsTest extends AbstractDaoTestCase { } finally { MyBatis.closeQuietly(session); } - checkTables("shouldDeleteSnapshot", "snapshots", "project_measures", "duplications_index", "events", "dependencies"); + checkTables("shouldDeleteSnapshot", "snapshots", "project_measures", "duplications_index", "events"); } /** @@ -81,8 +80,7 @@ public class PurgeCommandsTest extends AbstractDaoTestCase { } finally { MyBatis.closeQuietly(session); } - checkTables("shouldPurgeSnapshot", - "snapshots", "project_measures", "duplications_index", "events", "dependencies"); + checkTables("shouldPurgeSnapshot", "snapshots", "project_measures", "duplications_index", "events"); } @Test diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml index 7a00cb1ef99..f17226a159a 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml @@ -22,9 +22,6 @@ person_id="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> - - - - - - - - - - - - - - - - - - - - - - - -