← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3206: Implemented grand parent report table parameter. Now its easy eg to create a province report with...

 

------------------------------------------------------------
revno: 3206
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-03-29 22:06:47 +0200
message:
  Implemented grand parent report table parameter. Now its easy eg to create a province report with all districts.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportParams.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js


--
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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-02-17 02:14:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-03-29 20:06:47 +0000
@@ -154,6 +154,18 @@
     // Logic
     // -------------------------------------------------------------------------
     
+    public Set<OrganisationUnit> getGrandChildren()
+    {
+        Set<OrganisationUnit> grandChildren = new HashSet<OrganisationUnit>();
+        
+        for ( OrganisationUnit child : children )
+        {
+            grandChildren.addAll( child.getChildren() );
+        }
+        
+        return grandChildren;
+    }
+    
     public boolean hasChild()
     {
     	return !this.children.isEmpty();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportParams.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportParams.java	2011-03-29 20:06:47 +0000
@@ -41,6 +41,8 @@
     implements Serializable
 {
     private Boolean paramReportingMonth;
+
+    private Boolean paramGrandParentOrganisationUnit;
     
     private Boolean paramParentOrganisationUnit;
     
@@ -54,9 +56,10 @@
     {
     }
     
-    public ReportParams( boolean paramReportingMonth, boolean paramParentOrganisationUnit, boolean paramOrganisationUnit )
+    public ReportParams( boolean paramReportingMonth, boolean paramGrandParentOrganisationUnit, boolean paramParentOrganisationUnit, boolean paramOrganisationUnit )
     {
         this.paramReportingMonth = paramReportingMonth;
+        this.paramGrandParentOrganisationUnit = paramGrandParentOrganisationUnit;
         this.paramParentOrganisationUnit = paramParentOrganisationUnit;
         this.paramOrganisationUnit = paramOrganisationUnit;
     }
@@ -70,6 +73,11 @@
         return paramReportingMonth != null && paramReportingMonth;
     }
     
+    public boolean isParamGrandParentOrganisationUnit()
+    {
+        return paramGrandParentOrganisationUnit != null && paramGrandParentOrganisationUnit;
+    }
+    
     public boolean isParamParentOrganisationUnit()
     {
         return paramParentOrganisationUnit != null && paramParentOrganisationUnit;
@@ -82,7 +90,7 @@
     
     public boolean isSet()
     {
-        return isParamReportingMonth() || isParamParentOrganisationUnit() || isParamOrganisationUnit();
+        return isParamReportingMonth() || isParamGrandParentOrganisationUnit() || isParamParentOrganisationUnit() || isParamOrganisationUnit();
     }
 
     // -------------------------------------------------------------------------
@@ -99,6 +107,16 @@
         this.paramReportingMonth = paramReportingMonth;
     }
 
+    public Boolean getParamGrandParentOrganisationUnit()
+    {
+        return paramGrandParentOrganisationUnit;
+    }
+
+    public void setParamGrandParentOrganisationUnit( Boolean paramGrandParentOrganisationUnit )
+    {
+        this.paramGrandParentOrganisationUnit = paramGrandParentOrganisationUnit;
+    }
+
     public Boolean getParamParentOrganisationUnit()
     {
         return paramParentOrganisationUnit;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-28 20:10:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-03-29 20:06:47 +0000
@@ -305,6 +305,21 @@
         }
 
         // ---------------------------------------------------------------------
+        // Grand parent organisation unit report parameter
+        // ---------------------------------------------------------------------
+
+        if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamGrandParentOrganisationUnit() )
+        {
+            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+            organisationUnit.setCurrentParent( true );
+            reportTable.getRelativeUnits().addAll( new ArrayList<OrganisationUnit>( organisationUnit.getGrandChildren() ) );
+            reportTable.getRelativeUnits().add( organisationUnit );
+            reportTable.setOrganisationUnitName( organisationUnit.getName() );
+            
+            log.info( "Grand parent organisation unit: " + organisationUnit.getName() );
+        }
+
+        // ---------------------------------------------------------------------
         // Parent organisation unit report parameter
         // ---------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-02-23 23:39:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-03-29 20:06:47 +0000
@@ -72,6 +72,7 @@
     
     <component name="reportParams">
       <property name="paramReportingMonth"/>
+      <property name="paramGrandParentOrganisationUnit"/>
       <property name="paramParentOrganisationUnit"/>
       <property name="paramOrganisationUnit"/>
     </component>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2011-02-22 23:17:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2011-03-29 20:06:47 +0000
@@ -28,15 +28,10 @@
  */
 
 import java.util.Calendar;
-import java.util.Collection;
-import java.util.List;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
 import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -67,13 +62,6 @@
         this.reportTableService = reportTableService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -119,21 +107,7 @@
     {
         return reportParams;
     }
-    
-    private List<OrganisationUnitLevel> levels;
-
-    public List<OrganisationUnitLevel> getLevels()
-    {
-        return levels;
-    }
-    
-    private Collection<OrganisationUnit> organisationUnits;
-
-    public Collection<OrganisationUnit> getOrganisationUnits()
-    {
-        return organisationUnits;
-    }
-    
+        
     private SortedMap<Integer, String> reportingPeriods = new TreeMap<Integer, String>();
 
     public SortedMap<Integer, String> getReportingPeriods()
