From bd78c6d9b0856cfae5e7a446647e350eb186ed67 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 24 Mar 2017 07:22:51 +0100 Subject: [PATCH] Drop unused SQL requests from ActiveRuleDao and QualityProfileDao --- .../db/qualityprofile/ActiveRuleDao.java | 8 ++-- .../db/qualityprofile/QualityProfileDao.java | 23 ----------- .../qualityprofile/QualityProfileMapper.java | 12 ------ .../qualityprofile/QualityProfileMapper.xml | 34 +--------------- .../db/qualityprofile/ActiveRuleDaoTest.java | 13 ------- .../qualityprofile/QualityProfileDaoTest.java | 39 ------------------- .../server/qualityprofile/QProfileLookup.java | 2 +- .../qualityprofile/ws/DeleteActionTest.java | 2 +- 8 files changed, 7 insertions(+), 126 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java index 246e79feb80..ffa57508df2 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDao.java @@ -59,10 +59,6 @@ public class ActiveRuleDao implements Dao { throw new RowNotFoundException(String.format("Active rule with key '%s' does not exist", key)); } - public List selectByKeys(DbSession dbSession, List keys) { - return executeLargeInputs(keys, mapper(dbSession)::selectByKeys); - } - public List selectByRuleId(DbSession dbSession, int ruleId) { return mapper(dbSession).selectByRuleId(ruleId); } @@ -140,6 +136,10 @@ public class ActiveRuleDao implements Dao { return null; } + /** + * @deprecated currently used only by tests + */ + @Deprecated public List selectAllParams(DbSession dbSession) { return mapper(dbSession).selectAllParams(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index be1e23a7aca..89aa8281d90 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -97,11 +97,6 @@ public class QualityProfileDao implements Dao { mapper.update(profile); } - public void delete(DbSession session, int profileId) { - QualityProfileMapper mapper = mapper(session); - mapper.delete(profileId); - } - public List selectDefaultProfiles(DbSession session, OrganizationDto organization, Collection languageKeys) { return executeLargeInputs(languageKeys, chunk -> mapper(session).selectDefaultProfiles(organization.getUuid(), chunk)); } @@ -124,16 +119,6 @@ public class QualityProfileDao implements Dao { return mapper(dbSession).selectByLanguage(organization.getUuid(), language); } - @CheckForNull - public QualityProfileDto selectById(DbSession session, int id) { - return mapper(session).selectById(id); - } - - @CheckForNull - public QualityProfileDto selectParentById(DbSession session, int childId) { - return mapper(session).selectParentById(childId); - } - public List selectChildren(DbSession session, String key) { return mapper(session).selectChildren(key); } @@ -159,10 +144,6 @@ public class QualityProfileDao implements Dao { return executeLargeInputs(languageKeys, input -> mapper(session).selectByNameAndLanguages(organization.getUuid(), name, input)); } - public List selectUuidsOfAssociatedProjects(DbSession dbSession, String profileKey) { - return mapper(dbSession).selectUuidsOfAssociatedProjects(profileKey); - } - public Map countProjectsByProfileKey(DbSession dbSession, OrganizationDto organization) { return KeyLongValue.toMap(mapper(dbSession).countProjectsByProfileKey(organization.getUuid())); } @@ -179,10 +160,6 @@ public class QualityProfileDao implements Dao { mapper(session).updateProjectProfileAssociation(projectUuid, newProfileKey, oldProfileKey); } - public void deleteAllProjectProfileAssociation(String profileKey, DbSession session) { - mapper(session).deleteAllProjectProfileAssociation(profileKey); - } - public void deleteProjectAssociationsByProfileKeys(DbSession dbSession, Collection profileKeys) { QualityProfileMapper mapper = mapper(dbSession); DatabaseUtils.executeLargeUpdates(profileKeys, mapper::deleteProjectAssociationByProfileKeys); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java index b3c7f66f868..16c13f77431 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java @@ -31,8 +31,6 @@ public interface QualityProfileMapper { void update(QualityProfileDto dto); - void delete(int id); - void deleteByKeys(@Param("profileKeys") Collection profileKeys); List selectAll(@Param("organizationUuid") String organizationUuid); @@ -47,9 +45,6 @@ public interface QualityProfileMapper { List selectByNameAndLanguages(@Param("organizationUuid") String organizationUuid, @Param("name") String name, @Param("languages") List languages); - @CheckForNull - QualityProfileDto selectById(@Param("id") Integer id); - @CheckForNull QualityProfileDto selectByKey(String key); @@ -59,15 +54,10 @@ public interface QualityProfileMapper { // INHERITANCE - @CheckForNull - QualityProfileDto selectParentById(int childId); - List selectChildren(String key); // PROJECTS - List selectUuidsOfAssociatedProjects(@Param("profileKey") String profileKey); - List countProjectsByProfileKey(@Param("organizationUuid") String organizationUuid); QualityProfileDto selectByProjectAndLanguage(@Param("projectKey") String projectKey, @Param("language") String language); @@ -81,8 +71,6 @@ public interface QualityProfileMapper { void deleteProjectProfileAssociation(@Param("projectUuid") String projectUuid, @Param("profileKey") String profileKey); - void deleteAllProjectProfileAssociation(@Param("profileKey") String profileKey); - void deleteProjectAssociationByProfileKeys(@Param("profileKeys") Collection profileKeys); List selectSelectedProjects(@Param("profileKey") String profileKey, @Param("nameQuery") String nameQuery); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml index e1297149508..2547f35611b 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml @@ -47,10 +47,6 @@ WHERE id=#{id} - - DELETE FROM rules_profiles WHERE id=#{id} - - delete from rules_profiles where kee in @@ -82,9 +78,7 @@ FROM rules_profiles p WHERE p.name=#{name, jdbcType=VARCHAR} AND p.language IN #{language, jdbcType=VARCHAR} - - AND p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} - + AND p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} - - - - - -