← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2108: Added SummaryReport Functionality in Manpower Module

 

------------------------------------------------------------
revno: 2108
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-11-19 15:03:44 +0530
message:
  Added SummaryReport Functionality in Manpower Module
added:
  local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/
  local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java
  local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menuForSummaryReport.vm
  local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm
modified:
  local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml
  local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml
  local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/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
=== added directory 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports'
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java	1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java	2010-11-19 09:33:44 +0000
@@ -0,0 +1,150 @@
+package org.hisp.dhis.ll.action.reports;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.dbmanager.DataBaseManagerInterface;
+import org.hisp.dhis.linelisting.LineListDataElementMap;
+import org.hisp.dhis.linelisting.LineListElement;
+import org.hisp.dhis.linelisting.LineListGroup;
+import org.hisp.dhis.linelisting.LineListOption;
+import org.hisp.dhis.linelisting.LineListService;
+import org.hisp.dhis.ll.action.lldataentry.SelectedStateManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+
+import com.opensymphony.xwork2.Action;
+
+public class SummaryReportAction
+implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SelectedStateManager selectedStateManager;
+
+    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    {
+        this.selectedStateManager = selectedStateManager;
+    }
+
+    private DataBaseManagerInterface dataBaseManagerInterface;
+
+    public void setDataBaseManagerInterface( DataBaseManagerInterface dataBaseManagerInterface )
+    {
+        this.dataBaseManagerInterface = dataBaseManagerInterface;
+    }
+
+    private LineListService lineListService;
+    
+    public void setLineListService( LineListService lineListService )
+    {
+        this.lineListService = lineListService;
+    }
+
+    private DataValueService dataValueService;
+    
+    public void setDataValueService( DataValueService dataValueService )
+    {
+        this.dataValueService = dataValueService;
+    }
+
+    private PeriodService periodService;
+    
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Map<String, String> resultMap;
+    
+    public Map<String, String> getResultMap()
+    {
+        return resultMap;
+    }
+
+    List<String> resultKeys;
+    
+    public List<String> getResultKeys()
+    {
+        return resultKeys;
+    }
+    
+    private String selOrgUnitName = "NONE";
+    
+    public String getSelOrgUnitName()
+    {
+        return selOrgUnitName;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        resultMap = new HashMap<String, String>();
+        resultKeys = new ArrayList<String>();
+        Period dataValuePeriod = periodService.getPeriod( 0 );
+        OrganisationUnit selOrgUnit = selectedStateManager.getSelectedOrganisationUnit();
+        String lastWorkingDateLLElementName  = "lastworkingdate";
+        //int sanctionedPostsCount = 0;
+        
+        if( selOrgUnit == null )
+        {
+            return SUCCESS;
+        }
+        
+        selOrgUnitName = selOrgUnit.getName();
+        
+        List<LineListGroup> lineListGroups = new ArrayList<LineListGroup>( lineListService.getLineListGroupsBySource( selOrgUnit ) );
+        
+        for( LineListGroup lineListGroup : lineListGroups )
+        {
+            LineListElement postElement = lineListGroup.getLineListElements().iterator().next();
+            List<LineListOption> postOptions = new ArrayList<LineListOption>( postElement.getLineListElementOptions() );
+            
+            for( LineListOption postOption : postOptions )
+            {
+                int sanctionedPostsCount = 0;
+                Map<String, String> llElementValueMap = new HashMap<String, String>();
+                llElementValueMap.put( postElement.getShortName(), postOption.getName() );
+                llElementValueMap.put( lastWorkingDateLLElementName, "null" );
+
+                List<LineListDataElementMap> lineListDataElementMaps = lineListService.getLinelistDataelementMappings( postElement, postOption );
+                
+                if( lineListDataElementMaps != null )
+                {
+                    LineListDataElementMap lineListDataElementMap = lineListDataElementMaps.iterator().next();
+                    DataValue dataValue = dataValueService.getDataValue( selOrgUnit, lineListDataElementMap.getDataElement(), dataValuePeriod, lineListDataElementMap.getDataElementOptionCombo() );
+                    if( dataValue != null && dataValue.getValue() != null )
+                    {
+                        sanctionedPostsCount = Integer.parseInt( dataValue.getValue() );
+                    }
+                }
+                
+                int filledPostsCount = dataBaseManagerInterface.getLLValueCountByLLElements( lineListGroup.getName(), llElementValueMap, selOrgUnit );
+                int vacantPostsCount = sanctionedPostsCount - filledPostsCount;
+                
+                resultMap.put( lineListGroup.getName()+" - "+postElement.getName(), sanctionedPostsCount + " - " + filledPostsCount + " - " + vacantPostsCount);
+            }
+        }
+        
+        resultKeys.addAll( resultMap.keySet() );
+        Collections.sort( resultKeys );
+        
+        return SUCCESS;
+    }
+
+}

=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml	2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml	2010-11-19 09:33:44 +0000
@@ -749,5 +749,25 @@
             <ref bean="org.hisp.dhis.dbmanager.DataBaseManagerInterface"/>
         </property>
     </bean>
