From 81e740e5c64d75b93e63ab428420cc3f12ee15a5 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 28 Sep 2016 16:25:55 +0200 Subject: [PATCH] Remove useless in mybatis --- .../db/permission/GroupPermissionMapper.xml | 23 +++---- .../sonar/db/permission/PermissionMapper.xml | 60 ++++++------------- 2 files changed, 27 insertions(+), 56 deletions(-) diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml index dd23e726266..31e08d7235c 100644 --- a/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml @@ -14,16 +14,13 @@ -- Add Anyone group permission SELECT #{anyoneGroup} as name, group_role.role as permission, group_role.resource_id as componentId FROM group_roles group_role - - AND group_role.group_id IS NULL - + where group_role.group_id IS NULL ) groups - + where groups.componentId in #{id} - GROUP BY groups.permission, groups.componentId @@ -44,8 +41,8 @@ -- Add Anyone group permission SELECT #{anyoneGroup} as name FROM group_roles group_role - - AND group_role.role=#{permission} + where + group_role.role=#{permission} AND group_role.group_id IS NULL AND group_role.resource_id=#{componentId} @@ -53,7 +50,6 @@ AND group_role.resource_id IS NULL - ) groups @@ -78,11 +74,9 @@ UNION ALL select 0 as group_id, 'Anyone' as name, gr.role as permission, gr.resource_id as resource_id, gr.id as id from group_roles gr - - - and gr.group_id is null - - + + where gr.group_id is null + ) gr left join projects p on gr.resource_id = p.id @@ -117,7 +111,7 @@ FROM group_roles gr WHERE gr.group_id is null ) sub - + where sub.name IN #{name} @@ -128,7 +122,6 @@ AND sub.resourceId IS NULL - diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml index 3df936ace02..d02f2b152b7 100644 --- a/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/permission/PermissionMapper.xml @@ -47,28 +47,25 @@ SELECT p.kee as root_project_kee FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} + where + gr.role=#{role} and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) - UNION SELECT p.kee as root_project_kee FROM user_roles ur INNER JOIN projects p on p.id = ur.resource_id AND p.module_uuid IS NULL - - and ur.role=#{role} + where + ur.role=#{role} and ur.user_id = #{userId} - SELECT p.kee as root_project_kee FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} + where + gr.role=#{role} and gr.group_id is null - @@ -79,28 +76,25 @@ SELECT p.uuid as root_project_uuid FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} + where + gr.role=#{role} and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) - UNION SELECT p.uuid as root_project_uuid FROM user_roles ur INNER JOIN projects p on p.id = ur.resource_id AND p.module_uuid IS NULL - - and ur.role=#{role} + where + ur.role=#{role} and ur.user_id = #{userId} - SELECT p.uuid as root_project_uuid FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} + where + gr.role=#{role} and gr.group_id is null - @@ -112,28 +106,21 @@ SELECT p.id as root_project_id FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} + where + gr.role=#{role} and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) - UNION SELECT p.id as root_project_id FROM user_roles ur INNER JOIN projects p on p.id = ur.resource_id AND p.module_uuid IS NULL - - and ur.role=#{role} - and ur.user_id = #{userId} - + where ur.role=#{role} and ur.user_id = #{userId} SELECT p.id as root_project_id FROM group_roles gr INNER JOIN projects p on p.id = gr.resource_id AND p.module_uuid IS NULL - - and gr.role=#{role} - and gr.group_id is null - + where gr.role=#{role} and gr.group_id is null @@ -145,10 +132,7 @@ FROM group_roles gr INNER JOIN groups_users gu on gu.group_id=gr.group_id INNER JOIN users u on u.id=gu.user_id - - and u.login=#{userLogin} - and gr.resource_id is null - + where u.login=#{userLogin} and gr.resource_id is null UNION SELECT gr.role FROM group_roles gr @@ -157,18 +141,12 @@ SELECT ur.role FROM user_roles ur INNER JOIN users u on u.id=ur.user_id - - and u.login=#{userLogin} - and ur.resource_id is null - + where u.login=#{userLogin} and ur.resource_id is null SELECT gr.role FROM group_roles gr - - and gr.resource_id is null - and gr.group_id is null - + where gr.resource_id is null and gr.group_id is null -- 2.39.5