diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-11 12:05:02 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-11 13:35:32 +0200 |
commit | 433993d355aa6da5914a0cd525659748aa741ce3 (patch) | |
tree | a5e08b45c68df971c97426e65dde36148ddef8a6 | |
parent | ca373f36b8517d938c0a9c8d27d484c33ab988f5 (diff) | |
download | sonarqube-433993d355aa6da5914a0cd525659748aa741ce3.tar.gz sonarqube-433993d355aa6da5914a0cd525659748aa741ce3.zip |
SONAR-5007 remove unused methods in Q profile DAOs
15 files changed, 3 insertions, 155 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java index 5c2396d459b..71cd5ba0722 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java @@ -33,16 +33,9 @@ public interface ActiveRuleMapper { void delete(int activeRuleId); - void deleteFromRule(int ruleId); - - void deleteFromProfile(int profileId); - @CheckForNull ActiveRuleDto selectById(Integer id); - @CheckForNull - ActiveRuleDto selectByProfileAndRule(@Param("profileId") int profileId, @Param("ruleId") int ruleId); - List<ActiveRuleDto> selectByRuleId(int ruleId); List<ActiveRuleDto> selectByProfileId(int profileId); @@ -59,13 +52,6 @@ public interface ActiveRuleMapper { void deleteParameter(int activeRuleParamId); - void deleteParametersWithParamId(int id); - - void deleteParametersFromProfile(int profileId); - - @CheckForNull - ActiveRuleParamDto selectParamById(int activeRuleParamId); - @CheckForNull ActiveRuleParamDto selectParamByActiveRuleAndKey(@Param("activeRuleId") int activeRuleId, @Param("key") String key); diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java index 5482369922f..8cf36f15f61 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java @@ -271,19 +271,6 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } } - public int countChildren(String name, String language, DbSession session) { - return session.getMapper(QualityProfileMapper.class).countChildren(name, language); - } - - public int countChildren(String name, String language) { - DbSession session = mybatis.openSession(false); - try { - return countChildren(name, language, session); - } finally { - MyBatis.closeQuietly(session); - } - } - /** * @deprecated Replaced by * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java index ae4b6b3e387..547ad9d8cb6 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java @@ -55,8 +55,6 @@ public interface QualityProfileMapper { List<QualityProfileDto> selectChildren(@Param("name") String name, @Param("language") String language); - int countChildren(@Param("name") String name, @Param("language") String language); - // PROJECTS List<ComponentDto> selectProjects(@Param("value") String propertyValue, @Param("key") String propertyKey); diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml index bdd5c15f66b..4da154a4226 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml @@ -67,14 +67,6 @@ DELETE FROM active_rules WHERE id=#{id} </update> - <update id="deleteFromRule" parameterType="Integer"> - DELETE FROM active_rules WHERE rule_id=#{ruleId} - </update> - - <update id="deleteFromProfile" parameterType="Integer"> - DELETE FROM active_rules WHERE profile_id=#{profileId} - </update> - <select id="selectByIds" parameterType="map" resultType="ActiveRule"> select <include refid="activeRuleColumns"/> @@ -118,16 +110,6 @@ AND qp.language = #{lang} </select> - <select id="selectByProfileAndRule" parameterType="map" resultType="ActiveRule"> - SELECT <include refid="activeRuleColumns"/> - FROM active_rules a - <include refid="activeRuleJoin"/> - <where> - AND a.profile_id=#{profileId} - AND a.rule_id=#{ruleId} - </where> - </select> - <select id="selectByRuleId" parameterType="Integer" resultType="ActiveRule"> SELECT <include refid="activeRuleKeyColumns"/> @@ -180,26 +162,10 @@ DELETE FROM active_rule_parameters WHERE active_rule_id=#{id} </update> - <update id="deleteParametersWithParamId" parameterType="Integer"> - DELETE FROM active_rule_parameters WHERE rules_parameter_id=#{id} - </update> - - <update id="deleteParametersFromProfile" parameterType="Integer"> - DELETE FROM active_rule_parameters WHERE active_rule_id IN (SELECT id FROM active_rules WHERE profile_id=#{profileId}) - </update> - <update id="deleteParameter" parameterType="Integer"> DELETE FROM active_rule_parameters WHERE id=#{id} </update> - <select id="selectParamById" parameterType="Integer" resultType="ActiveRuleParam"> - SELECT <include refid="activeRuleParamColumns"/> - FROM active_rule_parameters p - <where> - AND p.id=#{id} - </where> - </select> - <select id="selectParamsByActiveRuleId" parameterType="Integer" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml index a764f207187..370eb6b006a 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml @@ -79,15 +79,6 @@ ORDER BY p.name </select> - <select id="countChildren" parameterType="map" resultType="Integer"> - SELECT count(p.id) - FROM rules_profiles p - <where> - AND p.parent_name=#{name} - AND p.language=#{language} - </where> - </select> - <select id="selectDefaultProfile" parameterType="Integer" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java index e62ce0abdce..d539ddc9e08 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java @@ -203,13 +203,6 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { } @Test - public void count_children() { - setupData("inheritance"); - - assertThat(dao.countChildren("Parent", "java")).isEqualTo(2); - } - - @Test public void select_projects() { setupData("projects"); diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java index 8d890cdab0a..081c7cc5863 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java @@ -160,19 +160,6 @@ public class QProfileLookup implements ServerComponent { } } - public int countChildren(QProfile profile) { - DbSession session = myBatis.openSession(false); - try { - return countChildren(profile, session); - } finally { - MyBatis.closeQuietly(session); - } - } - - public int countChildren(QProfile profile, DbSession session) { - return dao.countChildren(profile.name(), profile.language(), session); - } - private List<QProfile> toQProfiles(List<QualityProfileDto> dtos) { return newArrayList(Iterables.transform(dtos, new Function<QualityProfileDto, QProfile>() { @Override diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java index c118eb7332b..6aaa2898b31 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java @@ -150,6 +150,9 @@ public class QProfileService implements ServerComponent { reset.resetLanguage(lang); } + /** + * Currently used by Ruby on Rails + */ public Collection<String> builtInProfileNamesForLanguage(String lang) { return reset.builtInProfileNamesForLanguage(lang); } @@ -169,11 +172,6 @@ public class QProfileService implements ServerComponent { // TODO } - //public void create(NewQualityProfile newProfile) { - // TODO - //verifyAdminPermission(); - //} - /** * Set or unset parent profile. * diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java index 444117e6bf6..1e11d2b9296 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java @@ -73,10 +73,6 @@ public class QProfiles implements ServerComponent { return profileLookup.defaultProfile(language); } - public int countChildren(QProfile profile) { - return profileLookup.countChildren(profile); - } - public QProfileResult newProfile(String name, String language, Map<String, String> xmlProfilesByPlugin) { checkProfileNameParam(name); Validation.checkMandatoryParameter(language, LANGUAGE_PARAM); diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java index b24fa33c627..8d61d0128e1 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java @@ -35,7 +35,6 @@ import org.sonar.core.qualityprofile.db.QualityProfileDao; import org.sonar.core.qualityprofile.db.QualityProfileKey; import org.sonar.core.rule.RuleDto; import org.sonar.server.db.BaseDao; -import org.sonar.server.qualityprofile.QProfile; import org.sonar.server.rule.db.RuleDao; import org.sonar.server.search.IndexDefinition; import org.sonar.server.search.action.IndexAction; @@ -207,14 +206,4 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti ActiveRuleDto activeRule = getNullableByKey(session, key); return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name); } - - @Deprecated - public void removeParamByProfile(DbSession session, QProfile profile) { - mapper(session).deleteParametersFromProfile(profile.id()); - } - - @Deprecated - public void deleteByProfile(DbSession session, QProfile profile) { - mapper(session).deleteFromProfile(profile.id()); - } } diff --git a/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java b/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java index dbae7bcfcda..329ddf606f1 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java @@ -36,7 +36,6 @@ import org.sonar.server.search.action.KeyIndexAction; import javax.annotation.CheckForNull; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -159,19 +158,6 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { return mapper(session).selectParamsByRuleKey(key); } - public List<RuleParamDto> findRuleParamsByRules(DbSession session, List<RuleDto> ruleDtos) { - List<RuleParamDto> ruleParamDtos = new ArrayList<RuleParamDto>(); - for (RuleDto rule : ruleDtos) { - ruleParamDtos.addAll(findRuleParamsByRuleKey(session, rule.getKey())); - } - return ruleParamDtos; - } - - public RuleParamDto getRuleParamByRuleAndParamKey(DbSession session, RuleDto rule, String key) { - Preconditions.checkNotNull(rule.getId(), "Rule is not persisted"); - return mapper(session).selectParamByRuleAndKey(rule.getId(), key); - } - public List<RuleDto> findRulesByDebtSubCharacteristicId(DbSession session, int id) { return mapper(session).selectBySubCharacteristicId(id); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb index eec11a65007..156f9648351 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb @@ -58,9 +58,4 @@ module ProfilesHelper def profile_rules_count(qProfile) Internal.quality_profiles.countProfileRules(qProfile).to_i end - - def children_count(qProfile) - Internal.quality_profiles.countChildren(qProfile).to_i - end - end diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java index ffe9d347ef4..1020dcac187 100644 --- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java +++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java @@ -140,12 +140,6 @@ public class QProfileLookupTest { } @Test - public void count_children_profiles() throws Exception { - search.countChildren(new QProfile().setName("Sonar Way").setLanguage("java")); - verify(dao).countChildren("Sonar Way", "java", session); - } - - @Test public void default_profile() throws Exception { when(dao.selectDefaultProfile("java", "sonar.profile.java", session)).thenReturn( new QualityProfileDto().setId(1).setName("Sonar Way with Findbugs").setLanguage("java").setParent("Sonar Way").setVersion(1).setUsed(false) diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java index e20bd4706d8..bb364bf5527 100644 --- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java @@ -112,13 +112,6 @@ public class QProfilesTest { } @Test - public void count_children() throws Exception { - QProfile profile = new QProfile(); - qProfiles.countChildren(profile); - verify(profileLookup).countChildren(profile); - } - - @Test public void create_new_profile() throws Exception { Map<String, String> xmlProfilesByPlugin = newHashMap(); qProfiles.newProfile("Default", "java", xmlProfilesByPlugin); diff --git a/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java b/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java index cf47f60aa4f..8eb82580510 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java @@ -37,7 +37,6 @@ import org.sonar.core.rule.RuleParamDto; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -320,16 +319,6 @@ public class RuleDaoTest extends AbstractDaoTestCase { } @Test - public void select_parameters_by_rule_ids() throws Exception { - setupData("select_parameters_by_rule_ids"); - - RuleDto rule1 = dao.getById(session, 1); - RuleDto rule2 = dao.getById(session, 2); - assertThat(dao.findRuleParamsByRules(session, newArrayList(rule1, rule2))).hasSize(2); - assertThat(dao.findRuleParamsByRules(session, newArrayList(rule1))).hasSize(1); - } - - @Test public void insert_parameter() { setupData("insert_parameter"); |