← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2481: Added system setting for aggregation strategy and implemented it in report, report table, chart, ...

 

------------------------------------------------------------
revno: 2481
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-01-07 12:37:47 +0100
message:
  Added system setting for aggregation strategy and implemented it in report, report table, chart, dataset report.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java
  dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml
  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/datasetreport/impl/DefaultDataSetReportService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2010-11-29 02:04:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2011-01-07 11:37:47 +0000
@@ -58,4 +58,5 @@
     double parseConditition( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period );
         
     Collection<PatientDataValue> getPatientDataValues( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period );
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-01-07 11:37:47 +0000
@@ -29,6 +29,7 @@
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.List;
 import java.util.SortedMap;
 
 /**
@@ -52,6 +53,7 @@
     final String KEY_GIS_LATITUDE = "latitude";
     final String KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED = "dataEntryFormCompleted";
     final String KEY_FACTOR_OF_DEVIATION = "factorDeviation";
+    final String KEY_AGGREGATION_STRATEGY = "aggregationStrategy";
     final String KEY_PATIENT_EXCEL_TEMPLATE_FILE_NAME = "patientExcelTemplateFileName";
     
     final String KEY_CHR_IMAGE_DIRECTORY = "chrImageDirectory";
@@ -61,6 +63,10 @@
     final int DEFAULT_TIMEFRAME_MINUTES = 1;
     final double DEFAULT_FACTOR_OF_DEVIATION = 2.0;
     
+    final String AGGREGATION_STRATEGY_REAL_TIME = "real_time";
+    final String AGGREGATION_STRATEGY_BATCH = "batch";
+    final String DEFAULT_AGGREGATION_STRATEGY = AGGREGATION_STRATEGY_REAL_TIME;
+    
     void saveSystemSetting( String name, Serializable value );   
 
     Serializable getSystemSetting( String name );   
@@ -72,4 +78,6 @@
     void deleteSystemSetting( String name );
     
     SortedMap<String, String> getFlags();
+    
+    List<String> getAggregationStrategies();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java	2011-01-07 11:37:47 +0000
@@ -28,7 +28,9 @@
  */
 
 import java.io.Serializable;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 import java.util.SortedMap;
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
@@ -129,4 +131,9 @@
     {
         return flags;
     }
+    
+    public List<String> getAggregationStrategies()
+    {
+        return Arrays.asList( AGGREGATION_STRATEGY_REAL_TIME, AGGREGATION_STRATEGY_BATCH );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2010-11-30 06:17:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2011-01-07 11:37:47 +0000
@@ -67,6 +67,10 @@
 public class DefaultCaseAggregationConditionService
     implements CaseAggregationConditionService
 {
+    private final String regExp = "\\[(" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|"
+        + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
+        + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -209,10 +213,6 @@
 
         String[] expression = aggregationCondition.getAggregationExpression().split( "(AND|OR)" );
 
-        String regExp = "\\[(" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|"
-            + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
-            + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
-
         // ---------------------------------------------------------------------
         // parse expressions
         // ---------------------------------------------------------------------
@@ -311,7 +311,7 @@
 
             conditions.add( condition );
         }
-        
+
         return getSQL( conditions, operators );
 
     }
@@ -433,28 +433,5 @@
 
         return patientIds.size();
     }
-
-    // public static void main( String[] args )
-    // {
-    //
-    // CaseAggregationCondition aggregationCondition = new
-    // CaseAggregationCondition();
-    //
-    // aggregationCondition.setOperator(
-    // CaseAggregationCondition.AGGRERATION_COUNT );
-    //
-    // // aggregationCondition.setAggregationExpression(
-    // // "( [DE:1.1.1] + [DE:1.1.1] + [DE:1.1.1] > 0 " );
-    // aggregationCondition.setAggregationExpression(
-    // " [DE:15.1.1]  +  [DE:16.2.1] > 0" );
-    // //
-    // aggregationCondition.setAggregationExpression("[PP:enrollmentdate - dateofincident]  > 0");
-    // // );
-    //
-    // DefaultCaseAggregationConditionService service = new
-    // DefaultCaseAggregationConditionService();
-    //
-    // service.parseConditition( aggregationCondition, null, null );
-    // }
-
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml	2010-12-27 07:59:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml	2011-01-07 11:37:47 +0000
@@ -16,7 +16,7 @@
 
 		<property name="lastName" column="lastname" length="50" />
 		
-		<property name="fullName" formula="concat(firstname, ' ', middleName,' ', lastname)"/>
+		<property name="fullName" formula="concat(firstname, lastname)"/>
 
 		<property name="birthDate" column="birthdate" not-null="true"/>
 		

