}
}
- @CheckForNull
- public QualityProfileDto selectParent(DbSession session, String childKey) {
- return mapper(session).selectParent(childKey);
- }
-
- @CheckForNull
- public QualityProfileDto selectParent(String childKey) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectParent(session, childKey);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
@CheckForNull
public QualityProfileDto selectParentById(DbSession session, int childId) {
return mapper(session).selectParentById(childId);
return mapper(session).selectProjects(profileName, language);
}
- public int countProjects(String profileName, String language) {
- DbSession session = mybatis.openSession(false);
- try {
- return mapper(session).countProjects(profileName, language);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
public Map<String, Long> countProjectsByProfileKey() {
DbSession session = mybatis.openSession(false);
try {
// INHERITANCE
- @CheckForNull
- QualityProfileDto selectParent(String childKey);
-
@CheckForNull
QualityProfileDto selectParentById(int childId);
List<ComponentDto> selectProjects(@Param("profileName") String profileName, @Param("language") String language);
- int countProjects(@Param("profileName") String profileName, @Param("language") String language);
-
List<QualityProfileProjectCount> countProjectsByProfile();
QualityProfileDto selectByProjectIdAndLanguage(@Param("projectId") Long projectId, @Param("language") String language);
WHERE p.id=#{id}
</select>
- <select id="selectParent" parameterType="string" resultType="QualityProfile">
- SELECT
- <include refid="profilesColumns"/>
- FROM rules_profiles p
- INNER JOIN rules_profiles child ON child.parent_kee=p.kee AND child.kee=#{id}
- </select>
-
<select id="selectParentById" parameterType="int" resultType="QualityProfile">
SELECT
<include refid="profilesColumns"/>
ORDER BY pj.name ASC
</select>
- <select id="countProjects" parameterType="Integer" resultType="Integer">
- SELECT count(projects.id)
- FROM projects projects
- JOIN project_qprofiles pp ON pp.project_uuid=projects.uuid
- JOIN rules_profiles prof ON pp.profile_key=prof.kee
- <where>
- AND prof.language=#{language}
- AND prof.name=#{profileName}
- </where>
- </select>
-
<select id="countProjectsByProfile" resultType="org.sonar.db.qualityprofile.QualityProfileProjectCount">
SELECT pp.profile_key as profileKey, count(projects.id) as projectCount
FROM projects projects
assertThat(underTest.selectProjects("Sonar Way", "java")).hasSize(2);
}
- @Test
- public void count_projects() {
- dbTester.prepareDbUnit(getClass(), "projects.xml");
-
- assertThat(underTest.countProjects("Sonar Way", "java")).isEqualTo(2);
- }
-
@Test
public void count_projects_by_profile() {
dbTester.prepareDbUnit(getClass(), "projects.xml");