diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-09-08 16:18:32 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-09-09 11:41:03 +0200 |
commit | cc5f905e907f8260b8e57379b0a5f434fa7d6238 (patch) | |
tree | 6ab17a3a0d541abbc36eae59afcf2fb68167a86d /sonar-core | |
parent | 4140a2e060e2c2cfe047a107be7ec71216e962a9 (diff) | |
download | sonarqube-cc5f905e907f8260b8e57379b0a5f434fa7d6238.tar.gz sonarqube-cc5f905e907f8260b8e57379b0a5f434fa7d6238.zip |
SONAR-5561 New migration task at start-up to feed ES with issue_project_permissions
Diffstat (limited to 'sonar-core')
5 files changed, 71 insertions, 27 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index 58d40c93502..fb13bb56181 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -167,7 +167,7 @@ public class MyBatis implements BatchComponent, ServerComponent { IssueMapper.class, IssueAuthorizationMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class, LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class, - SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class, + SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, GroupMapper.class, WidgetMapper.class, WidgetPropertyMapper.class, org.sonar.api.database.model.MeasureMapper.class, SnapshotDataMapper.class, SnapshotSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class, NotificationQueueMapper.class, CharacteristicMapper.class, GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class, diff --git a/sonar-core/src/main/java/org/sonar/core/user/GroupDto.java b/sonar-core/src/main/java/org/sonar/core/user/GroupDto.java index f3afa89a920..b70d2526785 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/GroupDto.java +++ b/sonar-core/src/main/java/org/sonar/core/user/GroupDto.java @@ -19,18 +19,16 @@ */ package org.sonar.core.user; +import org.sonar.core.persistence.Dto; + +import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import java.util.Date; -/** - * @since 3.2 - */ -public class GroupDto { +public class GroupDto extends Dto<String> { + private Long id; private String name; private String description; - private Date createdAt; - private Date updatedAt; public Long getId() { return id; @@ -50,6 +48,7 @@ public class GroupDto { return this; } + @CheckForNull public String getDescription() { return description; } @@ -59,21 +58,9 @@ public class GroupDto { return this; } - public Date getCreatedAt() { - return createdAt; - } - - public GroupDto setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - public Date getUpdatedAt() { - return updatedAt; + @Override + public String getKey() { + return name; } - public GroupDto setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } } diff --git a/sonar-core/src/main/java/org/sonar/core/user/GroupMapper.java b/sonar-core/src/main/java/org/sonar/core/user/GroupMapper.java new file mode 100644 index 00000000000..0edd9c3f331 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/user/GroupMapper.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.core.user; + +import javax.annotation.CheckForNull; + +public interface GroupMapper { + + @CheckForNull + GroupDto selectByKey(String name); + + void insert(GroupDto groupDto); + +} diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml index d4cf8ba718f..eb451cf51ae 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml @@ -6,10 +6,10 @@ <select id="selectAfterDate" parameterType="map" resultType="map"> SELECT - project_authorization.project as project, - project_authorization.login as user, - project_authorization.permission_group as permission_group, - project_authorization.permission_role as permission_role + project_authorization.project as "project", + project_authorization.login as "user", + project_authorization.permission_group as "permission_group", + project_authorization.permission_role as "permission_role" FROM ( -- users SELECT diff --git a/sonar-core/src/main/resources/org/sonar/core/user/GroupMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/GroupMapper.xml new file mode 100644 index 00000000000..4dd187badbe --- /dev/null +++ b/sonar-core/src/main/resources/org/sonar/core/user/GroupMapper.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + +<mapper namespace="org.sonar.core.user.GroupMapper"> + + <sql id="groupColumns"> + g.id as id, + g.name as name, + g.description as description, + g.created_at as "createdAt", + g.updated_at as "updatedAt" + </sql> + + <select id="selectByKey" parameterType="string" resultType="Group"> + SELECT <include refid="groupColumns"/> + FROM groups g WHERE g.name=#{id} + </select> + + <insert id="insert" parameterType="Group" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> + INSERT INTO groups (name, description, created_at, updated_at) + VALUES (#{name}, #{description}, #{createdAt}, #{updatedAt}) + </insert> + +</mapper> |