← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2024: Implemented aggregated validation rule analysis

 

------------------------------------------------------------
revno: 2024
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Tue 2010-08-31 13:40:23 +0200
message:
  Implemented aggregated validation rule analysis
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.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/validation/ValidationRuleService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java	2010-08-30 13:04:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java	2010-08-31 11:40:23 +0000
@@ -47,12 +47,18 @@
     // ValidationRule business logic
     // -------------------------------------------------------------------------
 
+    Collection<ValidationResult> validateAggregate( Date startDate, Date endDate, Collection<? extends Source> sources );
+    
+    public Collection<ValidationResult> validateAggregate( Date startDate, Date endDate, Collection<? extends Source> sources, ValidationRuleGroup group );
+    
     /**
      * Validate DataValues.
      * 
      * @param startDate the start date.
      * @param endDate the end date.
      * @param sources a collection of Sources.
+     * @param aggregate indicates whether aggregated or raw data should be used
+     *        to evaluate the validation expression.
      * @return a collection of ValidationResults for each validation violation. 
      */
     Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<? extends Source> sources );
@@ -64,6 +70,8 @@
      * @param endDate the end date.
      * @param sources a collection of Sources.
      * @param group a group of ValidationRules.
+     * @param aggregate indicates whether aggregated or raw data should be used
+     *        to evaluate the validation expression.
      * @return a collection of ValidationResults for each validation violation. 
      */
     Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<? extends Source> sources, ValidationRuleGroup group );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2010-08-31 08:14:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2010-08-31 11:40:23 +0000
@@ -35,10 +35,11 @@
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -87,19 +88,77 @@
     {
         this.periodService = periodService;
     }
+    
+    private DataSetService dataSetService;
+    
+    public void setDataSetService( DataSetService dataSetService )
+    {
+        this.dataSetService = dataSetService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
 
     // -------------------------------------------------------------------------
     // ValidationRule business logic
     // -------------------------------------------------------------------------
-
+    
+    public Collection<ValidationResult> validateAggregate( Date startDate, Date endDate, Collection<? extends Source> sources )
+    {
+        Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
+        
+        Collection<ValidationRule> validationRules = getAllValidationRules();
+
+        Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();
+        
+        for ( Source source : sources  )
+        {
+            for ( Period period : periods )
+            {
+                validationViolations.addAll( validate( period, source, validationRules, true ) );
+            }
+        }
+        
+        return validationViolations;
+    }
+
+    public Collection<ValidationResult> validateAggregate( Date startDate, Date endDate, Collection<? extends Source> sources, ValidationRuleGroup group )
+    {
+        Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
+        
+        Collection<DataSet> dataSets = dataSetService.getDataSetsBySources( sources );
+        
+        Collection<DataElement> dataElements = dataElementService.getDataElementsByDataSets( dataSets );
+        
+        Collection<ValidationRule> validationRules = getValidationRulesByDataElements( dataElements );
+
+        validationRules.retainAll( group.getMembers() );
+        
+        Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();
+
+        for ( Source source : sources  )
+        {
+            for ( Period period : periods )
+            {
+                validationViolations.addAll( validate( period, source, validationRules, true ) );
+            }
+        }
+        
+        return validationViolations;
+    }
+    
     public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<? extends Source> sources )
     {
         Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();
 
+        Map<DataSet, Collection<ValidationRule>> relevantValidationRulesMap = getRelevantValidationRulesMap( sources );
+                
         Collection<Period> relevantPeriods = periodService.getPeriodsBetweenDates( startDate, endDate );
 
-        Map<DataSet, Collection<ValidationRule>> relevantValidationRulesMap = getRelevantValidationRulesMap( sources );
-                
         for ( Source source : sources )
         {
             for ( DataSet dataSet : source.getDataSets() )
@@ -112,7 +171,7 @@
                     {
                         if ( dataSet.getPeriodType().equals( period.getPeriodType() ) )
                         {
-                            validationViolations.addAll( validate( period, source, relevantRules ) );
+                            validationViolations.addAll( validate( period, source, relevantRules, false ) );
                         }
                     }
                 }
@@ -122,7 +181,6 @@
         return validationViolations;
     }
 
