← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15932: Enabled org unit group sets in event analytics tables

 

------------------------------------------------------------
revno: 15932
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-07-02 10:56:21 +0200
message:
  Enabled org unit group sets in event analytics tables
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.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-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-06-04 16:18:39 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-07-02 08:56:21 +0000
@@ -40,6 +40,7 @@
 
 import org.hisp.dhis.analytics.AnalyticsTable;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -168,6 +169,7 @@
             sql = removeLast( sql, 1 ) + " ";
 
             sql += "from programstageinstance psi " +
+                "left join _organisationunitgroupsetstructure ougs on psi.organisationunitid=ougs.organisationunitid " +
                 "left join programinstance pi on psi.programinstanceid=pi.programinstanceid " +
                 "left join programstage ps on psi.programstageid=ps.programstageid " +
                 "left join program pr on pi.programid=pr.programid " +
@@ -199,8 +201,20 @@
 
         List<String[]> columns = new ArrayList<String[]>();
 
-        Collection<OrganisationUnitLevel> levels = organisationUnitService.getOrganisationUnitLevels();
-
+        Collection<OrganisationUnitGroupSet> orgUnitGroupSets = 
+            organisationUnitGroupService.getDataDimensionOrganisationUnitGroupSets();
+
+        Collection<OrganisationUnitLevel> levels = 
+            organisationUnitService.getOrganisationUnitLevels();
+
+        List<PeriodType> periodTypes = PeriodType.getAvailablePeriodTypes();
+
+        for ( OrganisationUnitGroupSet groupSet : orgUnitGroupSets )
+        {
+            String[] col = { quote( groupSet.getUid() ), "character(11)", "ougs." + quote( groupSet.getUid() ) };
+            columns.add( col );
+        }
+        
         for ( OrganisationUnitLevel level : levels )
         {
             String column = quote( PREFIX_ORGUNITLEVEL + level.getLevel() );
@@ -208,8 +222,6 @@
             columns.add( col );
         }
 
-        List<PeriodType> periodTypes = PeriodType.getAvailablePeriodTypes();
-
         for ( PeriodType periodType : periodTypes )
         {
             String column = quote( periodType.getName().toLowerCase() );