From 5d21ae8d7ff15fe76833159f880bd134710434b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Tue, 18 Oct 2016 18:15:39 +0200 Subject: [PATCH] SONAR-8100 add GroupDao#deleteByOrganization --- .../main/java/org/sonar/db/user/GroupDao.java | 4 ++ .../java/org/sonar/db/user/GroupMapper.java | 2 + .../org/sonar/db/user/GroupMapper.xml | 7 +++ .../java/org/sonar/db/user/GroupDaoTest.java | 45 +++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java index 30ad7a49f28..a88029e17fb 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java @@ -71,6 +71,10 @@ public class GroupDao implements Dao { mapper(dbSession).deleteById(groupId); } + public void deleteByOrganization(DbSession dbSession, String organizationUuid) { + mapper(dbSession).deleteByOrganization(organizationUuid); + } + public int countByQuery(DbSession session, String organizationUuid, @Nullable String query) { return mapper(session).countByQuery(organizationUuid, groupSearchToSql(query)); } diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupMapper.java b/sonar-db/src/main/java/org/sonar/db/user/GroupMapper.java index d056931638a..cbb3e0dff7c 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/GroupMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/user/GroupMapper.java @@ -44,6 +44,8 @@ public interface GroupMapper { void deleteById(long groupId); + void deleteByOrganization(@Param("organizationUuid") String organizationUuid); + @CheckForNull GroupDto selectByName(@Param("organizationUuid") String organizationUuid, @Param("name") String name); diff --git a/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml index 45d71a4d7b6..bc74e334d7e 100644 --- a/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/user/GroupMapper.xml @@ -46,6 +46,13 @@ + + delete from + groups + where + organization_uuid=#{organizationUuid,jdbcType=VARCHAR} + +