-    @SuppressWarnings( "unchecked" )
     public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<? extends Source> sources,
         ValidationRuleGroup group )
     {
@@ -136,7 +194,8 @@
         {
             for ( DataSet dataSet : source.getDataSets() )
             {
-                Collection<ValidationRule> relevantRules = CollectionUtils.intersection( relevantValidationRulesMap.get( dataSet ), group.getMembers() );
+                Collection<ValidationRule> relevantRules = relevantValidationRulesMap.get( dataSet );
+                relevantRules.retainAll( group.getMembers() );
                 
                 if ( relevantRules != null && relevantRules.size() > 0 )
                 {
@@ -144,7 +203,7 @@
                     {
                         if ( dataSet.getPeriodType().equals( period.getPeriodType() ) )
                         {
-                            validationViolations.addAll( validate( period, source, relevantRules ) );
+                            validationViolations.addAll( validate( period, source, relevantRules, false ) );
                         }
                     }
                 }
@@ -164,7 +223,7 @@
 
         for ( DataSet dataSet : source.getDataSets() )
         {
-            Collection<ValidationRule> relevantRules = relevantValidationRulesMap.get( dataSet );
+            Collection<ValidationRule> relevantRules = relevantValidationRulesMap.get( dataSet ); //TODO incorrect, fix
             
             if ( relevantRules != null && relevantRules.size() > 0 )
             {
@@ -172,7 +231,7 @@
                 {
                     if ( dataSet.getPeriodType().equals( period.getPeriodType() ) )
                     {
-                        validationViolations.addAll( validate( period, source, relevantRules ) );
+                        validationViolations.addAll( validate( period, source, relevantRules, false ) );
                     }
                 }
             }
@@ -183,7 +242,7 @@
 
     public Collection<ValidationResult> validate( DataSet dataSet, Period period, Source source )
     {
-        return validate( period, source, getRelevantValidationRules( dataSet ) );
+        return validate( period, source, getRelevantValidationRules( dataSet ), false );
     }
 
     // -------------------------------------------------------------------------
@@ -199,7 +258,7 @@
      * @returns a collection of rules that did not pass validation.
      */
     private Collection<ValidationResult> validate( final Period period, final Source source,
-        final Collection<ValidationRule> validationRules )
+        final Collection<ValidationRule> validationRules, boolean aggregate )
     {
         final Collection<ValidationResult> validationResults = new HashSet<ValidationResult>();
 
@@ -210,8 +269,8 @@
 
         for ( final ValidationRule validationRule : validationRules )
         {
-            leftSide = expressionService.getExpressionValue( validationRule.getLeftSide(), period, source, true, false );
-            rightSide = expressionService.getExpressionValue( validationRule.getRightSide(), period, source, true, false );
+            leftSide = expressionService.getExpressionValue( validationRule.getLeftSide(), period, source, true, aggregate );
+            rightSide = expressionService.getExpressionValue( validationRule.getRightSide(), period, source, true, aggregate );
 
             if ( leftSide != null && rightSide != null )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-08-31 05:47:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-08-31 11:40:23 +0000
@@ -265,8 +265,8 @@
 		<property name="expressionStore" ref="org.hisp.dhis.expression.ExpressionStore" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
-		<property name="categoryService"
-			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+		<property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService"/>
+		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.validation.ValidationRuleService" class="org.hisp.dhis.validation.DefaultValidationRuleService">
@@ -275,6 +275,8 @@
 			ref="org.hisp.dhis.validation.ValidationRuleGroupStore" />
 		<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService"/>
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementCategoryService"
@@ -1477,7 +1479,7 @@
 
 		<aop:aspect ref="statementInterceptor">
 			<aop:around
-				pointcut="execution( * org.hisp.dhis.validation.ValidationRuleService.validate(..) )"
+				pointcut="execution( * org.hisp.dhis.validation.ValidationRuleService.validate*(..) )"
 				method="intercept" />
 			<aop:around
 				pointcut="execution( * org.hisp.dhis.dataanalysis.DataAnalysisService.analyse(..) )"

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java	2010-08-05 17:12:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java	2010-08-31 11:40:23 +0000
@@ -164,6 +164,11 @@
     {
         return reloadOrganisationUnits( getSelectedOrganisationUnits() );
     }
+    
+    public OrganisationUnit getReloadedSelectedOrganisationUnit()
+    {
+        return reloadOrganisationUnit( getSelectedOrganisationUnit() );
+    }
 
     public void clearSelectedOrganisationUnits()
     {

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java	2010-08-05 17:12:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java	2010-08-31 11:40:23 +0000
@@ -98,8 +98,7 @@
 
     /**
      * Returns the selected OrganisationUnits. The returned OrganisationUnits
-     * are always in the subtree of the selected root. The OrganisationUnits are
-     * fetched within the current transaction.
+     * are always in the subtree of the selected root. 
      * 
      * @return the selected OrganisationUnits or an empty collection if no unit
      *         is selected
@@ -107,20 +106,40 @@
     Collection<OrganisationUnit> getSelectedOrganisationUnits();
     
     /**
+     * Convenience method for getting one selected OrganisationUnit. If multiple
+     * OrganisationUnits are selected, this method returns one of them.
+     * 
+     * @return a selected OrganisationUnit or null if no OrganisationUnit is
+     *         selected
+     */
+    OrganisationUnit getSelectedOrganisationUnit();
+
+    /**
+     * Returns the selected OrganisationUnits. The returned OrganisationUnits
+     * are always in the subtree of the selected root. The OrganisationUnits
+     * are associated with the current session.
+     * 
+     * @return the selected OrganisationUnits or an empty collection if no unit
+     *         is selected
+     */
+    Collection<OrganisationUnit> getReloadedSelectedOrganisationUnits();
+
+    /**
+     * Convenience method for getting one selected OrganisationUnit. If multiple
+     * OrganisationUnits are selected, this method returns one of them. The 
+     * OrganisationUnits are associated with the current session.
+     * 
+     * @return a selected OrganisationUnit or null if no OrganisationUnit is
+     *         selected
+     */
+    OrganisationUnit getReloadedSelectedOrganisationUnit();
+    
+    /**
      * Clears the selection and makes getSelectedOrganisationUnit() return null.
      */
     void clearSelectedOrganisationUnits();
 
     /**
-     * Convenience method for getting one selected OrganisationUnit. If multiple
-     * OrganisationUnits are selected, this method returns one of them.
-     * 
-     * @return a selected OrganisationUnit or null if no OrganisationUnit is
-     *         selected
-     */
-    OrganisationUnit getSelectedOrganisationUnit();
-
-    /**
      * Convenience method for setting one selected OrganisationUnit.
      * 
      * @param unit
@@ -129,6 +148,4 @@
      *             if the argument is null
      */
     void setSelectedOrganisationUnit( OrganisationUnit unit );
-    
-    Collection<OrganisationUnit> getReloadedSelectedOrganisationUnits();
 }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-08-30 06:24:45 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-08-31 11:40:23 +0000
@@ -30,7 +30,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -39,7 +38,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.source.Source;
 import org.hisp.dhis.util.SessionUtils;
 import org.hisp.dhis.validation.ValidationResult;
 import org.hisp.dhis.validation.ValidationRuleGroup;
@@ -133,6 +131,13 @@
     {
         return validationResults;
     }
+    
+    private boolean aggregate;
+
+    public void setAggregate( boolean aggregate )
+    {
+        this.aggregate = aggregate;
+    }
 
     // -------------------------------------------------------------------------
     // Execute
@@ -140,32 +145,49 @@
 
     public String execute()
     {
-        Collection<? extends Source> sources = selectionTreeManager.getReloadedSelectedOrganisationUnits();
-
-        Collection<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
-
-        for ( Source source : sources )
-        {
-            organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( source.getId() ) );
-        }
-
-        sources = organisationUnits;
-
-        if ( validationRuleGroupId == -1 )
-        {
-            log.info( "Validating all rules" );
-
-            validationResults = new ArrayList<ValidationResult>( validationRuleService.validate( format
-                .parseDate( startDate ), format.parseDate( endDate ), sources ) );
-        }
-        else
-        {
-            ValidationRuleGroup group = validationRuleService.getValidationRuleGroup( validationRuleGroupId );
-
-            log.info( "Validating rules for group: '" + group.getName() + "'" );
-
-            validationResults = new ArrayList<ValidationResult>( validationRuleService.validate( format
-                .parseDate( startDate ), format.parseDate( endDate ), sources, group ) );
+        OrganisationUnit unit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
+
+        if ( aggregate ) // Aggregate data source
+        {
+            Collection<OrganisationUnit> organisationUnits = unit.getChildren();
+            
+            if ( validationRuleGroupId == -1 )
+            {
+                log.info( "Validating aggregate data for all rules" );
+
+                validationResults = new ArrayList<ValidationResult>( validationRuleService.validateAggregate( format
+                    .parseDate( startDate ), format.parseDate( endDate ), organisationUnits ) );
+            }
+            else
+            {
+                ValidationRuleGroup group = validationRuleService.getValidationRuleGroup( validationRuleGroupId );
+
+                log.info( "Validating aggregate data for rules for group: '" + group.getName() + "'" );
+
+                validationResults = new ArrayList<ValidationResult>( validationRuleService.validateAggregate( format
+                    .parseDate( startDate ), format.parseDate( endDate ), organisationUnits, group ) );
+            }
+        }
+        else // Captured data source
+        {
+            Collection<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitWithChildren( unit.getId() );
+
+            if ( validationRuleGroupId == -1 )
+            {
+                log.info( "Validating captured data for all rules" );
+    
+                validationResults = new ArrayList<ValidationResult>( validationRuleService.validate( format
+                    .parseDate( startDate ), format.parseDate( endDate ), organisationUnits ) );
+            }
+            else
+            {
+                ValidationRuleGroup group = validationRuleService.getValidationRuleGroup( validationRuleGroupId );
+    
+                log.info( "Validating captured data for rules for group: '" + group.getName() + "'" );
+    
+                validationResults = new ArrayList<ValidationResult>( validationRuleService.validate( format
+                    .parseDate( startDate ), format.parseDate( endDate ), organisationUnits, group ) );
+            }
         }
 
         Collections.sort( validationResults, new ValidationResultComparator() );

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2010-07-04 23:55:46 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2010-08-31 11:40:23 +0000
@@ -167,4 +167,9 @@
 periodtype = Periodtype
 available_data_sets = Available data sets
 selected_data_sets = Selected data sets
-analysing_please_wait = Analysing data, please wait
\ No newline at end of file
+analysing_please_wait = Analysing data, please wait
+data_source = Data source
+use_captured_data = Use captured data
+use_aggregated_data = Use aggregated data
+aggregate_data_info = Immediate children of the selected organisation unit will be included.
+captured_data_info = All children of the selected organisation unit will be included.

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2010-08-30 06:24:45 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2010-08-31 11:40:23 +0000
@@ -21,8 +21,10 @@
     	setWaitMessage( "Analysing data, please wait..." );
     	
         var url = 'runValidationAction.action?startDate=' + getFieldValue( 'startDate' ) +
-        	'&endDate=' + getFieldValue( 'endDate' ) + '&validationRuleGroupId=' + $( "#validationRuleGroupId" ).val();
-        	        
+        	'&endDate=' + getFieldValue( 'endDate' ) + 
+        	'&validationRuleGroupId=' + $( '#validationRuleGroupId' ).val() +
+        	'&aggregate=' + getListValue( 'aggregate' );
+        	
 		$.get( url, function( data ) {
 			$( "div#analysisInput" ).hide();
 			$( "div#analysisResult" ).show();
@@ -50,3 +52,17 @@
     		 height=550, width=500, location=no, menubar=no, status=no, \
     		 toolbar=no, resizable=yes");
 }
+
+function aggregateChanged()
+{
+	var aggregate = getListValue( 'aggregate' );
+	
+	if ( aggregate == "true" )
+	{
+		$( "span#info" ).html( i18n_aggregate_data_info );
+	}
+	else
+	{		
+		$( "span#info" ).html( i18n_captured_data_info );
+	}
+}

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2010-06-30 16:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2010-08-31 11:40:23 +0000
@@ -34,7 +34,18 @@
     	</td>
     </tr>
     <tr>
-    	<td style="height:10px" colspan="2"></td>
+    	<td>
+    		<label for="aggregate">$i18n.getString( "data_source" )</label>
+	    </td>
+	    <td>
+	    	<select id="aggregate" name="aggregate" style="width:20em" onchange="aggregateChanged()">
+	    		<option value="false" selected="selected">$i18n.getString( "use_captured_data" )</option>
+	    		<option value="true">$i18n.getString( "use_aggregated_data" )</option>
+	    	</select>
+    	</td>
+    </tr>
+    <tr>
+    	<td colspan="2"><span id="info">$i18n.getString( "aggregate_data_info" )</span></td>
     </tr>
     <tr>
         <td colspan="2">
@@ -52,13 +63,16 @@
 <span id="message"></span>
 
 <script type="text/javascript">
-	selectionTreeSelection.setMultipleSelectionAllowed( true );
+	selectionTreeSelection.setMultipleSelectionAllowed( false );
 	selectionTree.clearSelectedOrganisationUnits();
 	selectionTree.buildSelectionTree();
 	
 	 jQuery(document).ready(function(){
 		datePickerInRange( 'startDate' , 'endDate' );	
 	});
+	
+	var i18n_aggregate_data_info = '$encoder.jsEscape( $i18n.getString( "aggregate_data_info" ) , "'")';
+	var i18n_captured_data_info = '$encoder.jsEscape( $i18n.getString( "captured_data_info" ) , "'")';
 </script>
 
 </div>