]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 remove unused methods in Q profile DAOs
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 11 Jun 2014 10:05:02 +0000 (12:05 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 11 Jun 2014 11:35:32 +0000 (13:35 +0200)
15 files changed:
sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java
sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java
sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java
sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml
sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml
sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java
sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java
sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java
sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java

index 5c2396d459b9840e8b50b40544c545bdbc93cb7a..71cd5ba07227f5729473c5f10d3f412f06aa0ff6 100644 (file)
@@ -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);
 
index 5482369922f21a25a92175a2e058e3c99bf72430..8cf36f15f6182955e57ea6e7937f984411eb8967 100644 (file)
@@ -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)}
index ae4b6b3e38779aad350fa913ff7198d37bb3d76c..547ad9d8cb627eae763f5c1e2b56344137520917 100644 (file)
@@ -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);
index bdd5c15f66b391eaa5d8a3a64ee6551b635d080f..4da154a42260ebbdb2c8c0b226e10c62f8916605 100644 (file)
     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"/>
     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"/>
     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"/>
index a764f207187d3db662a549021055ebbef0eac215..370eb6b006aa7723aa8a363228d8c98ced89ec4d 100644 (file)
     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
index e62ce0abdce3c80156bd9c922ce1529c0d428960..d539ddc9e08bcdadee5489db15c8dfe3ee614d9d 100644 (file)
@@ -202,13 +202,6 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase {
     assertThat(dto2.getParent()).isEqualTo("Parent");
   }
 
-  @Test
-  public void count_children() {
-    setupData("inheritance");
-
-    assertThat(dao.countChildren("Parent", "java")).isEqualTo(2);
-  }
-
   @Test
   public void select_projects() {
     setupData("projects");
index 8d890cdab0a713d0ff9358fd038821387178dd8a..081c7cc5863d8556069c595755628fbff81cbaec 100644 (file)
@@ -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
index c118eb7332be3a30f821a8119cf01d1f25b52693..6aaa2898b31d277a0b54f82bf09141004a822e20 100644 (file)
@@ -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.
    *
index 444117e6bf67305e7b63180e3bbcee8f84866fdd..1e11d2b9296c2f4dbf0f15e8ed387aa5ae78e1a1 100644 (file)
@@ -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);
index b24fa33c6279844b236c8fa6220a7030939fcb25..8d61d0128e17c8e06eba9876877173e3204e65d4 100644 (file)
@@ -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());
-  }
 }
index dbae7bcfcda1bcd5b25850a79e24eaf8bfec007a..329ddf606f1d74afe9c12f7513b57b538a30ae6f 100644 (file)
@@ -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);
   }
index eec11a65007314d2f5a686e4be7b1edbf29bc895..156f964835164f279de4556329a847c4aaf62d43 100644 (file)
@@ -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
index ffe9d347ef440382d487c730f3d52edcda52da7e..1020dcac187e7b4ec13d87fa4113381d13e138c2 100644 (file)
@@ -139,12 +139,6 @@ public class QProfileLookupTest {
     verify(dao).selectChildren("Sonar Way", "java", session);
   }
 
-  @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(
index e20bd4706d86b837cea7945637e1a5bc6a9f71cb..bb364bf55279da5887531d8d612875e41cc8acd7 100644 (file)
@@ -111,13 +111,6 @@ public class QProfilesTest {
     verify(profileLookup).ancestors(profile);
   }
 
-  @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();
index cf47f60aa4f6a2ea81014e2023ead80fd00a0489..8eb8258051058d8e247e0dd2c51c1b7d194e4009 100644 (file)
@@ -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;
@@ -319,16 +318,6 @@ public class RuleDaoTest extends AbstractDaoTestCase {
     assertThat(ruleDto.getRuleId()).isEqualTo(1);
   }
 
-  @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");