]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10110 Remove LoadedTemplate DAO
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 27 Nov 2017 13:30:30 +0000 (14:30 +0100)
committerEric Hartmann <hartmann.eric@gmail.Com>
Mon, 4 Dec 2017 12:44:55 +0000 (13:44 +0100)
16 files changed:
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java
server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl
server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java
server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java
server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDao.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateDto.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/LoadedTemplateMapper.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/loadedtemplate/package-info.java [deleted file]
server/sonar-db-dao/src/main/resources/org/sonar/db/loadedtemplate/LoadedTemplateMapper.xml [deleted file]
server/sonar-db-dao/src/test/java/org/sonar/db/DaoModuleTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest.java [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldCountByTypeAndKey.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert-result.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/loadedtemplate/LoadedTemplateDaoTest/shouldInsert.xml [deleted file]

index 950cbde71b7e19a2cec704f0fe51fc9f157dc13d..5a9d59c19edbbab2c1c06a31182a34266d734f5e 100644 (file)
@@ -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
index c5ec32904dd2e7a18215d9b9670dc9191d8f6bd3..c01be6b844ad6292ad7b9bd22dc092b862ed5d58 100644 (file)
@@ -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",
index 9ad599b91fda96b4fa3c8c4d1598d5dcc7c678b6..a4b54efd55eaa66e8b31ebaa01d8574a2ffc2593 100644 (file)
@@ -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,
index e70920b964e4d0226f3810b403bd01beecefbec6..06a3216c6c754385eb599442cd95dd78a93fcf03 100644 (file)
@@ -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() {
index 5df791543f19096994b22bd489051a1c603653c1..1cc3778af491740603b30de82d4b5c2a51f0161e 100644 (file)
@@ -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;
   }
index bfb866e758d436dc10dc3f08789fcbb5de3350af..03f2eb1a5567bc5834e6aca07cdb4f77ea760f88 100644 (file)
@@ -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 (file)
index 8e6d8ff..0000000
+++ /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 (file)
index e099e96..0000000
+++ /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 (file)
index 20b5f27..0000000
+++ /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 (file)
index 081c236..0000000
+++ /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 (file)
index 935dee7..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.db.loadedtemplate.LoadedTemplateMapper">
-
-  <resultMap id="loadedTemplateResultMap" type="LoadedTemplate">
-    <result property="id" column="id"/>
-    <result property="key" column="kee"/>
-    <result property="type" column="template_type"/>
-  </resultMap>
-
-  <select id="countByTypeAndKey" parameterType="map" resultType="int">
-    SELECT count(1)
-    FROM loaded_templates
-    WHERE kee = #{key} AND template_type = #{type}
-  </select>
-
-  <insert id="insert" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
-    INSERT INTO loaded_templates (kee, template_type)
-    VALUES (#{key}, #{type})
-  </insert>
-
-  <delete id="delete" parameterType="map">
-    delete from loaded_templates where kee = #{key} AND template_type = #{type}
-  </delete>
-</mapper>
index 5ff22c1e2fd0b50fdaeec8c269490a1a7244c124..d79b8f289e8ed13c79b0c5b166088d8af40d56fb 100644 (file)
@@ -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 (file)
index 1be4a70..0000000
+++ /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 (file)
index f4b6b01..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<dataset>
-
-  <loaded_templates
-    id="1"
-    kee="HOTSPOTS"
-    template_type="DASHBOARD"/>
-
-</dataset>
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 (file)
index 6881dd8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<dataset>
-
-  <loaded_templates
-    id="1"
-    kee="SQALE"
-    template_type="DASHBOARD"/>
-
-</dataset>
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 (file)
index 871dedc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-
-</dataset>