=== 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	2010-12-14 11:36:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-01-07 11:37:47 +0000
@@ -48,6 +48,7 @@
 import org.apache.commons.math.analysis.UnivariateRealFunction;
 import org.apache.commons.math.analysis.UnivariateRealInterpolator;
 import org.apache.commons.math.stat.regression.SimpleRegression;
+import org.hisp.dhis.aggregation.AggregatedDataValueService;
 import org.hisp.dhis.aggregation.AggregationService;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.chart.ChartService;
@@ -60,6 +61,7 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.minmax.MinMaxDataElementService;
+import org.hisp.dhis.options.SystemSettingManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -81,6 +83,8 @@
 import org.jfree.data.category.DefaultCategoryDataset;
 import org.springframework.transaction.annotation.Transactional;
 
+import static org.hisp.dhis.options.SystemSettingManager.*;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -143,6 +147,20 @@
         this.aggregationService = aggregationService;
     }
 
+    private AggregatedDataValueService aggregatedDataValueService;
+    
+    public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
+    {
+        this.aggregatedDataValueService = aggregatedDataValueService;
+    }
+
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
+
     // -------------------------------------------------------------------------
     // ChartService implementation
     // -------------------------------------------------------------------------
@@ -439,6 +457,8 @@
      */
     private CategoryDataset[] getCategoryDataSet( Chart chart )
     {
+        String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY );
+        
         final DefaultCategoryDataset regularDataSet = new DefaultCategoryDataset();
         final DefaultCategoryDataset regressionDataSet = new DefaultCategoryDataset();
 
