← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4996: completeness charts now have data

 

------------------------------------------------------------
revno: 4996
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-10-21 11:24:04 +0200
message:
  completeness charts now have data
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.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/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-10-20 12:52:57 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-10-21 09:24:04 +0000
@@ -27,15 +27,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.chart.Chart.DIMENSION_COMPLETENESS_PERIOD;
 import static org.hisp.dhis.chart.Chart.DIMENSION_DATAELEMENT_PERIOD;
 import static org.hisp.dhis.chart.Chart.DIMENSION_INDICATOR_PERIOD;
-import static org.hisp.dhis.chart.Chart.DIMENSION_COMPLETENESS_PERIOD;
+import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_COMPLETENESS;
 import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_DATAELEMENT;
 import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_INDICATOR;
-import static org.hisp.dhis.chart.Chart.DIMENSION_ORGANISATIONUNIT_COMPLETENESS;
+import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_COMPLETENESS;
 import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_DATAELEMENT;
 import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_INDICATOR;
-import static org.hisp.dhis.chart.Chart.DIMENSION_PERIOD_COMPLETENESS;
 import static org.hisp.dhis.chart.Chart.SIZE_NORMAL;
 import static org.hisp.dhis.chart.Chart.TYPE_BAR;
 import static org.hisp.dhis.chart.Chart.TYPE_BAR3D;
@@ -54,6 +54,7 @@
 import java.awt.Color;
 import java.awt.Font;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -73,6 +74,8 @@
 import org.hisp.dhis.chart.ChartStore;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
+import org.hisp.dhis.completeness.DataSetCompletenessService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataset.DataSet;
@@ -203,6 +206,13 @@
         this.currentUserService = currentUserService;
     }
 
+    private DataSetCompletenessService dataSetCompletenessService;
+
+    public void setDataSetCompletenessService( DataSetCompletenessService dataSetCompletenessService )
+    {
+        this.dataSetCompletenessService = dataSetCompletenessService;
+    }
+
     private GenericIdentifiableObjectStore<ChartGroup> chartGroupStore;
 
     public void setChartGroupStore( GenericIdentifiableObjectStore<ChartGroup> chartGroupStore )
@@ -904,7 +914,19 @@
                         }
                         else if ( isCompletenessChart )
                         {
-                            // Completeness value here
+                            List<DataSetCompletenessResult> dataSetCompleteness = new ArrayList<DataSetCompletenessResult>(
+                                dataSetCompletenessService.getDataSetCompleteness( period.getId(),
+                                    Arrays.asList( selectedOrganisationUnit.getId() ), dataSets.get( i ).getId() ) );
+
+                            if ( !dataSetCompleteness.isEmpty() )
+                            {
+                                DataSetCompletenessResult dataSetCompletenessResult = dataSetCompleteness.get( 0 );
+                                value = dataSetCompletenessResult.getPercentage();
+                            }
+                            else
+                            {
+                                value = 0d;
+                            }
                         }
 
                         if ( chart.isDimension( DIMENSION_PERIOD_INDICATOR )
@@ -981,7 +1003,19 @@
                         }
                         else if ( isCompletenessChart )
                         {
-                            // Completeness value here
+                            List<DataSetCompletenessResult> dataSetCompleteness = new ArrayList<DataSetCompletenessResult>(
+                                dataSetCompletenessService.getDataSetCompleteness( selectedPeriod.getId(),
+                                    Arrays.asList( unit.getId() ), dataSets.get( i ).getId() ) );
+
+                            if ( !dataSetCompleteness.isEmpty() )
+                            {
+                                DataSetCompletenessResult dataSetCompletenessResult = dataSetCompleteness.get( 0 );
+                                value = dataSetCompletenessResult.getPercentage();
+                            }
+                            else
+                            {
+                                value = 0d;
+                            }
                         }
 
                         regularDataSet.addValue( value != null ? value : 0, shortName, unit.getShortName() );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-10-11 15:11:09 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-10-21 09:24:04 +0000
@@ -4,7 +4,7 @@
   xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd";>
-    
+
   <!-- ReportTable -->
 
   <bean id="internal-process-ReportTable" class="org.hisp.dhis.reporttable.ReportTableInternalProcess" scope="prototype">
