diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2023-08-14 10:29:32 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-08-22 20:03:04 +0000 |
commit | d6133f5b991c6ee072b7c4acdbb1f13fb8a0dd17 (patch) | |
tree | b23cd521668c89ab5f7ec7c181c9e6e34589faca /server/sonar-db-dao/src/main/java/org | |
parent | 1aa7ae3a18bcb2413792cf75be725d7c3d0851ca (diff) | |
download | sonarqube-d6133f5b991c6ee072b7c4acdbb1f13fb8a0dd17.tar.gz sonarqube-d6133f5b991c6ee072b7c4acdbb1f13fb8a0dd17.zip |
SONAR-19783 add GithubOrganizationGroupDao/Dto + mapper
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org')
6 files changed, 128 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java index 3ba6682347b..9ef51dcb632 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java @@ -63,6 +63,7 @@ import org.sonar.db.project.ProjectDao; import org.sonar.db.property.InternalComponentPropertiesDao; import org.sonar.db.property.InternalPropertiesDao; import org.sonar.db.property.PropertiesDao; +import org.sonar.db.provisioning.GithubOrganizationGroupDao; import org.sonar.db.purge.PurgeDao; import org.sonar.db.pushevent.PushEventDao; import org.sonar.db.qualitygate.ProjectQgateAssociationDao; @@ -126,6 +127,7 @@ public class DaoModule extends Module { EsQueueDao.class, EventDao.class, EventComponentChangeDao.class, + GithubOrganizationGroupDao.class, ExternalGroupDao.class, FileSourceDao.class, GroupDao.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java index 47d6813b549..13d32c315d2 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java @@ -63,6 +63,7 @@ import org.sonar.db.project.ProjectDao; import org.sonar.db.property.InternalComponentPropertiesDao; import org.sonar.db.property.InternalPropertiesDao; import org.sonar.db.property.PropertiesDao; +import org.sonar.db.provisioning.GithubOrganizationGroupDao; import org.sonar.db.purge.PurgeDao; import org.sonar.db.pushevent.PushEventDao; import org.sonar.db.qualitygate.ProjectQgateAssociationDao; @@ -185,6 +186,7 @@ public class DbClient { private final ReportScheduleDao reportScheduleDao; private final ReportSubscriptionDao reportSubscriptionDao; + private final GithubOrganizationGroupDao githubOrganizationGroupDao; public DbClient(Database database, MyBatis myBatis, DBSessions dbSessions, Dao... daos) { this.database = database; @@ -241,6 +243,7 @@ public class DbClient { notificationQueueDao = getDao(map, NotificationQueueDao.class); metricDao = getDao(map, MetricDao.class); groupDao = getDao(map, GroupDao.class); + githubOrganizationGroupDao = getDao(map, GithubOrganizationGroupDao.class); externalGroupDao = getDao(map, ExternalGroupDao.class); ruleDao = getDao(map, RuleDao.class); ruleRepositoryDao = getDao(map, RuleRepositoryDao.class); @@ -483,6 +486,10 @@ public class DbClient { return groupDao; } + public GithubOrganizationGroupDao githubOrganizationGroupDao() { + return githubOrganizationGroupDao; + } + public ExternalGroupDao externalGroupDao() { return externalGroupDao; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index acfd0374e1f..874d265a54f 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -117,6 +117,8 @@ import org.sonar.db.property.InternalPropertiesMapper; import org.sonar.db.property.InternalPropertyDto; import org.sonar.db.property.PropertiesMapper; import org.sonar.db.property.ScrapPropertyDto; +import org.sonar.db.provisioning.GithubOrganizationGroupDto; +import org.sonar.db.provisioning.GithubOrganizationGroupMapper; import org.sonar.db.purge.PurgeMapper; import org.sonar.db.purge.PurgeableAnalysisDto; import org.sonar.db.pushevent.PushEventDto; @@ -204,6 +206,7 @@ public class MyBatis { confBuilder.loadAlias("Entity", EntityDto.class); confBuilder.loadAlias("Event", EventDto.class); confBuilder.loadAlias("ExternalGroup", ExternalGroupDto.class); + confBuilder.loadAlias("GithubOrganizationGroup", GithubOrganizationGroupDto.class); confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class); confBuilder.loadAlias("KeyWithUuid", KeyWithUuidDto.class); confBuilder.loadAlias("Group", GroupDto.class); @@ -281,6 +284,7 @@ public class MyBatis { EsQueueMapper.class, EventMapper.class, EventComponentChangeMapper.class, + GithubOrganizationGroupMapper.class, ExternalGroupMapper.class, FileSourceMapper.class, GroupMapper.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDao.java new file mode 100644 index 00000000000..4c9d13cbf42 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDao.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.provisioning; + +import java.util.Optional; +import java.util.Set; +import org.sonar.db.Dao; +import org.sonar.db.DbSession; + +public class GithubOrganizationGroupDao implements Dao { + + public Set<GithubOrganizationGroupDto> findAll(DbSession dbSession) { + return mapper(dbSession).selectAll(); + } + public void insert(DbSession dbSession, GithubOrganizationGroupDto githubOrganizationGroupDto) { + mapper(dbSession).insert(githubOrganizationGroupDto); + } + public Optional<GithubOrganizationGroupDto> selectByGroupUuid(DbSession dbSession, String groupUuid) { + return mapper(dbSession).selectByGroupUuid(groupUuid); + } + public void deleteByGroupUuid(DbSession dbSession, String groupUuid) { + mapper(dbSession).deleteByGroupUuid(groupUuid); + } + private static GithubOrganizationGroupMapper mapper(DbSession session) { + return session.getMapper(GithubOrganizationGroupMapper.class); + } + +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDto.java new file mode 100644 index 00000000000..9f2eee1aa30 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupDto.java @@ -0,0 +1,35 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.provisioning; + +import java.util.Objects; +import javax.annotation.Nullable; + +public record GithubOrganizationGroupDto(String groupUuid, String organizationName, @Nullable String name) { + + public GithubOrganizationGroupDto(String groupUuid, String organizationName) { + this(groupUuid, organizationName, null); + } + + public String getNameOrThrow() { + return Objects.requireNonNull(name); + } + +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupMapper.java new file mode 100644 index 00000000000..a6e325ce400 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/provisioning/GithubOrganizationGroupMapper.java @@ -0,0 +1,35 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.provisioning; + +import java.util.Optional; +import java.util.Set; +import org.apache.ibatis.annotations.Param; + +public interface GithubOrganizationGroupMapper { + + Set<GithubOrganizationGroupDto> selectAll(); + void insert(GithubOrganizationGroupDto githubOrganizationGroupDto); + + Optional<GithubOrganizationGroupDto> selectByGroupUuid(@Param("groupUuid") String groupUuid); + + void deleteByGroupUuid(@Param("groupUuid") String groupUuid); + +} |