← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1986: Trying to improve getorgunitdetails for huge orgunit tree

 

------------------------------------------------------------
revno: 1986
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-02 15:01:44 +0530
message:
  Trying to improve getorgunitdetails for huge orgunit tree
modified:
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/GetOrgUnitsAction.java
  local/in/dhis-web-reports-national/src/main/resources/struts.xml
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm


--
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 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/GetOrgUnitsAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/GetOrgUnitsAction.java	2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/GetOrgUnitsAction.java	2010-11-02 09:31:44 +0000
@@ -1,15 +1,14 @@
 package org.hisp.dhis.dashboard.action;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
+import java.util.Date;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 
-import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.Action;
 
-public class GetOrgUnitsAction
-    extends ActionSupport
+public class GetOrgUnitsAction implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -68,6 +67,7 @@
     public String execute()
         throws Exception
     {
+        System.out.println( "StartTime: "+ new Date() );
         /* OrganisationUnit */
         if ( orgUnitId != null )
         {
@@ -76,29 +76,45 @@
 
         orgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
         maxOrgUnitLevel = orgUnitLevel;
-        
-        // Hardcoded : if it is Tabular Analysis, Null Reporter
-        if(type!=null && type.equalsIgnoreCase( "ta" ))
-        {
-        
-        List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
-        
-        for( OrganisationUnit ou : orgUnitTree )
-        {
-            if( organisationUnitService.getLevelOfOrganisationUnit( ou ) > maxOrgUnitLevel )
-            {
-                maxOrgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( ou );
-            }
-        }
-        }
-        
-            
-       
-        //System.out.println( "OrgUnitLevel : " + orgUnitLevel + " Name : " + orgUnit.getShortName() + " MaxLevel : "+ maxOrgUnitLevel );
+        int maxNumberofLevels = organisationUnitService.getNumberOfOrganisationalLevels();
+        
+        // Hardcoded : if it is Tabular Analysis, Null Reporter
+        if( type != null && type.equalsIgnoreCase( "ta" ) )
+        {
+            for( int i = orgUnitLevel+1; i <= maxNumberofLevels; i++ )
+            {
+                Collection<OrganisationUnit> tempOrgUnitList = organisationUnitService.getOrganisationUnitsAtLevel( i, orgUnit );
+                if( tempOrgUnitList == null || tempOrgUnitList.size() == 0 )
+                {
+                    maxOrgUnitLevel = i;
+                    break;
+                }
+            }
+        }
+        
+        System.out.println( "EndTime: "+ new Date() );
+        
+        /*
+        orgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
+        maxOrgUnitLevel = orgUnitLevel;
+        
+        // Hardcoded : if it is Tabular Analysis, Null Reporter
+        if( type != null && type.equalsIgnoreCase( "ta" ) )
+        {
+            List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( orgUnitId ) );
+            
+            
+            for( OrganisationUnit ou : orgUnitTree )
+            {
+                if( organisationUnitService.getLevelOfOrganisationUnit( ou ) > maxOrgUnitLevel )
+                {
+                    maxOrgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( ou );
+                }
+            }
+        }
+        */
 
         return SUCCESS;
     }
 
-    
-
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/struts.xml'
--- local/in/dhis-web-reports-national/src/main/resources/struts.xml	2010-09-23 10:40:37 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/struts.xml	2010-11-02 09:31:44 +0000
@@ -16,14 +16,15 @@
 			<param name="page">/dhis-web-reports/welcome.vm</param>
 			<param name="menu">/dhis-web-reports/menu.vm</param>
 		</action>
-		<!-- Reports Management start 07/08/2010 Global-->
+		
+		<!-- Reports Management -->
 		<action name="reportManagement"
 			class="org.hisp.dhis.reports.reportmanagement.action.ReportsListAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-reports/reportsList.vm</param>
 			<param name="menu">/dhis-web-reports/menu.vm</param>
-			<param name="javascripts">
-				javascript/reportManagement.js,javascript/filterTable.js</param>
+			<param name="javascripts">javascript/reportManagement.js,javascript/filterTable.js</param>
+			<param name="requiredAuthorities">F_REPORT_MANAGEMENT_LIST</param>
 		</action>
 		
 		<!-- Report Management Addition Start-->
@@ -36,8 +37,7 @@
 		</action>
 		<action name="addReport"
 			class="org.hisp.dhis.reports.reportmanagement.action.AddReportAction">
-			<result name="success" type="redirect">
-				reportManagement.action</result>
+			<result name="success" type="redirect">reportManagement.action</result>
 		</action>
 		<!-- Report Management Addition End-->
 		

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2010-09-13 10:03:14 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm	2010-11-02 09:31:44 +0000
@@ -1,56 +1,31 @@
 <h2>Report Analyser</h2>
+
+#if( $auth.hasAccess( "dhis-web-reports", "reportManagement") )
 <ul>
     <li>Report Management</li>
     <ul>
         <li><a href = "reportManagement.action">Report Management</a></li>
     </ul>
 </ul>
+#end
 <ul>
     <li>Report Analysis</li>
     <ul>
         <li><a href = "upwardReportAnalyser.action">GOI Reports</a></li>
-       
         <li><a href = "edReportForm.action">ED Report</a></li>
         <li><a href = "routineReportAnalyser.action">Routine Reports</a></li>
-        
         <li><a href = "feedbackReportAnalyser.action">Feedback Reports</a></li>
-
-<!--    <li><a href = "cumulativeReportAnalyser.action">Aggregation Reports</a></li>-->
         <li><a href = "aggregationReportAnalyser.action">Aggregation Reports</a></li>
         <li><a href = "linelistingReportAnalyser.action">Linelisting Reports</a></li>
-        <!--
-        <li><a href = "dataSetReport.action">Dataset Report</a></li>
-        <li><a href = "displayPivotTableForm.action">Pivot Table</a></li>
-       
-        <li><a href = "progressReportAnalyser.action">Periodwise Progress Reports</a></li>
--->         
         <li><a href = "periodWiseprogressReportAnalyser.action">Periodwise Progress Reports</a></li>
         <li><a href = "ouWiseProgressReportAnalyser.action">Orgunitwise Progress Reports</a></li>
         <li><a href = "metaDataReportAnalyser.action">Meta Data Reports</a></li>
         <li><a href = "benificiaryInfoReportsAnalyser.action">NBITS Benificiary Info</a></li>
         <li><a href = "activePlanReportsAnalyser.action">NBITS Reports</a></li>
         <li><a href = "portalReportsAnalyser.action">NBITS Portal Reports</a></li>
-		
 		<li><a href = "dataSetLockReportAnalyser.action">DataSet Lock Reports</a></li>
         <li><a href = "quarterlyPhysicalReport.action ">Quarterly Physical Output Reports</a></li>              
-
         <li><a href = "csReviewReportForm.action">CS Review Reports</a></li>  
-        <li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>
-		
-		  <!-- 
-	    <li><a href = "TwentyPointReportsAnalyser.action">Twenty Point Reports</a></li>       
-        <li><a href = "malaryaForm.action">Malaria Reports</a></li>
-        <li><a href = "nlepForm.action">NLEP Reports</a></li>
-        <li><a href = "rankingReportForm.action">Ranking Report</a></li>
-        <li><a href = "specialReportForm.action">OrgUnitGroupSet Reports</a></li> 
-        <li><a href = "autoReportAnalyser.action">Auto Reports</a></li>        
-        <li>Grading</li>
-		<ul>
-			<li><a href = "gradingReportAnalyser.action">Detailed</a></li>
-			<li><a href = "gradingAbstration.action">Abstraction</a></li>			
-		</ul>
-       <li><a href = "populateUsers.action">Populate Users</a></li>
-        -->
-								
+        <!--<li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>-->
     </ul>
 </ul>