@@ -39,7 +39,7 @@
     <property name="dataMartService" ref="org.hisp.dhis.datamart.DataMartService" />
     <property name="completenessService" ref="registrationDataCompletenessService" />
   </bean>
-  
+
   <!-- Report -->
 
   <bean id="org.hisp.dhis.report.ReportStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
@@ -47,7 +47,7 @@
     <property name="sessionFactory" ref="sessionFactory" />
     <property name="cacheable" value="true" />
   </bean>
-  
+
   <bean id="org.hisp.dhis.report.ReportGroupStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="clazz" value="org.hisp.dhis.report.ReportGroup" />
     <property name="sessionFactory" ref="sessionFactory" />
@@ -57,12 +57,12 @@
   <bean id="org.hisp.dhis.report.ReportService" class="org.hisp.dhis.report.impl.DefaultReportService">
     <property name="reportStore" ref="org.hisp.dhis.report.ReportStore" />
     <property name="reportGroupStore" ref="org.hisp.dhis.report.ReportGroupStore" />
-	<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
-	<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
+    <property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
+    <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
     <property name="statementManager" ref="statementManager" />
-	<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+    <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
   </bean>
-    
+
   <!-- Chart -->
 
   <bean id="org.hisp.dhis.chart.ChartStore" class="org.hisp.dhis.chart.hibernate.HibernateChartStore">
@@ -70,7 +70,7 @@
     <property name="sessionFactory" ref="sessionFactory" />
     <property name="cacheable" value="true" />
   </bean>
-  
+
   <bean id="org.hisp.dhis.chart.ChartGroupStore" class="org.hisp.dhis.chart.hibernate.HibernateChartStore">
     <property name="clazz" value="org.hisp.dhis.chart.ChartGroup" />
     <property name="sessionFactory" ref="sessionFactory" />
@@ -87,8 +87,9 @@
     <property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
     <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+    <property name="dataSetCompletenessService" ref="registrationDataCompletenessService" />
   </bean>
-  
+
   <!-- Document -->
 
   <bean id="org.hisp.dhis.document.DocumentStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
@@ -100,7 +101,7 @@
   <bean id="org.hisp.dhis.document.DocumentService" class="org.hisp.dhis.document.impl.DefaultDocumentService">
     <property name="documentStore" ref="org.hisp.dhis.document.DocumentStore" />
   </bean>
-  
+
   <!-- DataSetCompleteness -->
 
   <bean id="dataCompletenessServiceProvider" class="org.hisp.dhis.common.ServiceProvider">
@@ -148,7 +149,7 @@
   <bean id="org.hisp.dhis.completeness.DataSetCompletenessStore" class="org.hisp.dhis.completeness.jdbc.JDBCDataSetCompletenessStore">
     <property name="statementManager" ref="statementManager" />
   </bean>
-  
+
   <!-- PivotTable -->
 
   <bean id="org.hisp.dhis.pivottable.PivotTableService" class="org.hisp.dhis.pivottable.impl.DefaultPivotTableService">
@@ -158,7 +159,7 @@
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
-  
+
   <!-- DataSetReport -->
 
   <bean id="org.hisp.dhis.datasetreport.DataSetReportService" class="org.hisp.dhis.datasetreport.impl.DefaultDataSetReportService">
@@ -167,7 +168,7 @@
     <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
     <property name="aggregationService" ref="org.hisp.dhis.aggregation.AggregationService" />
   </bean>
-  
+
   <!-- Dashboard -->
 
   <bean id="org.hisp.dhis.dashboard.DashboardContentStore" class="org.hisp.dhis.dashboard.hibernate.HibernateDashboardContentStore">
@@ -179,7 +180,7 @@
   <bean id="org.hisp.dhis.dashboard.DashboardService" class="org.hisp.dhis.dashboard.impl.DefaultDashboardService">
     <property name="dashboardContentStore" ref="org.hisp.dhis.dashboard.DashboardContentStore" />
   </bean>
-  
+
   <!-- Dashboard Content providers -->
 
   <bean id="reportContentProvider" class="org.hisp.dhis.dashboard.provider.ReportContentProvider">
@@ -211,7 +212,7 @@
     <property name="url" value="http://health.yahoo.com/news/rss/health"; />
     <property name="key" value="healthItems" />
   </bean>
