public void exportXml(SonarConfig sonarConfig) { this.profiles = (this.profiles == null ? session.getResults(RulesProfile.class) : this.profiles); // the profiles objects must be cloned to avoid issues CGLib List<RulesProfile> cloned = new ArrayList<RulesProfile>(); for (RulesProfile profile : this.profiles) { cloned.add((RulesProfile) profile.clone()); } sonarConfig.setProfiles(cloned); }
private void registerRepository(RuleRepository repository, DatabaseSession session) { Map<String, Rule> rulesByKey = Maps.newHashMap(); for (Rule rule : repository.createRules()) { rule.setRepositoryKey(repository.getKey()); rulesByKey.put(rule.getKey(), rule); } Logs.INFO.info(rulesByKey.size() + " rules"); List<Rule> persistedRules = session.getResults(Rule.class, "pluginName", repository.getKey()); for (Rule persistedRule : persistedRules) { Rule rule = rulesByKey.get(persistedRule.getKey()); if (rule != null) { updateRule(persistedRule, rule, session); rulesByKey.remove(rule.getKey()); } } saveNewRules(rulesByKey.values(), session); }