import org.sonar.core.rule.CacheRuleFinder;
import org.sonar.core.user.HibernateUserFinder;
import org.sonar.jpa.dao.MeasuresDao;
-import org.sonar.jpa.dao.ProfilesDao;
import org.sonar.jpa.dao.RulesDao;
import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.JpaDatabaseSession;
RuleI18nManager.class,
MeasuresDao.class,
RulesDao.class,
- ProfilesDao.class,
HibernateUserFinder.class,
SemaphoreUpdater.class,
SemaphoresImpl.class,
if (rule != null) {
NewActiveRule newActiveRule = builder.activate(rule.ruleKey());
newActiveRule.setSeverity(activeDto.getSeverityString());
+ newActiveRule.setLanguage(rule.getLanguage());
if (rule.getParent() != null) {
newActiveRule.setInternalKey(rule.getParent().getConfigKey());
} else {
import org.apache.commons.lang.StringUtils;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.config.Settings;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rules.ActiveRule;
-import org.sonar.jpa.dao.ProfilesDao;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.rules.RulePriority;
import java.util.Collection;
+import java.util.Map;
/**
* Ensures backward-compatibility with extensions that use {@link org.sonar.api.profiles.RulesProfile}.
private RulesProfile singleton = null;
- public RulesProfile provide(ModuleQProfiles qProfiles, Settings settings, ProfilesDao dao) {
+ public RulesProfile provide(ModuleQProfiles qProfiles, ActiveRules activeRules, RuleFinder ruleFinder, Settings settings) {
if (singleton == null) {
String lang = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY);
if (StringUtils.isNotBlank(lang)) {
// Backward-compatibility with single-language modules
- singleton = loadSingleLanguageProfile(qProfiles, lang, dao);
+ singleton = loadSingleLanguageProfile(qProfiles, activeRules, ruleFinder, lang);
} else {
- singleton = loadProfiles(qProfiles, dao);
+ singleton = loadProfiles(qProfiles, activeRules, ruleFinder);
}
}
return singleton;
}
- private RulesProfile loadSingleLanguageProfile(ModuleQProfiles qProfiles, String language, ProfilesDao dao) {
+ private RulesProfile loadSingleLanguageProfile(ModuleQProfiles qProfiles, ActiveRules activeRules,
+ RuleFinder ruleFinder, String language) {
ModuleQProfiles.QProfile qProfile = qProfiles.findByLanguage(language);
if (qProfile != null) {
- return new RulesProfileWrapper(select(qProfile, dao));
+ return new RulesProfileWrapper(select(qProfile, activeRules, ruleFinder));
}
return new RulesProfileWrapper(Lists.<RulesProfile>newArrayList());
}
- private RulesProfile loadProfiles(ModuleQProfiles qProfiles, ProfilesDao dao) {
+ private RulesProfile loadProfiles(ModuleQProfiles qProfiles, ActiveRules activeRules, RuleFinder ruleFinder) {
Collection<RulesProfile> dtos = Lists.newArrayList();
for (ModuleQProfiles.QProfile qProfile : qProfiles.findAll()) {
- dtos.add(select(qProfile, dao));
+ dtos.add(select(qProfile, activeRules, ruleFinder));
}
return new RulesProfileWrapper(dtos);
}
- private RulesProfile select(ModuleQProfiles.QProfile qProfile, ProfilesDao dao) {
- RulesProfile dto = dao.getProfile(qProfile.language(), qProfile.name());
- return hibernateHack(dto);
- }
-
- private RulesProfile hibernateHack(RulesProfile profile) {
- // hack to lazy initialize the profile collections
- profile.getActiveRules().size();
- for (ActiveRule activeRule : profile.getActiveRules()) {
- activeRule.getActiveRuleParams().size();
- activeRule.getRule().getParams().size();
+ private RulesProfile select(ModuleQProfiles.QProfile qProfile, ActiveRules activeRules, RuleFinder ruleFinder) {
+ RulesProfile deprecatedProfile = new RulesProfile();
+ deprecatedProfile.setVersion(qProfile.version());
+ deprecatedProfile.setName(qProfile.name());
+ deprecatedProfile.setLanguage(qProfile.language());
+ for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules.findByLanguage(qProfile.language())) {
+ Rule rule = ruleFinder.findByKey(activeRule.ruleKey());
+ ActiveRule deprecatedActiveRule = deprecatedProfile.activateRule(rule, RulePriority.valueOf(activeRule.severity()));
+ for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
+ deprecatedActiveRule.setParameter(param.getKey(), param.getValue());
+ }
}
- return profile;
+ return deprecatedProfile;
}
+
}
return singleLanguageProfile.getLanguage();
}
- // TODO remove when ProfileEventsSensor is refactored
- public RulesProfile getProfileByLanguage(String languageKey) {
- for (RulesProfile profile : profiles) {
- if (languageKey.equals(profile.getLanguage())) {
- return profile;
- }
- }
- return null;
- }
-
@Override
public List<ActiveRule> getActiveRules() {
List<ActiveRule> activeRules = new ArrayList<ActiveRule>();
package org.sonar.batch.rule;
import org.junit.Test;
+import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.config.Settings;
import org.sonar.api.profiles.RulesProfile;
-import org.sonar.jpa.dao.ProfilesDao;
+import org.sonar.api.rules.RuleFinder;
import java.util.Arrays;
public class RulesProfileProviderTest {
ModuleQProfiles qProfiles = mock(ModuleQProfiles.class);
+ ActiveRules activeRules = mock(ActiveRules.class);
+ RuleFinder ruleFinder = mock(RuleFinder.class);
Settings settings = new Settings();
- ProfilesDao dao = mock(ProfilesDao.class);
RulesProfileProvider provider = new RulesProfileProvider();
@Test
public void merge_profiles() throws Exception {
ModuleQProfiles.QProfile qProfile = new ModuleQProfiles.QProfile(33, "Sonar way", "java", 12);
when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile));
- RulesProfile hibernateProfile = new RulesProfile("Sonar way", "java");
- when(dao.getProfile("java", "Sonar way")).thenReturn(hibernateProfile);
- RulesProfile profile = provider.provide(qProfiles, settings, dao);
+ RulesProfile profile = provider.provide(qProfiles, activeRules, ruleFinder, settings);
// merge of all profiles
assertThat(profile).isNotNull().isInstanceOf(RulesProfileWrapper.class);
ModuleQProfiles.QProfile qProfile = new ModuleQProfiles.QProfile(33, "Sonar way", "java", 12);
when(qProfiles.findByLanguage("java")).thenReturn(qProfile);
- RulesProfile hibernateProfile = new RulesProfile("Sonar way", "java").setVersion(12);
- when(dao.getProfile("java", "Sonar way")).thenReturn(hibernateProfile);
- RulesProfile profile = provider.provide(qProfiles, settings, dao);
+ RulesProfile profile = provider.provide(qProfiles, activeRules, ruleFinder, settings);
// no merge, directly the old hibernate profile
assertThat(profile).isNotNull();
+++ /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.profiles.RulesProfile;
-
-public class ProfilesDao extends BaseDao {
-
- public ProfilesDao(DatabaseSession session) {
- super(session);
- }
-
- public RulesProfile getProfile(String languageKey, String profileName) {
- return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName);
- }
-
-}
<class>org.sonar.api.rules.Rule</class>
<class>org.sonar.api.rules.RuleParam</class>
<class>org.sonar.api.resources.ProjectLink</class>
- <class>org.sonar.api.profiles.RulesProfile</class>
- <class>org.sonar.api.rules.ActiveRule</class>
- <class>org.sonar.api.rules.ActiveRuleParam</class>
<class>org.sonar.api.batch.Event</class>
- <class>org.sonar.api.rules.ActiveRuleChange</class>
- <class>org.sonar.api.rules.ActiveRuleParamChange</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
+++ /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.profiles.RulesProfile;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class ProfilesDaoTest extends AbstractDbUnitTestCase {
-
- private ProfilesDao profilesDao;
-
- @Before
- public void setup() {
- profilesDao = new ProfilesDao(getSession());
- }
-
- @Test
- public void should_get_profile_by_name() {
- RulesProfile profile = RulesProfile.create("my profile", "java");
- getSession().save(profile);
-
- assertThat(profilesDao.getProfile("unknown language", "my profile")).isNull();
- assertThat(profilesDao.getProfile("java", "my profile").getName()).isEqualTo("my profile");
- }
-}
*/
String severity();
+ /**
+ * Language of rule, for example <code>java</code>
+ */
+ String language();
+
/**
* Value of given parameter. Returns <code>null</code> if the parameter key does not
* exist on the rule or if the parameter has no value nor default value.
* <p/>
* Use {@link org.sonar.api.batch.rule.internal.ActiveRulesBuilder} to instantiate
* this component in unit tests.
+ *
* @since 4.2
*/
public interface ActiveRules extends BatchComponent {
Collection<ActiveRule> findAll();
/**
- * The active rules for a given repository, like Findbugs
+ * The active rules for a given repository, like <code>findbugs</code>
*/
Collection<ActiveRule> findByRepository(String repository);
+ /**
+ * The active rules for a given language, like <code>java</code>
+ */
+ Collection<ActiveRule> findByLanguage(String language);
+
}
@Immutable
class DefaultActiveRule implements ActiveRule {
private final RuleKey ruleKey;
- private final String severity, internalKey;
+ private final String severity, internalKey, language;
private final Map<String, String> params;
DefaultActiveRule(NewActiveRule newActiveRule) {
this.internalKey = newActiveRule.internalKey;
this.ruleKey = newActiveRule.ruleKey;
this.params = ImmutableMap.copyOf(newActiveRule.params);
+ this.language = newActiveRule.language;
}
@Override
return severity;
}
+ @Override
+ public String language() {
+ return language;
+ }
+
@Override
public String param(String key) {
return params.get(key);
// TODO use disk-backed cache (persistit) instead of full in-memory cache ?
private final ListMultimap<String, ActiveRule> activeRulesByRepository;
+ private final ListMultimap<String, ActiveRule> activeRulesByLanguage;
public DefaultActiveRules(Collection<NewActiveRule> newActiveRules) {
- ImmutableListMultimap.Builder<String, ActiveRule> builder = ImmutableListMultimap.builder();
+ ImmutableListMultimap.Builder<String, ActiveRule> repoBuilder = ImmutableListMultimap.builder();
+ ImmutableListMultimap.Builder<String, ActiveRule> langBuilder = ImmutableListMultimap.builder();
for (NewActiveRule newAR : newActiveRules) {
DefaultActiveRule ar = new DefaultActiveRule(newAR);
- builder.put(ar.ruleKey().repository(), ar);
+ repoBuilder.put(ar.ruleKey().repository(), ar);
+ if (ar.language()!=null) {
+ langBuilder.put(ar.language(), ar);
+ }
}
- activeRulesByRepository = builder.build();
+ activeRulesByRepository = repoBuilder.build();
+ activeRulesByLanguage = langBuilder.build();
}
@Override
public Collection<ActiveRule> findByRepository(String repository) {
return activeRulesByRepository.get(repository);
}
+
+ @Override
+ public Collection<ActiveRule> findByLanguage(String language) {
+ return activeRulesByLanguage.get(language);
+ }
}
final RuleKey ruleKey;
String severity = Severity.defaultSeverity();
Map<String, String> params = new HashMap<String, String>();
- String internalKey;
+ String internalKey, language;
NewActiveRule(RuleKey ruleKey) {
this.ruleKey = ruleKey;
return this;
}
+ public NewActiveRule setLanguage(@Nullable String language) {
+ this.language = language;
+ return this;
+ }
+
public NewActiveRule setParam(String key, @Nullable String value) {
// possible improvement : check that the param key exists in rule definition
if (value == null) {
/**
* This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.
*/
-@Entity
-@Table(name = "rules_profiles")
public class RulesProfile implements Cloneable {
/**
@Deprecated
public static final String SUN_CONVENTIONS_NAME = "Sun checks";
- @Id
- @Column(name = "id")
- @GeneratedValue
private Integer id;
-
- @Column(name = "name", updatable = true, nullable = false)
private String name;
-
- @Column(name = "version", updatable = true, nullable = false)
private int version = 1;
-
- @Transient
private Boolean defaultProfile = Boolean.FALSE;
-
- @Column(name = "used_profile", updatable = true, nullable = false)
private Boolean used = Boolean.FALSE;
-
- @Column(name = "language", updatable = true, nullable = false, length = 20)
private String language;
-
- @Column(name = "parent_name", updatable = true, nullable = true)
private String parentName;
-
- @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
private List<ActiveRule> activeRules = Lists.newArrayList();
/**
import org.sonar.api.profiles.RulesProfile;
import javax.annotation.CheckForNull;
-import javax.persistence.*;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* A class to map an ActiveRule to the hibernate model
*/
-@Entity
-@Table(name = "active_rules")
public class ActiveRule implements Cloneable {
public static final String INHERITED = "INHERITED";
public static final String OVERRIDES = "OVERRIDES";
- @Id
- @Column(name = "id")
- @GeneratedValue
private Integer id;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "rule_id", updatable = true, nullable = false)
private Rule rule;
-
- @Column(name = "failure_level", updatable = true, nullable = false)
- @Enumerated(EnumType.ORDINAL)
private RulePriority severity;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "profile_id", updatable = true, nullable = false)
private RulesProfile rulesProfile;
-
- @OneToMany(mappedBy = "activeRule", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
private List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
-
- @Column(name = "inheritance", updatable = true, nullable = true)
private String inheritance;
/**
@Override
public String toString() {
return new ToStringBuilder(this).append("id", getId()).append("rule", rule).append("priority", severity)
- .append("params", activeRuleParams).toString();
+ .append("params", activeRuleParams).toString();
}
@Override
* @since 2.6
*/
public boolean isEnabled() {
- return getRule()!=null && getRule().isEnabled();
+ return getRule() != null && getRule().isEnabled();
}
}
+++ /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.api.rules;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.database.BaseIdentifiable;
-import org.sonar.api.profiles.RulesProfile;
-
-import javax.persistence.*;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-/**
- * A class to map a RuleChange to the hibernate model
- *
- * @since 2.9
- */
-@Entity
-@Table(name = "active_rule_changes")
-public class ActiveRuleChange extends BaseIdentifiable {
-
- @Column(name = "username", updatable = false, nullable = true)
- private String userName;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "profile_id", updatable = false, nullable = false)
- private RulesProfile rulesProfile;
-
- @Column(name = "profile_version", updatable = false, nullable = false)
- private int profileVersion;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "rule_id", updatable = false, nullable = false)
- private Rule rule;
-
- @Column(name = "change_date", updatable = false, nullable = false)
- private Date date;
-
- /**
- * true means rule was enabled
- * false means rule was disabled
- * null means rule stay enabled (another param was changed)
- */
- @Column(name = "enabled")
- private Boolean enabled;
-
- @Column(name = "old_severity", updatable = false, nullable = true)
- @Enumerated(EnumType.ORDINAL)
- private RulePriority oldSeverity;
-
- @Column(name = "new_severity", updatable = false, nullable = true)
- @Enumerated(EnumType.ORDINAL)
- private RulePriority newSeverity;
-
- @OneToMany(mappedBy = "activeRuleChange", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
- private List<ActiveRuleParamChange> activeRuleParamChanges = new ArrayList<ActiveRuleParamChange>();
-
- public ActiveRuleChange(String userName, RulesProfile profile, Rule rule) {
- this.userName = userName;
- this.rulesProfile = profile;
- this.profileVersion = profile.getVersion();
- this.rule = rule;
- this.date = Calendar.getInstance().getTime();
- }
-
- public Rule getRule() {
- return rule;
- }
-
- public RulePriority getOldSeverity() {
- return oldSeverity;
- }
-
- public void setOldSeverity(RulePriority oldSeverity) {
- this.oldSeverity = oldSeverity;
- }
-
- public RulePriority getNewSeverity() {
- return newSeverity;
- }
-
- public void setNewSeverity(RulePriority newSeverity) {
- this.newSeverity = newSeverity;
- }
-
- public RulesProfile getRulesProfile() {
- return rulesProfile;
- }
-
- public int getProfileVersion() {
- return profileVersion;
- }
-
- public String getRepositoryKey() {
- return rule.getRepositoryKey();
- }
-
- /**
- * @return the config key the changed rule belongs to
- */
- public String getConfigKey() {
- return rule.getConfigKey();
- }
-
- /**
- * @return the key of the changed rule
- */
- public String getRuleKey() {
- return rule.getKey();
- }
-
- public Boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public List<ActiveRuleParamChange> getActiveRuleParamChanges() {
- return activeRuleParamChanges;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public ActiveRuleChange setParameterChange(String key, String oldValue, String newValue) {
- RuleParam ruleParameter = rule.getParam(key);
- if (ruleParameter != null) {
- activeRuleParamChanges.add(new ActiveRuleParamChange(this, ruleParameter, oldValue, newValue));
- }
- return this;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj.getClass() != getClass()) {
- return false;
- }
- ActiveRuleChange rhs = (ActiveRuleChange) obj;
- return new EqualsBuilder()
- .appendSuper(super.equals(obj))
- .append(userName, rhs.userName)
- .append(rulesProfile, rhs.rulesProfile)
- .append(rule, rhs.rule)
- .append(date, rhs.date)
- .append(enabled, rhs.enabled)
- .append(newSeverity, rhs.newSeverity)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(41, 33)
- .append(userName)
- .append(rulesProfile)
- .append(rule)
- .append(date)
- .append(enabled)
- .append(newSeverity)
- .toHashCode();
- }
-
- @Override
- public String toString() {
- return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
- }
-
-}
*/
package org.sonar.api.rules;
-import javax.persistence.*;
-
-@Entity
-@Table(name = "active_rule_parameters")
public class ActiveRuleParam implements Cloneable {
- @Id
- @Column(name = "id")
- @GeneratedValue
private Integer id;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "active_rule_id")
private ActiveRule activeRule;
-
- @ManyToOne(fetch = FetchType.LAZY, optional = true)
- @JoinColumn(name = "rules_parameter_id")
private RuleParam ruleParam;
-
- @Column(name = "rules_parameter_key", updatable = false, nullable = false, length = 128)
private String paramKey;
-
- @Column(name = "value", updatable = false, nullable = true, length = 4000)
private String value;
public Integer getId() {
+++ /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.api.rules;
-
-import org.sonar.api.database.BaseIdentifiable;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-
-import javax.persistence.*;
-
-/**
- * @since 2.9
- */
-@Entity
-@Table(name = "active_rule_param_changes")
-public class ActiveRuleParamChange extends BaseIdentifiable {
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "active_rule_change_id")
- private ActiveRuleChange activeRuleChange;
-
- @ManyToOne(fetch = FetchType.LAZY, optional = true)
- @JoinColumn(name = "rules_parameter_id")
- private RuleParam ruleParam;
-
- @Column(name = "old_value", updatable = false, nullable = true, length = 4000)
- private String oldValue;
-
- @Column(name = "new_value", updatable = false, nullable = true, length = 4000)
- private String newValue;
-
- ActiveRuleParamChange(ActiveRuleChange activeRuleChange, RuleParam ruleParam, String oldValue, String newValue) {
- this.activeRuleChange = activeRuleChange;
- this.ruleParam = ruleParam;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
-
- public ActiveRuleChange getActiveRuleChange() {
- return activeRuleChange;
- }
-
- public RuleParam getRuleParam() {
- return ruleParam;
- }
-
- public String getOldValue() {
- return oldValue;
- }
-
- public String getNewValue() {
- return newValue;
- }
-
- public String getKey() {
- return ruleParam.getKey();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof ActiveRuleParamChange)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- ActiveRuleParamChange other = (ActiveRuleParamChange) obj;
- return new EqualsBuilder()
- .append(getId(), other.getId()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 57)
- .append(getId())
- .toHashCode();
- }
-
-}
import org.sonar.core.user.DefaultUserFinder;
import org.sonar.core.user.HibernateUserFinder;
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.DatabaseSessionProvider;
// quality profile
pico.addSingleton(XMLProfileParser.class);
pico.addSingleton(XMLProfileSerializer.class);
- pico.addComponent(ProfilesDao.class, false);
pico.addSingleton(AnnotationProfileParser.class);
pico.addSingleton(QProfiles.class);
pico.addSingleton(QProfileLookup.class);