@Override
public Object clone() {
- ActiveRule clone = new ActiveRule(getRulesProfile(), getRule(), getSeverity());
+ final ActiveRule clone = new ActiveRule(getRulesProfile(), getRule(), getSeverity());
clone.setInherited(isInherited());
if (CollectionUtils.isNotEmpty(getActiveRuleParams())) {
clone.setActiveRuleParams(new ArrayList<ActiveRuleParam>(CollectionUtils.collect(getActiveRuleParams(), new Transformer() {
public Object transform(Object input) {
- return ((ActiveRuleParam) input).clone();
+ ActiveRuleParam activeRuleParamClone = (ActiveRuleParam) ((ActiveRuleParam) input).clone();
+ activeRuleParamClone.setActiveRule(clone);
+ return activeRuleParamClone;
}
})));
}
public void importXml(SonarConfig sonarConfig) {
if (CollectionUtils.isNotEmpty(sonarConfig.getProfiles())) {
- ProfilesManager profilesManager = new ProfilesManager(session, null, null, null);
+ ProfilesManager profilesManager = new ProfilesManager(session, null);
profilesManager.deleteAllProfiles();
RulesDao rulesDao = new RulesDao(session);
*/
package org.sonar.server.configuration;
-import org.sonar.api.Plugins;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rules.ActiveRule;
-import org.sonar.api.rules.ActiveRuleParam;
-import org.sonar.api.rules.DefaultRulesManager;
import org.sonar.api.rules.Rule;
import org.sonar.jpa.dao.BaseDao;
import org.sonar.jpa.dao.RulesDao;
public class ProfilesManager extends BaseDao {
- private DefaultRulesManager rulesManager;
private RulesDao rulesDao;
- private Plugins plugins;
- public ProfilesManager(DatabaseSession session, RulesDao rulesDao, Plugins plugins, DefaultRulesManager rulesManager) {
+ public ProfilesManager(DatabaseSession session, RulesDao rulesDao) {
super(session);
- this.rulesManager = rulesManager;
this.rulesDao = rulesDao;
- this.plugins = plugins;
}
public void copyProfile(int profileId, String newProfileName) {
removeActiveRule(profile, activeRule);
}
activeRule = (ActiveRule) parentActiveRule.clone();
- // TODO Godin: it means that we have bug in ActiveRule.clone()
- for (ActiveRuleParam param : activeRule.getActiveRuleParams()) {
- param.setActiveRule(activeRule);
- }
activeRule.setRulesProfile(profile);
activeRule.setInherited(true);
profile.getActiveRules().add(activeRule);