← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17756: Added sql script for displaying an overview of which items a user group have been shared with. Us...

 

------------------------------------------------------------
revno: 17756
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-12-20 10:10:25 +0100
message:
  Added sql script for displaying an overview of which items a user group have been shared with. Useful as dhis sql view with query param ?criteria=ug:<usergroupuid>.
added:
  resources/sql/sharing-overview.sql
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-12-19 17:25:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-12-20 09:10:25 +0000
@@ -277,7 +277,9 @@
             boolean canSeeAllDimensions = CollectionUtils.isEmpty( userService.getCoDimensionConstraints( user.getUserCredentials() ) )
                 && CollectionUtils.isEmpty( userService.getCogDimensionConstraints( user.getUserCredentials() ) );
 
-            for ( DataApprovalLevel approvalLevel : getAllDataApprovalLevels() )
+            List<DataApprovalLevel> approvalLevels = getAllDataApprovalLevels();
+            
+            for ( DataApprovalLevel approvalLevel : approvalLevels )
             {
                 CategoryOptionGroupSet cogs = approvalLevel.getCategoryOptionGroupSet();
 

=== added file 'resources/sql/sharing-overview.sql'
--- resources/sql/sharing-overview.sql	1970-01-01 00:00:00 +0000
+++ resources/sql/sharing-overview.sql	2014-12-20 09:10:25 +0000
@@ -0,0 +1,100 @@
+select name,uid,type, ug, ug_name from (
+
+select distinct a.name as name, a.uid as uid, 'categoryoption' as type, ug.uid as ug, ug.name as ug_name from dataelementcategoryoption a 
+inner join dataelementcategoryoptionusergroupaccesses b on a.categoryoptionid=b.categoryoptionid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'category' as type, ug.uid as ug, ug.name as ug_name from dataelementcategory a 
+inner join dataelementcategoryusergroupaccesses b on a.categoryid=b.categoryid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'categorycombo' as type, ug.uid as ug, ug.name as ug_name from categorycombo a 
+inner join categorycombousergroupaccesses b on a.categorycomboid=b.categorycomboid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'categoryoptiongroup' as type, ug.uid as ug, ug.name as ug_name from categoryoptiongroup a 
+inner join categoryoptiongroupusergroupaccesses b on a.categoryoptiongroupid=b.categoryoptiongroupid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'categoryoptiongroupset' as type, ug.uid as ug, ug.name as ug_name from categoryoptiongroupset a 
+inner join categoryoptiongroupsetusergroupaccesses b on a.categoryoptiongroupsetid=b.categoryoptiongroupsetid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'dataelement' as type, ug.uid as ug, ug.name as ug_name from dataelement a 
+inner join dataelementusergroupaccesses b on a.dataelementid=b.dataelementid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'dataelementgroup' as type, ug.uid as ug, ug.name as ug_name from dataelementgroup a 
+inner join dataelementgroupusergroupaccesses b on a.dataelementgroupid=b.dataelementgroupid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'dataelementgroupset' as type, ug.uid as ug, ug.name as ug_name from dataelementgroupset a 
+inner join dataelementgroupsetusergroupaccesses b on a.dataelementgroupsetid=b.dataelementgroupsetid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'dataset' as type, ug.uid as ug, ug.name as ug_name from dataset a 
+inner join datasetusergroupaccesses b on a.datasetid=b.datasetid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'indicator' as type, ug.uid as ug, ug.name as ug_name from indicator a 
+inner join indicatorusergroupaccesses b on a.indicatorid=b.indicatorid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'indicatorgroup' as type, ug.uid as ug, ug.name as ug_name from indicatorgroup a 
+inner join indicatorgroupusergroupaccesses b on a.indicatorgroupid=b.indicatorgroupid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'indicatorgroupset' as type, ug.uid as ug, ug.name as ug_name from indicatorgroupset a 
+inner join indicatorgroupsetusergroupaccesses b on a.indicatorgroupsetid=b.indicatorgroupsetid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'orgunitgroup' as type, ug.uid as ug, ug.name as ug_name from orgunitgroup a 
+inner join orgunitgroupusergroupaccesses b on a.orgunitgroupid=b.orgunitgroupid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+union all
+
+select distinct a.name as name, a.uid as uid, 'orgunitgroupset' as type, ug.uid as ug, ug.name as ug_name from orgunitgroupset a 
+inner join orgunitgroupsetusergroupaccesses b on a.orgunitgroupsetid=b.orgunitgroupsetid
+inner join usergroupaccess uga on b.usergroupaccessid=uga.usergroupaccessid
+inner join usergroup ug on uga.usergroupid=ug.usergroupid 
+
+) as items where ug='FDy0VsGjccX';
+