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;
DefaultI18n.class,
RuleI18nManager.class,
MeasuresDao.class,
- RulesDao.class,
HibernateUserFinder.class,
SemaphoreUpdater.class,
SemaphoresImpl.class,
+++ /dev/null
-/*
- * 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);
- }
-
-}
+++ /dev/null
-/*
- * 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());
- }
-
-}
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;
// 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);