diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-12 18:20:59 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-12 18:21:09 +0200 |
commit | 980a535929f5d4a1944a14882d74fab4a0a54693 (patch) | |
tree | 52f5cbd16d832a9c18f9d284f0e22f860ce22414 | |
parent | 58e9546400d146a4fb64f5a7ef57d3804f50b318 (diff) | |
download | sonarqube-980a535929f5d4a1944a14882d74fab4a0a54693.tar.gz sonarqube-980a535929f5d4a1944a14882d74fab4a0a54693.zip |
SONAR-5007 delete unused class RulesDao
4 files changed, 0 insertions, 103 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java index 0e954b0fe19..693be2183a2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java @@ -55,7 +55,6 @@ import org.sonar.core.purge.PurgeProfiler; import org.sonar.core.rule.CacheRuleFinder; import org.sonar.core.user.HibernateUserFinder; import org.sonar.jpa.dao.MeasuresDao; -import org.sonar.jpa.dao.RulesDao; import org.sonar.jpa.session.DefaultDatabaseConnector; import org.sonar.jpa.session.JpaDatabaseSession; @@ -147,7 +146,6 @@ public class BootstrapContainer extends ComponentContainer { DefaultI18n.class, RuleI18nManager.class, MeasuresDao.class, - RulesDao.class, HibernateUserFinder.class, SemaphoreUpdater.class, SemaphoresImpl.class, diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java deleted file mode 100644 index 1a47b332c01..00000000000 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.jpa.dao; - -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleParam; - -public class RulesDao extends BaseDao { - - public RulesDao(DatabaseSession session) { - super(session); - } - - public Rule getRuleByKey(String repositoryKey, String ruleKey) { - DatabaseSession session = getSession(); - return (Rule) session.getSingleResult( - session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.key=:key and r.pluginName=:pluginName and r.status<>:status") - .setParameter("key", ruleKey) - .setParameter("pluginName", repositoryKey) - .setParameter("status", Rule.STATUS_REMOVED - ), - null); - } - - public RuleParam getRuleParam(Rule rule, String paramKey) { - return getSession().getSingleResult(RuleParam.class, "rule", rule, "key", paramKey); - } - -} diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java deleted file mode 100644 index e8256331e79..00000000000 --- a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.jpa.dao; - -import org.junit.Before; -import org.junit.Test; -import org.sonar.api.rules.Rule; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -public class RulesDaoTest extends AbstractDbUnitTestCase { - - private RulesDao rulesDao; - - @Before - public void setup() { - rulesDao = new RulesDao(getSession()); - } - - @Test - public void shouldGetRuleWithRuleKeyAndPluginKey() { - setupData("shouldGetRuleWithRuleKeyAndPluginKey"); - - Rule rule = rulesDao.getRuleByKey("plugin", "checkstyle.rule1"); - assertThat(rule, notNullValue()); - assertThat(rule.getId(), notNullValue()); - - Rule rule2 = rulesDao.getRuleByKey("plugin", "key not found"); - assertThat(rule2, nullValue()); - } - -} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java index ba51176ec2c..4cd1601e59a 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java @@ -73,7 +73,6 @@ import org.sonar.core.timemachine.Periods; import org.sonar.core.user.DefaultUserFinder; import org.sonar.core.user.HibernateUserFinder; import org.sonar.jpa.dao.MeasuresDao; -import org.sonar.jpa.dao.RulesDao; import org.sonar.jpa.session.DatabaseSessionFactory; import org.sonar.jpa.session.DatabaseSessionProvider; import org.sonar.jpa.session.DefaultDatabaseConnector; @@ -445,7 +444,6 @@ class ServerComponents { // rule pico.addSingleton(AnnotationRuleParser.class); pico.addSingleton(XMLRuleParser.class); - pico.addComponent(RulesDao.class, false); pico.addSingleton(DefaultRuleFinder.class); pico.addSingleton(RuleOperations.class); pico.addSingleton(RubyRuleService.class); |