From: Julien Lancelot Date: Mon, 27 Nov 2017 13:30:30 +0000 (+0100) Subject: SONAR-10110 Remove LoadedTemplate DAO X-Git-Tag: 7.0-RC1~222 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40e2632fe600e837e92f008f80de902edf3ffffd;p=sonarqube.git SONAR-10110 Remove LoadedTemplate DAO --- diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 950cbde71b7..5a9d59c19ed 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -115,7 +115,7 @@ public class ComputeEngineContainerImplTest { assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 26 // level 1 - + 52 // content of DaoModule + + 51 // content of DaoModule + 3 // content of EsSearchModule + 67 // content of CorePropertyDefinitions + 1 // StopFlagContainer diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java b/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java index c5ec32904dd..c01be6b844a 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java @@ -37,6 +37,7 @@ public final class SqTables { "dashboards", "issue_filters", "issue_filter_favourites", + "loaded_templates", "measure_filters", "measure_filter_favourites", "resource_index", @@ -68,7 +69,6 @@ public final class SqTables { "internal_properties", "issues", "issue_changes", - "loaded_templates", "manual_measures", "metrics", "notifications", diff --git a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl index 9ad599b91fd..a4b54efd55e 100644 --- a/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -460,14 +460,6 @@ CREATE TABLE "METRICS" ( CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); -CREATE TABLE "LOADED_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(200), - "TEMPLATE_TYPE" VARCHAR(64) NOT NULL -); -CREATE INDEX "IX_LOADED_TEMPLATES_TYPE" ON "LOADED_TEMPLATES" ("TEMPLATE_TYPE"); - - CREATE TABLE "ISSUES" ( "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(50) UNIQUE NOT NULL, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java index e70920b964e..06a3216c6c7 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java @@ -39,7 +39,6 @@ import org.sonar.db.es.EsQueueDao; import org.sonar.db.event.EventDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; -import org.sonar.db.loadedtemplate.LoadedTemplateDao; import org.sonar.db.measure.MeasureDao; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.metric.MetricDao; @@ -105,7 +104,6 @@ public class DaoModule extends Module { InternalPropertiesDao.class, IssueChangeDao.class, IssueDao.class, - LoadedTemplateDao.class, MeasureDao.class, MetricDao.class, NotificationQueueDao.class, @@ -132,8 +130,7 @@ public class DaoModule extends Module { UserGroupDao.class, UserPermissionDao.class, UserTokenDao.class, - WebhookDeliveryDao.class) - ); + WebhookDeliveryDao.class)); @Override protected void configureModule() { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java index 5df791543f1..1cc3778af49 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java @@ -37,7 +37,6 @@ import org.sonar.db.es.EsQueueDao; import org.sonar.db.event.EventDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; -import org.sonar.db.loadedtemplate.LoadedTemplateDao; import org.sonar.db.measure.MeasureDao; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.metric.MetricDao; @@ -85,7 +84,6 @@ public class DbClient { private final OrganizationDao organizationDao; private final OrganizationMemberDao organizationMemberDao; private final QualityProfileDao qualityProfileDao; - private final LoadedTemplateDao loadedTemplateDao; private final PropertiesDao propertiesDao; private final InternalPropertiesDao internalPropertiesDao; private final SnapshotDao snapshotDao; @@ -147,7 +145,6 @@ public class DbClient { organizationDao = getDao(map, OrganizationDao.class); organizationMemberDao = getDao(map, OrganizationMemberDao.class); qualityProfileDao = getDao(map, QualityProfileDao.class); - loadedTemplateDao = getDao(map, LoadedTemplateDao.class); propertiesDao = getDao(map, PropertiesDao.class); internalPropertiesDao = getDao(map, InternalPropertiesDao.class); snapshotDao = getDao(map, SnapshotDao.class); @@ -232,10 +229,6 @@ public class DbClient { return qualityProfileDao; } - public LoadedTemplateDao loadedTemplateDao() { - return loadedTemplateDao; - } - public PropertiesDao propertiesDao() { return propertiesDao; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index bfb866e758d..03f2eb1a556 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -62,8 +62,6 @@ import org.sonar.db.issue.IssueChangeMapper; import org.sonar.db.issue.IssueDto; import org.sonar.db.issue.IssueMapper; import org.sonar.db.issue.ShortBranchIssueDto; -import org.sonar.db.loadedtemplate.LoadedTemplateDto; -import org.sonar.db.loadedtemplate.LoadedTemplateMapper; import org.sonar.db.measure.MeasureDto; import org.sonar.db.measure.MeasureMapper; import org.sonar.db.measure.custom.CustomMeasureDto; @@ -166,7 +164,6 @@ public class MyBatis implements Startable { confBuilder.loadAlias("KeyLongValue", KeyLongValue.class); confBuilder.loadAlias("Issue", IssueDto.class); confBuilder.loadAlias("ShortBranchIssue", ShortBranchIssueDto.class); - confBuilder.loadAlias("LoadedTemplate", LoadedTemplateDto.class); confBuilder.loadAlias("Measure", MeasureDto.class); confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class); confBuilder.loadAlias("Organization", OrganizationDto.class); @@ -223,7 +220,6 @@ public class MyBatis implements Startable { IsAliveMapper.class, IssueChangeMapper.class, IssueMapper.class, - LoadedTemplateMapper.class, MeasureMapper.class, MetricMapper.class, NotificationQueueMapper.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDao.java deleted file mode 100644 index 8e6d8ff54d8..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDao.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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.db.loadedtemplate; - -import org.sonar.db.Dao; -import org.sonar.db.DbSession; - -public class LoadedTemplateDao implements Dao { - - public int countByTypeAndKey(String type, String key, DbSession session) { - return session.getMapper(LoadedTemplateMapper.class).countByTypeAndKey(type, key); - } - - public void insert(LoadedTemplateDto loadedTemplateDto, DbSession session) { - session.getMapper(LoadedTemplateMapper.class).insert(loadedTemplateDto); - } - - public void delete(DbSession session, String type, String key) { - session.getMapper(LoadedTemplateMapper.class).delete(type, key); - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDto.java deleted file mode 100644 index e099e96b426..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDto.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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.db.loadedtemplate; - -import java.util.Objects; - -public final class LoadedTemplateDto { - - public static final String ONE_SHOT_TASK_TYPE = "ONE_SHOT_TASK"; - - private Long id; - private String key; - private String type; - - public LoadedTemplateDto() { - } - - public LoadedTemplateDto(String key, String type) { - this.key = key; - this.type = type; - } - - public Long getId() { - return id; - } - - public LoadedTemplateDto setId(Long l) { - this.id = l; - return this; - } - - public String getKey() { - return key; - } - - public LoadedTemplateDto setKey(String key) { - this.key = key; - return this; - } - - public String getType() { - return type; - } - - public LoadedTemplateDto setType(String type) { - this.type = type; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - LoadedTemplateDto other = (LoadedTemplateDto) o; - return Objects.equals(id, other.id) && Objects.equals(key, other.key) && Objects.equals(type, other.type); - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateMapper.java deleted file mode 100644 index 20b5f278eee..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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.db.loadedtemplate; - -import org.apache.ibatis.annotations.Param; - -public interface LoadedTemplateMapper { - - int countByTypeAndKey(@Param("type") String type, @Param("key") String key); - - void insert(LoadedTemplateDto template); - - void delete(@Param("type") String type, @Param("key") String key); -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/package-info.java b/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/package-info.java deleted file mode 100644 index 081c236d7a7..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.db.loadedtemplate; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml deleted file mode 100644 index 935dee74972..00000000000 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - INSERT INTO loaded_templates (kee, template_type) - VALUES (#{key}, #{type}) - - - - delete from loaded_templates where kee = #{key} AND template_type = #{type} - - diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/DaoModuleTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/DaoModuleTest.java index 5ff22c1e2fd..d79b8f289e8 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/DaoModuleTest.java @@ -30,6 +30,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 52); + assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 51); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest.java deleted file mode 100644 index 1be4a70d918..00000000000 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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.db.loadedtemplate; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class LoadedTemplateDaoTest { - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - private LoadedTemplateDao underTest = dbTester.getDbClient().loadedTemplateDao(); - private DbSession dbSession = dbTester.getSession(); - - @Test - public void shouldCountByTypeAndKey() { - dbTester.prepareDbUnit(getClass(), "shouldCountByTypeAndKey.xml"); - - assertThat(underTest.countByTypeAndKey("DASHBOARD", "HOTSPOTS", dbSession)).isEqualTo(1); - assertThat(underTest.countByTypeAndKey("DASHBOARD", "UNKNOWN", dbSession)).isEqualTo(0); - assertThat(underTest.countByTypeAndKey("PROFILE", "HOTSPOTS", dbSession)).isEqualTo(0); - } - - @Test - public void shouldInsert() { - dbTester.prepareDbUnit(getClass(), "shouldInsert.xml"); - - LoadedTemplateDto template = new LoadedTemplateDto("SQALE", "DASHBOARD"); - underTest.insert(template, dbSession); - dbSession.commit(); - - dbTester.assertDbUnit(getClass(), "shouldInsert-result.xml", "loaded_templates"); - } -} diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldCountByTypeAndKey.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldCountByTypeAndKey.xml deleted file mode 100644 index f4b6b01f4ab..00000000000 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldCountByTypeAndKey.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert-result.xml deleted file mode 100644 index 6881dd82799..00000000000 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert-result.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert.xml deleted file mode 100644 index 871dedcb5e9..00000000000 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert.xml +++ /dev/null @@ -1,3 +0,0 @@ - - -