@@ -462,8 +482,9 @@
 
                     for ( Period period : chart.getAllPeriods() )
                     {
-                        final Double value = aggregationService.getAggregatedIndicatorValue( indicator, period
-                            .getStartDate(), period.getEndDate(), selectedOrganisationUnit );
+                        final Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? 
+                            aggregationService.getAggregatedIndicatorValue( indicator, period.getStartDate(), period.getEndDate(), selectedOrganisationUnit ) :
+                                aggregatedDataValueService.getAggregatedValue( indicator, period, selectedOrganisationUnit );
 
                         if ( chart.isDimension( DIMENSION_PERIOD ) )
                         {
@@ -516,8 +537,9 @@
 
                     for ( OrganisationUnit unit : chart.getOrganisationUnits() )
                     {
-                        final Double value = aggregationService.getAggregatedIndicatorValue( indicator, selectedPeriod
-                            .getStartDate(), selectedPeriod.getEndDate(), unit );
+                        final Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? 
+                            aggregationService.getAggregatedIndicatorValue( indicator, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), unit ) :
+                                aggregatedDataValueService.getAggregatedValue( indicator, selectedPeriod, unit );
 
                         regularDataSet.addValue( value != null ? value : 0, indicator.getShortName(), unit
                             .getShortName() );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2010-07-25 12:54:27 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java	2011-01-07 11:37:47 +0000
@@ -33,6 +33,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.hisp.dhis.aggregation.AggregatedDataValueService;
 import org.hisp.dhis.aggregation.AggregationService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -41,12 +42,15 @@
 import org.hisp.dhis.datasetreport.DataSetReportService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.options.SystemSettingManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.filter.AggregatableDataElementFilter;
 import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.system.util.MathUtils;
 
+import static org.hisp.dhis.options.SystemSettingManager.*;
+
 /**
  * @author Abyot Asalefew
  * @author Lars Helge Overland
@@ -76,6 +80,20 @@
     {
         this.aggregationService = aggregationService;
     }
+    
+    private AggregatedDataValueService aggregatedDataValueService;
+    
+    public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
+    {
+        this.aggregatedDataValueService = aggregatedDataValueService;
+    }
+
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
 
     // -------------------------------------------------------------------------
     // DataSetReportService implementation
@@ -83,6 +101,8 @@
     
     public Map<String, String> getAggregatedValueMap( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly )
     {
+        String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY );
+        
         Collection<DataElement> dataElements = dataSet.getDataElements();
         
         FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
@@ -103,9 +123,12 @@
                     value = ( dataValue != null ) ? dataValue.getValue() : null;
                 }
                 else
-                {                                   
-                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, categoryOptionCombo, period.getStartDate(), period.getEndDate(), unit );                                    
-                    value = ( aggregatedValue != null ) ? String.valueOf( MathUtils.getRounded( aggregatedValue, 0 ) ) : null;                                                       
+                {
+                    Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? 
+                        aggregationService.getAggregatedDataValue( dataElement, categoryOptionCombo, period.getStartDate(), period.getEndDate(), unit ) :
+                            aggregatedDataValueService.getAggregatedValue( dataElement, categoryOptionCombo, period, unit );
+                                        
+                    value = ( aggregatedValue != null ) ? String.valueOf( MathUtils.getRounded( aggregatedValue, 0 ) ) : null;
                 }                 
                 
                 if ( value != null )

=== 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	2010-12-27 00:21:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-01-07 11:37:47 +0000
@@ -98,8 +98,6 @@
   
   <bean id="org.hisp.dhis.chart.ChartService"
     class="org.hisp.dhis.chart.impl.DefaultChartService">
-	<property name="aggregationService"
-	  ref="org.hisp.dhis.aggregation.AggregationService"/>
     <property name="chartStore"
       ref="org.hisp.dhis.chart.ChartStore"/>
 	<property name="periodService"
@@ -108,6 +106,12 @@
 	  ref="org.hisp.dhis.datavalue.DataValueService"/>
 	<property name="minMaxDataElementService"
 	  ref="org.hisp.dhis.minmax.MinMaxDataElementService"/>
+	<property name="aggregationService"
+	  ref="org.hisp.dhis.aggregation.AggregationService"/>
+	<property name="systemSettingManager"
+	  ref="org.hisp.dhis.options.SystemSettingManager"/>
+	<property name="aggregatedDataValueService"
+	  ref="org.hisp.dhis.aggregation.AggregatedDataValueService"/>
   </bean>
   
   <!-- Document -->
@@ -208,6 +212,10 @@
 	class="org.hisp.dhis.datasetreport.impl.DefaultDataSetReportService">
 	<property name="dataValueService"
 	  ref="org.hisp.dhis.datavalue.DataValueService"/>
+	<property name="systemSettingManager"
+	  ref="org.hisp.dhis.options.SystemSettingManager"/>
+	<property name="aggregatedDataValueService"
+	  ref="org.hisp.dhis.aggregation.AggregatedDataValueService"/>
 	<property name="aggregationService"
 	  ref="org.hisp.dhis.aggregation.AggregationService"/>
   </bean>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2011-01-07 11:37:47 +0000
@@ -27,7 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_FACTOR_OF_DEVIATION;
+import static org.hisp.dhis.options.SystemSettingManager.*;
 import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_MAX_NUMBER_OF_ATTEMPTS;
 import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_TIMEFRAME_MINUTES;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_APPLICATION_TITLE;
@@ -95,6 +95,7 @@
         map.put( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false ) );
         map.put( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, systemSettingManager.getSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, false ) );
         map.put( KEY_FACTOR_OF_DEVIATION, systemSettingManager.getSystemSetting( KEY_FACTOR_OF_DEVIATION, DEFAULT_FACTOR_OF_DEVIATION ) );
+        map.put( KEY_AGGREGATION_STRATEGY, systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY ) );
         
         invocation.getStack().push( map );
         

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/screen/DefaultDataEntryScreenManager.java	2011-01-07 11:37:47 +0000
@@ -221,7 +221,7 @@
         // Inline Javascript to add to HTML before outputting
         // ---------------------------------------------------------------------
 
-        final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME', $SAVEMODE )\" onkeypress=\"return keyPress(event, this)\" style=\"text-align:center\" ";
+        final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME', $SAVEMODE )\" style=\"text-align:center\" ";
         final String jsCodeForCombos = " $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID, this )\">";
         final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
         final String calDataElementCode = " class=\"calculated\" disabled ";
@@ -496,7 +496,7 @@
         // Inline Javascript to add to HTML before outputting
         // ---------------------------------------------------------------------
 
-        final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME', $SAVEMODE )\" onkeypress=\"return keyPress(event, this)\" style=\"text-align:center\" ";
+        final String jsCodeForInputs = " $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME', $SAVEMODE )\" style=\"text-align:center\" ";
         final String jsCodeForCombos = " $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID, this )\">";
         final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
         final String calDataElementCode = " class=\"calculated\" disabled ";

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java	2010-10-29 14:32:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java	2011-01-07 11:37:47 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
 import java.util.List;
 import java.util.SortedMap;
 
@@ -106,6 +107,13 @@
         return currentStyle;
     }
     
+    private Collection<String> aggregationStrategies;
+
+    public Collection<String> getAggregationStrategies()
+    {
+        return aggregationStrategies;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -122,6 +130,8 @@
         
         currentStyle = styleManager.getCurrentStyle();
         
+        aggregationStrategies = systemSettingManager.getAggregationStrategies();
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java	2011-01-07 11:37:47 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_APPLICATION_TITLE;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_FACTOR_OF_DEVIATION;
@@ -72,6 +73,7 @@
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
+    
     private String applicationTitle;
 
     public void setApplicationTitle( String applicationTitle )
@@ -149,6 +151,13 @@
         this.currentStyle = style;
     }
     
+    private String aggregationStrategy;
+
+    public void setAggregationStrategy( String aggregationStrategy )
+    {
+        this.aggregationStrategy = aggregationStrategy;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -178,6 +187,7 @@
         systemSettingManager.saveSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, disableDataEntryWhenCompleted );
         systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
         styleManager.setCurrentStyle( currentStyle );
+        systemSettingManager.saveSystemSetting( KEY_AGGREGATION_STRATEGY, aggregationStrategy );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2010-11-28 19:45:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2011-01-07 11:37:47 +0000
@@ -99,3 +99,6 @@
 lockout_timeframe = Lockout minutes after max number of login attempts
 data_analysis_factor = Data analysis std dev factor
 auto_save_data_entry_form = Auto-save data entry form
+aggregation_strategy = Aggregation strategy
+real_time = Real-time
+batch = Batch

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-01-07 11:37:47 +0000
@@ -7,12 +7,22 @@
 
 <p><input type="text" name="applicationTitle" style="width:30em" maxlength="40" value="$!applicationTitle"/></p>
 
+<h4>$i18n.getString( "aggregation_strategy" )</h4>
+
+<p>
+<select name="aggregationStrategy" style="width:30em">
+	#foreach( $strategy in $aggregationStrategies )
+	<option value="$strategy" #if( $aggregationStrategy == $strategy )selected="selected"#end>$i18n.getString( $strategy )</option>
+	#end
+</select>
+</p>
+
 <h4>$i18n.getString( "style" )</h4>
 
 <select style="min-width:250px" name='currentStyle' id='currentStyle'>
-#foreach( $style in $styles.entrySet() )
+	#foreach( $style in $styles.entrySet() )
 	<option value="$style.value" #if( $style.value == $currentStyle )selected="selected"#end>$i18n.getString( $style.key )</option>
-#end
+	#end
 </select>
 
 <h4>$i18n.getString( "max_attempts" )</h4>
@@ -29,7 +39,7 @@
 <select name="flag" style="width:30em">
 	<option value="NO_FLAG">$i18n.getString( "no_flag" )</option>
 	#foreach ( $f in $flags.entrySet() )
-		<option value="$f.value" #if( $f.value == $flag )selected="selected"#end>$i18n.getString( $f.key )</option>
+	<option value="$f.value" #if( $f.value == $flag )selected="selected"#end>$i18n.getString( $f.key )</option>
     #end
 </select>
 </p>
@@ -40,7 +50,7 @@
 <select name="startModule" style="width:30em">
     <option value="NO_START_PAGE">$i18n.getString( "no_start_page" )</option>
 	#foreach ( $module in $modules )
-		<option value="$module.name" #if ( $module.name == $startModule )selected="selected"#end>$i18n.getString( "$module.name" )</option>
+	<option value="$module.name" #if( $module.name == $startModule )selected="selected"#end>$i18n.getString( "$module.name" )</option>
 	#end
 </select>
 </p>
@@ -49,8 +59,8 @@
 
 <p>
 <select name="reportFramework" style="width:30em">
-    <option value="birt"#if ( "birt" == $reportFramework )selected#end>$i18n.getString( "birt" )</option>
-    <option value="jasper"#if ( "jasper" == $reportFramework )selected#end>$i18n.getString( "jasper" )</option>
+    <option value="birt" #if( "birt" == $reportFramework )selected="selected"#end>$i18n.getString( "birt" )</option>
+    <option value="jasper" #if( "jasper" == $reportFramework )selected="selected"#end>$i18n.getString( "jasper" )</option>
 </select>
 </p>
 

=== 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-01-06 12:40:57 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-01-07 11:37:47 +0000
@@ -9,6 +9,7 @@
 	
 	<!-- Data source -->
 	
+	#if ( $aggregationStrategy == "realTime" )
     <tr>
         <th>$i18n.getString( "method" )</th>
     </tr>
@@ -23,7 +24,8 @@
     <tr>
         <td colspan="4" style="height:10px"></td>
     </tr>
-	
+    #end
+    	
     <!-- Reporting month -->
     
     #if ( $!reportParams.isParamReportingMonth() )