void delete(int activeRuleId);
- void deleteFromRule(int ruleId);
-
- void deleteFromProfile(int profileId);
-
@CheckForNull
ActiveRuleDto selectById(Integer id);
- @CheckForNull
- ActiveRuleDto selectByProfileAndRule(@Param("profileId") int profileId, @Param("ruleId") int ruleId);
-
List<ActiveRuleDto> selectByRuleId(int ruleId);
List<ActiveRuleDto> selectByProfileId(int profileId);
void deleteParameter(int activeRuleParamId);
- void deleteParametersWithParamId(int id);
-
- void deleteParametersFromProfile(int profileId);
-
- @CheckForNull
- ActiveRuleParamDto selectParamById(int activeRuleParamId);
-
@CheckForNull
ActiveRuleParamDto selectParamByActiveRuleAndKey(@Param("activeRuleId") int activeRuleId, @Param("key") String key);
}
}
- public int countChildren(String name, String language, DbSession session) {
- return session.getMapper(QualityProfileMapper.class).countChildren(name, language);
- }
-
- public int countChildren(String name, String language) {
- DbSession session = mybatis.openSession(false);
- try {
- return countChildren(name, language, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
/**
* @deprecated Replaced by
* {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)}
List<QualityProfileDto> selectChildren(@Param("name") String name, @Param("language") String language);
- int countChildren(@Param("name") String name, @Param("language") String language);
-
// PROJECTS
List<ComponentDto> selectProjects(@Param("value") String propertyValue, @Param("key") String propertyKey);
DELETE FROM active_rules WHERE id=#{id}
</update>
- <update id="deleteFromRule" parameterType="Integer">
- DELETE FROM active_rules WHERE rule_id=#{ruleId}
- </update>
-
- <update id="deleteFromProfile" parameterType="Integer">
- DELETE FROM active_rules WHERE profile_id=#{profileId}
- </update>
-
<select id="selectByIds" parameterType="map" resultType="ActiveRule">
select
<include refid="activeRuleColumns"/>
AND qp.language = #{lang}
</select>
- <select id="selectByProfileAndRule" parameterType="map" resultType="ActiveRule">
- SELECT <include refid="activeRuleColumns"/>
- FROM active_rules a
- <include refid="activeRuleJoin"/>
- <where>
- AND a.profile_id=#{profileId}
- AND a.rule_id=#{ruleId}
- </where>
- </select>
-
<select id="selectByRuleId" parameterType="Integer" resultType="ActiveRule">
SELECT
<include refid="activeRuleKeyColumns"/>
DELETE FROM active_rule_parameters WHERE active_rule_id=#{id}
</update>
- <update id="deleteParametersWithParamId" parameterType="Integer">
- DELETE FROM active_rule_parameters WHERE rules_parameter_id=#{id}
- </update>
-
- <update id="deleteParametersFromProfile" parameterType="Integer">
- DELETE FROM active_rule_parameters WHERE active_rule_id IN (SELECT id FROM active_rules WHERE profile_id=#{profileId})
- </update>
-
<update id="deleteParameter" parameterType="Integer">
DELETE FROM active_rule_parameters WHERE id=#{id}
</update>
- <select id="selectParamById" parameterType="Integer" resultType="ActiveRuleParam">
- SELECT <include refid="activeRuleParamColumns"/>
- FROM active_rule_parameters p
- <where>
- AND p.id=#{id}
- </where>
- </select>
-
<select id="selectParamsByActiveRuleId" parameterType="Integer" resultType="ActiveRuleParam">
select
<include refid="activeRuleParamColumns"/>
ORDER BY p.name
</select>
- <select id="countChildren" parameterType="map" resultType="Integer">
- SELECT count(p.id)
- FROM rules_profiles p
- <where>
- AND p.parent_name=#{name}
- AND p.language=#{language}
- </where>
- </select>
-
<select id="selectDefaultProfile" parameterType="Integer" resultType="QualityProfile">
SELECT <include refid="profilesColumns"/>
FROM rules_profiles p
assertThat(dto2.getParent()).isEqualTo("Parent");
}
- @Test
- public void count_children() {
- setupData("inheritance");
-
- assertThat(dao.countChildren("Parent", "java")).isEqualTo(2);
- }
-
@Test
public void select_projects() {
setupData("projects");
}
}
- public int countChildren(QProfile profile) {
- DbSession session = myBatis.openSession(false);
- try {
- return countChildren(profile, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public int countChildren(QProfile profile, DbSession session) {
- return dao.countChildren(profile.name(), profile.language(), session);
- }
-
private List<QProfile> toQProfiles(List<QualityProfileDto> dtos) {
return newArrayList(Iterables.transform(dtos, new Function<QualityProfileDto, QProfile>() {
@Override
reset.resetLanguage(lang);
}
+ /**
+ * Currently used by Ruby on Rails
+ */
public Collection<String> builtInProfileNamesForLanguage(String lang) {
return reset.builtInProfileNamesForLanguage(lang);
}
// TODO
}
- //public void create(NewQualityProfile newProfile) {
- // TODO
- //verifyAdminPermission();
- //}
-
/**
* Set or unset parent profile.
*
return profileLookup.defaultProfile(language);
}
- public int countChildren(QProfile profile) {
- return profileLookup.countChildren(profile);
- }
-
public QProfileResult newProfile(String name, String language, Map<String, String> xmlProfilesByPlugin) {
checkProfileNameParam(name);
Validation.checkMandatoryParameter(language, LANGUAGE_PARAM);
import org.sonar.core.qualityprofile.db.QualityProfileKey;
import org.sonar.core.rule.RuleDto;
import org.sonar.server.db.BaseDao;
-import org.sonar.server.qualityprofile.QProfile;
import org.sonar.server.rule.db.RuleDao;
import org.sonar.server.search.IndexDefinition;
import org.sonar.server.search.action.IndexAction;
ActiveRuleDto activeRule = getNullableByKey(session, key);
return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name);
}
-
- @Deprecated
- public void removeParamByProfile(DbSession session, QProfile profile) {
- mapper(session).deleteParametersFromProfile(profile.id());
- }
-
- @Deprecated
- public void deleteByProfile(DbSession session, QProfile profile) {
- mapper(session).deleteFromProfile(profile.id());
- }
}
import javax.annotation.CheckForNull;
import java.sql.Timestamp;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
return mapper(session).selectParamsByRuleKey(key);
}
- public List<RuleParamDto> findRuleParamsByRules(DbSession session, List<RuleDto> ruleDtos) {
- List<RuleParamDto> ruleParamDtos = new ArrayList<RuleParamDto>();
- for (RuleDto rule : ruleDtos) {
- ruleParamDtos.addAll(findRuleParamsByRuleKey(session, rule.getKey()));
- }
- return ruleParamDtos;
- }
-
- public RuleParamDto getRuleParamByRuleAndParamKey(DbSession session, RuleDto rule, String key) {
- Preconditions.checkNotNull(rule.getId(), "Rule is not persisted");
- return mapper(session).selectParamByRuleAndKey(rule.getId(), key);
- }
-
public List<RuleDto> findRulesByDebtSubCharacteristicId(DbSession session, int id) {
return mapper(session).selectBySubCharacteristicId(id);
}
def profile_rules_count(qProfile)
Internal.quality_profiles.countProfileRules(qProfile).to_i
end
-
- def children_count(qProfile)
- Internal.quality_profiles.countChildren(qProfile).to_i
- end
-
end
verify(dao).selectChildren("Sonar Way", "java", session);
}
- @Test
- public void count_children_profiles() throws Exception {
- search.countChildren(new QProfile().setName("Sonar Way").setLanguage("java"));
- verify(dao).countChildren("Sonar Way", "java", session);
- }
-
@Test
public void default_profile() throws Exception {
when(dao.selectDefaultProfile("java", "sonar.profile.java", session)).thenReturn(
verify(profileLookup).ancestors(profile);
}
- @Test
- public void count_children() throws Exception {
- QProfile profile = new QProfile();
- qProfiles.countChildren(profile);
- verify(profileLookup).countChildren(profile);
- }
-
@Test
public void create_new_profile() throws Exception {
Map<String, String> xmlProfilesByPlugin = newHashMap();
import java.util.List;
-import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
assertThat(ruleDto.getRuleId()).isEqualTo(1);
}
- @Test
- public void select_parameters_by_rule_ids() throws Exception {
- setupData("select_parameters_by_rule_ids");
-
- RuleDto rule1 = dao.getById(session, 1);
- RuleDto rule2 = dao.getById(session, 2);
- assertThat(dao.findRuleParamsByRules(session, newArrayList(rule1, rule2))).hasSize(2);
- assertThat(dao.findRuleParamsByRules(session, newArrayList(rule1))).hasSize(1);
- }
-
@Test
public void insert_parameter() {
setupData("insert_parameter");