+
+<!-- Linelisting Reports -->
+    <bean id="org.hisp.dhis.ll.action.reports.SummaryReportAction"
+        class="org.hisp.dhis.ll.action.reports.SummaryReportAction" scope="prototype">
+        <property name="lineListService">
+            <ref bean="org.hisp.dhis.linelisting.LineListService"/>
+        </property>     
+        <property name="periodService">
+            <ref bean="org.hisp.dhis.period.PeriodService"/>
+        </property>
+        <property name="dataBaseManagerInterface">
+            <ref bean="org.hisp.dhis.dbmanager.DataBaseManagerInterface"/>
+        </property>
+        <property name="dataValueService">
+            <ref bean="org.hisp.dhis.datavalue.DataValueService"/>
+        </property>
+        <property name="selectedStateManager">
+            <ref bean="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager"/>
+        </property>
+    </bean>
 		
 </beans>

=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml	2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml	2010-11-19 09:33:44 +0000
@@ -557,7 +557,7 @@
 
 		<action name="linelistAggregationResult" class="org.hisp.dhis.ll.action.llagg.LinelistingAggregationResultAction">                 
 		  <result name="success" type="velocity">/main.vm</result>
-		  <param name="page">/dhis-web-linelisting-mp/linelistingAggResult.vm</param>
+		  <param name="page">/dhis-web-linelisting-mp/summaryReportResult.vm</param>
 		  <param name="menu">/dhis-web-linelisting-mp/menu.vm</param>      
 		</action>
 
@@ -567,6 +567,15 @@
       <param name="page">/dhis-web-linelisting-mp/llDataImportResult.vm</param>
       <param name="menu">/dhis-web-linelisting-mp/menu.vm</param>             
     </action>
+
+<!-- Linelisting Reports -->
+    <action name="summaryReport" class="org.hisp.dhis.ll.action.reports.SummaryReportAction">
+		<interceptor-ref name="organisationUnitTreeStack"/>
+		<result name="success" type="velocity">/main.vm</result>
+		<param name="page">/dhis-web-linelisting-mp/summaryReportResult.vm</param>
+		<param name="menu">/dhis-web-linelisting-mp/menuForSummaryReport.vm</param>      	  
+        <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js</param>	         
+    </action>
 		
     
     </package>

=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm	2010-10-20 06:14:25 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm	2010-11-19 09:33:44 +0000
@@ -9,6 +9,12 @@
 	<ul>
 		<li><a href="select.action">DataEntry</a></li>
 	</ul>
+<h2>Linelisting Reports</h2>
+    <ul>
+        <li><a href="summaryReport.action">Linelist Summary Report</a></li>
+		<li><a href="#">Linelist Detailed Report</a></li>
+    </ul>
+<!--
 <h2>Linelisting Validation Rules</h2>
 	<ul>
 		<li><a href="showValidationRules.action">Linelist Validation Rules</a></li>
@@ -18,11 +24,8 @@
         <li><a href="showLLAggQueryBuilderForm.action">Linelisting Aggregation Query Builder</a></li>
         <li><a href="linelistAggForm.action">Linelisting Aggregation</a></li>
     </ul>
-<!--<ul>
-        <li><a href="linelistAggForm.action">$i18n.getString( "linelisting_aggregation" )</a></li>     
-    </ul> -->
 <h2>Linelisting Data Import</h2>
     <ul>
         <li><a href="lldataImport.action">Linelisting Data Import</a></li>
     </ul>
-    
\ No newline at end of file
+-->    
\ No newline at end of file

=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menuForSummaryReport.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menuForSummaryReport.vm	1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menuForSummaryReport.vm	2010-11-19 09:33:44 +0000
@@ -0,0 +1,23 @@
+
+<h2>Linelisting Reports</h2>
+<ul>
+    <li>Summary Report</li>
+</ul>
+
+<div style=" float:right; font-size:6pt; cursor:pointer; margin-top:-20px; ">
+        <a href="index.action">
+          <img src="images/goback.png" width="36" height="30" alt="$i18n.getString( "go_back" )"></a>
+</div>
+
+#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
+
+<script>
+    
+    function organisationUnitSelected( orgUnits )
+    {
+        window.location.href = 'summaryReport.action';
+    }
+
+    selection.setListenerFunction( organisationUnitSelected );
+    
+</script>

=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm	1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm	2010-11-19 09:33:44 +0000
@@ -0,0 +1,18 @@
+
+#if( $selOrgUnitName == "NONE" )
+	<h1>Please select OrganisationUnit</h1>	
+#else
+	<h1>Summary Report Result for : $selOrgUnitName</h1>
+	<table>
+		<tr>
+			<th>Department Name - Post Name</th>
+			<th>Department Name - Post Name</th>
+		</tr>
+		#foreach( $resultKey in $resultKeys )
+			<tr>
+				<td>$resultKey</td>
+				<td>$resultMap.get( $resultKey )</td>
+			</tr>
+		#end
+	</table>
+#end
\ No newline at end of file