← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5189: Org unit distribution report, including a column for number of org units which are not member of ...

 

------------------------------------------------------------
revno: 5189
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-11-22 10:03:42 +0100
message:
  Org unit distribution report, including a column for number of org units which are not member of any of the groups in the selected group set
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.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-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2011-09-08 15:47:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2011-11-22 09:03:42 +0000
@@ -65,6 +65,7 @@
 
     private static final String TITLE_SEP = " - ";
     private static final String FIRST_COLUMN_TEXT = "Organisation unit";
+    private static final String HEADER_NONE = "None";
     private static final String HEADER_TOTAL = "Total";
     
     // -------------------------------------------------------------------------
@@ -135,23 +136,46 @@
             grid.addHeader( new GridHeader( group.getName(), false, false )  );
         }
         
+        grid.addHeader( new GridHeader( HEADER_NONE, false, false ) );
         grid.addHeader( new GridHeader( HEADER_TOTAL, false, false ) );
         
+        boolean hasNone = false;
+        
         for ( OrganisationUnit unit : units )
         {            
             grid.addRow();
             grid.addValue( unit.getName() );
             
+            int totalGroup = 0;
+            
             Collection<OrganisationUnit> subTree = organisationUnitService.getOrganisationUnitWithChildren( unit.getId() ); 
             
             for ( OrganisationUnitGroup group : groups )
             {
                 Collection<OrganisationUnit> result = CollectionUtils.intersection( subTree, group.getMembers() );
                 
-                grid.addValue( result != null ? result.size() : 0 );
-            }
-            
-            grid.addValue( subTree != null ? subTree.size() : 0 );
+                int count = result != null ? result.size() : 0;
+                
+                grid.addValue( count );
+                
+                totalGroup += count;
+            }
+            
+            int total = subTree != null ? subTree.size() : 0;
+            int none = total - totalGroup;
+            
+            grid.addValue( none );
+            grid.addValue( total );
+            
+            if ( none > 0 )
+            {
+                hasNone = true;
+            }
+        }
+        
+        if ( !hasNone )
+        {
+            grid.removeColumn( grid.getWidth() - 2 ); // None column
         }
         
         return grid;