-  
+
   <!-- Dashboard Manager -->
 
   <bean id="org.hisp.dhis.dashboard.DashboardManager" class="org.hisp.dhis.dashboard.manager.DefaultDashboardManager">
@@ -251,7 +252,7 @@
       </map>
     </property>
   </bean>
-  
+
   <!-- Tally Sheet -->
 
   <bean id="org.hisp.dhis.tallysheet.TallySheetService" class="org.hisp.dhis.tallysheet.DefaultTallySheetService">
@@ -259,14 +260,14 @@
   </bean>
 
   <bean id="org.hisp.dhis.tallysheet.TallySheetPdfService" class="org.hisp.dhis.tallysheet.DefaultTallySheetPdfService" />
-  
+
   <!-- Organisation Unit Distribution -->
 
   <bean id="org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService" class="org.hisp.dhis.orgunitdistribution.impl.DefaultOrgUnitDistributionService">
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
   </bean>
-  
+
   <!-- Scheduling -->
 
   <bean id="org.hisp.dhis.scheduling.SchedulingManager" class="org.hisp.dhis.scheduling.DefaultSchedulingManager"
@@ -293,7 +294,7 @@
     <constructor-arg ref="org.hisp.dhis.dataset.DataSetService" />
     <constructor-arg ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
-  
+
   <!-- DeletionHandler -->
 
   <bean id="org.hisp.dhis.report.ReportDeletionHandler" class="org.hisp.dhis.report.ReportDeletionHandler">
@@ -311,7 +312,7 @@
   <bean id="org.hisp.dhis.dashboard.DashboardContentDeletionHandler" class="org.hisp.dhis.dashboard.DashboardContentDeletionHandler">
     <property name="dashboardService" ref="org.hisp.dhis.dashboard.DashboardService" />
   </bean>
-  
+
   <!-- DeletionManager -->
 
   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -328,7 +329,7 @@
       </list>
     </property>
   </bean>
-  
+
   <!-- AOP definitions -->
 
   <aop:config>
@@ -341,12 +342,17 @@
     </aop:aspect>
 
     <aop:aspect ref="statementInterceptor">
-      <aop:around pointcut="execution( * org.hisp.dhis.completeness.DataSetCompletenessService.exportDataSetCompleteness(..) )" method="intercept" />
-      <aop:around pointcut="execution( * org.hisp.dhis.completeness.DataSetCompletenessService.getDataSetCompleteness(..) )" method="intercept" />
+      <aop:around pointcut="execution( * org.hisp.dhis.completeness.DataSetCompletenessService.exportDataSetCompleteness(..) )"
+        method="intercept" />
+      <aop:around pointcut="execution( * org.hisp.dhis.completeness.DataSetCompletenessService.getDataSetCompleteness(..) )"
+        method="intercept" />
       <aop:around pointcut="execution( * org.hisp.dhis.chart.ChartService.getJFreeChart*(..) )" method="intercept" />
-      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getCustomDataSetReport(..) )" method="intercept" />
-      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getSectionDataSetReport(..) )" method="intercept" />
-      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getDefaultDataSetReport(..) )" method="intercept" />
+      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getCustomDataSetReport(..) )"
+        method="intercept" />
+      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getSectionDataSetReport(..) )"
+        method="intercept" />
+      <aop:around pointcut="execution( * org.hisp.dhis.datasetreport.DataSetReportService.getDefaultDataSetReport(..) )"
+        method="intercept" />
     </aop:aspect>
 
   </aop:config>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java	2011-10-20 13:05:27 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java	2011-10-21 09:24:04 +0000
@@ -155,14 +155,8 @@
     {
         Grid _grid = (Grid) SessionUtils.getSessionVar( KEY_DATA_COMPLETENESS );
 
-        if ( _grid != null && type != null && !type.equals( DEFAULT_TYPE ) ) // Use
-                                                                             // last
-                                                                             // grid
-                                                                             // for
-                                                                             // any
-                                                                             // format
-                                                                             // except
-                                                                             // html
+        // Uselast grid for any format except html
+        if ( _grid != null && type != null && !type.equals( DEFAULT_TYPE ) )
         {
             grid = _grid;