@@ -161,14 +135,7 @@
             if ( reportTable != null )
             {
                 reportParams = reportTable.getReportParams();
-                
-                if ( reportParams.isParamParentOrganisationUnit() || reportParams.isParamOrganisationUnit() )
-                {
-                    levels = organisationUnitService.getOrganisationUnitLevels();
-                    
-                    organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( 1 );
-                }
-                
+                                
                 if ( reportParams.isParamReportingMonth() )
                 {
                     MonthlyPeriodType periodType = new MonthlyPeriodType();

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-02-19 00:09:05 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-03-29 20:06:47 +0000
@@ -270,6 +270,13 @@
         this.paramReportingMonth = paramReportingMonth;
     }
 
+    private boolean paramGrandParentOrganisationUnit;
+    
+    public void setParamGrandParentOrganisationUnit( boolean paramGrandParentOrganisationUnit )
+    {
+        this.paramGrandParentOrganisationUnit = paramGrandParentOrganisationUnit;
+    }
+
     private boolean paramParentOrganisationUnit;
 
     public void setParamParentOrganisationUnit( boolean paramParentOrganisationUnit )
@@ -339,6 +346,7 @@
         ReportParams reportParams = new ReportParams();
         
         reportParams.setParamReportingMonth( paramReportingMonth );
+        reportParams.setParamGrandParentOrganisationUnit( paramGrandParentOrganisationUnit );
         reportParams.setParamParentOrganisationUnit( paramParentOrganisationUnit );
         reportParams.setParamOrganisationUnit( paramOrganisationUnit );
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-03-23 02:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-03-29 20:06:47 +0000
@@ -195,8 +195,6 @@
     scope="prototype">
     <property name="reportTableService"
       ref="org.hisp.dhis.reporttable.ReportTableService"/>
-    <property name="organisationUnitService"
-      ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
   </bean>
   
   <bean id="org.hisp.dhis.reporting.tablecreator.action.GetAllTablesAction"

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-03-19 22:30:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-03-29 20:06:47 +0000
@@ -324,4 +324,5 @@
 top_limit = Top limit
 data_type = Data type
 indicator = Indicator
-data_element_group = Data element group
\ No newline at end of file
+data_element_group = Data element group
+grand_parent_organisation_unit = Grand parent organisation unit
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2011-03-28 20:09:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2011-03-29 20:06:47 +0000
@@ -437,6 +437,8 @@
     	<td>
     		<label for="paramReportingMonth">$i18n.getString( "reporting_month" )</label>
     	    <input type="checkbox" id="paramReportingMonth" name="paramReportingMonth" value="true"#if( $reportTable.reportParams.isParamReportingMonth() ) checked#end>&nbsp;
+    	    <label for="paramGrandParentOrganisationUnit">$i18n.getString( "grand_parent_organisation_unit" )</label>
+            <input type="checkbox" id="paramGrandParentOrganisationUnit" name="paramGrandParentOrganisationUnit" value="true"#if( $reportTable.reportParams.isParamGrandParentOrganisationUnit() ) checked#end>&nbsp;
     	    <label for="paramParentOrganisationUnit">$i18n.getString( "parent_organisation_unit" )</label>
             <input type="checkbox" id="paramParentOrganisationUnit" name="paramParentOrganisationUnit" value="true"#if( $reportTable.reportParams.isParamParentOrganisationUnit() ) checked#end>&nbsp;
             <label for="paramOrganisationUnit">$i18n.getString( "organisation_unit" )</label>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-03-28 20:09:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-03-29 20:06:47 +0000
@@ -57,7 +57,8 @@
     #end
     
     <!-- OrganisationUnit -->
-    #if ( $!reportParams.isParamParentOrganisationUnit() || $!reportParams.isParamOrganisationUnit() )
+    
+    #if ( $!reportParams.isParamGrandParentOrganisationUnit() || $!reportParams.isParamParentOrganisationUnit() || $!reportParams.isParamOrganisationUnit() )
         
 	<tr>
         <th>$i18n.getString( "organisation_unit" )</th>
@@ -76,9 +77,11 @@
     <tr>
         <td colspan="4" style="height:10px"></td>
     </tr>
+    
     #end
     
-    <!-- Submit -->    
+    <!-- Submit -->
+    
     <tr>
         <td>
     	#if( $!reportParams.isSet() )

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2011-03-20 22:35:55 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2011-03-29 20:06:47 +0000
@@ -115,7 +115,8 @@
 
 function organisationUnitReportParamsChecked()
 {
-    if ( isChecked( "paramParentOrganisationUnit" ) == true ||
+    if ( isChecked( "paramGrandParentOrganisationUnit" ) == true ||
+         isChecked( "paramParentOrganisationUnit" ) == true ||
          isChecked( "paramOrganisationUnit" ) == true )
     {
         return true;
@@ -126,13 +127,22 @@
 
 function bothOrganisationUnitReportParamsChecked()
 {
-	if ( isChecked( "paramParentOrganisationUnit" ) == true &&
-         isChecked( "paramOrganisationUnit" ) == true )
+	var count = 0;
+	
+	if ( isChecked( "paramGrandParentOrganisationUnit" ) )
+	{
+		count++;
+	}
+	if ( isChecked( "paramParentOrganisationUnit" ) )
+	{
+		count++;
+	}
+    if( isChecked( "paramOrganisationUnit" ) )
     {
-        return true;
+        count++;
     }
     
-    return false;
+    return count > 1;
 }
 
 // -----------------------------------------------------------------------------