Both of them have been deprecated long time ago.
}
private void checkCorrectServerId() {
- String remoteServerId = null;
+ String remoteServerId;
try {
remoteServerId = remoteServer.getServerId();
} catch (IOException e) {
import org.sonar.api.resources.Languages;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.rules.DefaultRulesManager;
import org.sonar.api.utils.IocContainer;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.*;
import org.sonar.batch.phases.Phases;
import org.sonar.batch.phases.PhasesTimeProfiler;
import org.sonar.core.qualitymodel.DefaultModelFinder;
-import org.sonar.jpa.dao.DaoFacade;
import org.sonar.jpa.dao.ProfilesDao;
import org.sonar.jpa.dao.RulesDao;
}
addCoreSingleton(DefaultProjectClasspath.class);
addCoreSingleton(DefaultProjectFileSystem2.class);
- addCoreSingleton(DaoFacade.class);
addCoreSingleton(RulesDao.class);
if (!dryRun) {
addCoreSingleton(TimeMachineConfiguration.class);
addCoreSingleton(org.sonar.api.database.daos.MeasuresDao.class);
addCoreSingleton(ProfilesDao.class);
- addCoreSingleton(DefaultRulesManager.class);
addCoreSingleton(DefaultSensorContext.class);
addCoreSingleton(Languages.class);
addCoreSingleton(BatchExtensionDictionnary.class);
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.jpa.dao;
-
-public class DaoFacade {
-
- private final RulesDao rulesDao;
- private final MeasuresDao measuresDao;
- private final ProfilesDao profilesDao;
-
- public DaoFacade(ProfilesDao profilesDao, RulesDao rulesDao, MeasuresDao measuresDao) {
- super();
- this.rulesDao = rulesDao;
- this.measuresDao = measuresDao;
- this.profilesDao = profilesDao;
- }
-
- public RulesDao getRulesDao() {
- return rulesDao;
- }
-
- public ProfilesDao getProfilesDao() {
- return profilesDao;
- }
-
- public MeasuresDao getMeasuresDao() {
- return measuresDao;
- }
-}
import org.sonar.core.persistence.DatabaseCommands;
import org.sonar.core.persistence.InMemoryDatabase;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.jpa.dao.DaoFacade;
-import org.sonar.jpa.dao.MeasuresDao;
-import org.sonar.jpa.dao.ProfilesDao;
-import org.sonar.jpa.dao.RulesDao;
import org.sonar.jpa.session.DatabaseSessionFactory;
import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.JpaDatabaseSession;
public abstract class AbstractDbUnitTestCase {
private JpaDatabaseSession session;
- private DaoFacade dao;
private IDatabaseTester databaseTester;
private IDatabaseConnection connection;
private static Database database;
return myBatis;
}
- public DaoFacade getDao() {
- if (dao == null) {
- dao = new DaoFacade(new ProfilesDao(session), new RulesDao(session), new MeasuresDao(session));
- }
- return dao;
- }
-
public DatabaseSession getSession() {
return session;
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.rules;
-
-import com.google.common.collect.Maps;
-import org.sonar.jpa.dao.RulesDao;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A class to manage and access rules defined in Sonar.
- *
- * @deprecated UGLY CLASS
- */
-@Deprecated
-public class DefaultRulesManager extends RulesManager {
-
- private final Map<String, Map<String, Rule>> rulesByPluginAndKey = Maps.newHashMap();
- private final RulesDao rulesDao;
-
- public DefaultRulesManager(RulesDao dao) {
- this.rulesDao = dao;
- }
-
- /**
- * Gets a list of rules indexed by their key for a given plugin
- *
- * @param pluginKey the plugin key
- * @return a Map with the rule key and the rule
- */
- public Map<String, Rule> getPluginRulesIndexedByKey(String pluginKey) {
- Map<String, Rule> rulesByKey = rulesByPluginAndKey.get(pluginKey);
- if (rulesByKey == null) {
- rulesByKey = new HashMap<String, Rule>();
- List<Rule> rules = rulesDao.getRulesByPlugin(pluginKey);
- if (rules != null) {
- for (Rule rule : rules) {
- rulesByKey.put(rule.getKey(), rule);
- }
- }
- rulesByPluginAndKey.put(pluginKey, rulesByKey);
- }
- return rulesByKey;
- }
-
- /**
- * Gets a rule belonging to a defined plugin based on its key
- *
- * @param pluginKey the plugin key
- * @param ruleKey the rule key
- * @return the rule
- */
- @Override
- public Rule getPluginRule(String pluginKey, String ruleKey) {
- Map<String, Rule> rulesByKey = getPluginRulesIndexedByKey(pluginKey);
- return rulesByKey.get(ruleKey);
- }
-
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.rules;
-
-/**
- * @deprecated since 2.3
- */
-@Deprecated
-public abstract class RulesManager {
-
- /**
- * Gets a rule belonging to a defined plugin based on its key
- *
- * @param pluginKey the plugin key
- * @param ruleKey the rule key
- * @return the rule
- */
- public abstract Rule getPluginRule(String pluginKey, String ruleKey);
-}
import org.sonar.api.resources.Languages;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.rules.AnnotationRuleParser;
-import org.sonar.api.rules.DefaultRulesManager;
import org.sonar.api.rules.XMLRuleParser;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.IocContainer;
import org.sonar.core.review.workflow.Workflow;
import org.sonar.core.rule.DefaultRuleFinder;
import org.sonar.core.user.DefaultUserFinder;
-import org.sonar.jpa.dao.DaoFacade;
import org.sonar.jpa.dao.MeasuresDao;
import org.sonar.jpa.dao.ProfilesDao;
import org.sonar.jpa.dao.RulesDao;
servicesContainer.addComponent(MeasuresDao.class, false);
servicesContainer.addComponent(org.sonar.api.database.daos.MeasuresDao.class, false);
servicesContainer.addComponent(ProfilesDao.class, false);
- servicesContainer.addComponent(DaoFacade.class, false);
- servicesContainer.addComponent(DefaultRulesManager.class, false);
servicesContainer.addComponent(ProfilesManager.class, false);
servicesContainer.addComponent(Backup.class, false);
servicesContainer.addSingleton(SecurityRealmFactory.class);
@Test
public void shouldImportMetrics() {
- MeasuresDao measuresDao = getDao().getMeasuresDao();
+ MeasuresDao measuresDao = new MeasuresDao(getSession());
Collection<Metric> oldMetrics = createMetrics();
measuresDao.registerMetrics(oldMetrics);
private void verify() {
assertThat(getSession().getResults(Rule.class).size(), is(2));
- Rule importedRule = getDao().getRulesDao().getRuleByKey("repo", "key2");
+ Rule importedRule = new RulesDao(getSession()).getRuleByKey("repo", "key2");
assertThat(importedRule.getParent(), is(rule));
assertThat(importedRule.isEnabled(), is(true));
assertThat(importedRule.getName(), is("name2"));
rulesBackup.importXml(sonarConfig);
assertThat(getSession().getResults(Rule.class).size(), is(2));
- RulesDao rulesDao = getDao().getRulesDao();
+ RulesDao rulesDao = new RulesDao(getSession());
Rule importedRule = rulesDao.getRuleByKey("repo", "key2");
assertThat(importedRule, notNullValue());
assertThat(rulesDao.getRuleParam(importedRule, "param"), nullValue());
public void enableOnlyLoadedMetrics() {
setupData("enableOnlyLoadedMetrics");
- RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
+ MeasuresDao measuresDao = new MeasuresDao(getSession());
+ RegisterMetrics loader = new RegisterMetrics(getSession(), measuresDao, null);
loader.start();
- assertFalse(getDao().getMeasuresDao().getMetric("deprecated").getEnabled());
- assertTrue(getDao().getMeasuresDao().getMetric(CoreMetrics.COMPLEXITY).getEnabled());
+ assertFalse(measuresDao.getMetric("deprecated").getEnabled());
+ assertTrue(measuresDao.getMetric(CoreMetrics.COMPLEXITY).getEnabled());
}
@Test