dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21247
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9999: DataEntry - Validated for multi-entry-org-unit
------------------------------------------------------------
revno: 9999
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-03-06 10:56:21 +0700
message:
DataEntry - Validated for multi-entry-org-unit
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
--
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-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2012-07-25 13:18:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2013-03-06 03:56:21 +0000
@@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -38,6 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataanalysis.DataAnalysisService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -134,6 +136,18 @@
this.organisationUnitId = organisationUnitId;
}
+ private boolean multiOrganisationUnit;
+
+ public void setMultiOrganisationUnit( boolean multiOrganisationUnit )
+ {
+ this.multiOrganisationUnit = multiOrganisationUnit;
+ }
+
+ public boolean isMultiOrganisationUnit()
+ {
+ return multiOrganisationUnit;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -188,9 +202,15 @@
// Min-max and outlier analysis
// ---------------------------------------------------------------------
- dataValues = minMaxOutlierAnalysisService.analyse( getCollection( orgUnit ), dataSet.getDataElements(), getCollection( period ), null );
-
+ dataValues = minMaxOutlierAnalysisService.analyse( getCollection( orgUnit ), dataSet.getDataElements(),
+ getCollection( period ), null );
+
log.debug( "Number of outlier values: " + dataValues.size() );
+
+ if ( dataValues.size() > 0 )
+ {
+ return INPUT;
+ }
// ---------------------------------------------------------------------
// Validation rule analysis
@@ -209,11 +229,73 @@
{
ValidationRule rule = result.getValidationRule();
- leftsideFormulaMap.put( rule.getId(),
- expressionService.getExpressionDescription( rule.getLeftSide().getExpression() ) );
-
- rightsideFormulaMap.put( rule.getId(),
- expressionService.getExpressionDescription( rule.getRightSide().getExpression() ) );
+ leftsideFormulaMap.put( rule.getId(), expressionService.getExpressionDescription( rule
+ .getLeftSide().getExpression() ) );
+
+ rightsideFormulaMap.put( rule.getId(), expressionService.getExpressionDescription( rule
+ .getRightSide().getExpression() ) );
+ }
+
+ return INPUT;
+ }
+ }
+
+ if ( multiOrganisationUnit && selectedPeriod != null )
+ {
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
+
+ Collections.sort( children, IdentifiableObjectNameComparator.INSTANCE );
+
+ for ( OrganisationUnit child : children )
+ {
+ if ( child != null )
+ {
+ Period period = periodService.getPeriod( selectedPeriod.getStartDate(),
+ selectedPeriod.getEndDate(), selectedPeriod.getPeriodType() );
+
+ DataSet dataSet = dataSetService.getDataSet( dataSetId );
+
+ // ---------------------------------------------------------------------
+ // Min-max and outlier analysis
+ // ---------------------------------------------------------------------
+
+ dataValues = minMaxOutlierAnalysisService.analyse( getCollection( orgUnit ), dataSet
+ .getDataElements(), getCollection( period ), null );
+
+ log.debug( "Number of outlier values: " + dataValues.size() );
+
+ if ( dataValues.size() > 0 )
+ {
+ return INPUT;
+ }
+
+ // ---------------------------------------------------------------------
+ // Validation rule analysis
+ // ---------------------------------------------------------------------
+
+ results = new ArrayList<ValidationResult>( validationRuleService
+ .validate( dataSet, period, orgUnit ) );
+
+ log.debug( "Number of validation violations: " + results.size() );
+
+ if ( results.size() > 0 )
+ {
+ leftsideFormulaMap = new HashMap<Integer, String>( results.size() );
+ rightsideFormulaMap = new HashMap<Integer, String>( results.size() );
+
+ for ( ValidationResult result : results )
+ {
+ ValidationRule rule = result.getValidationRule();
+
+ leftsideFormulaMap.put( rule.getId(), expressionService.getExpressionDescription( rule
+ .getLeftSide().getExpression() ) );
+
+ rightsideFormulaMap.put( rule.getId(), expressionService.getExpressionDescription( rule
+ .getRightSide().getExpression() ) );
+ }
+
+ return INPUT;
+ }
}
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-02-05 15:10:14 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-03-06 03:56:21 +0000
@@ -1463,6 +1463,8 @@
var validCompleteOnly = dataSets[currentDataSetId].validCompleteOnly;
var params = storageManager.getCurrentCompleteDataSetParams();
+ params['organisationUnitId'] = selection.getSelected();
+ params['multiOrganisationUnit'] = multiOrganisationUnit;
$( '#validationDiv' ).load( 'validate.action', params,
function( response, status, xhr )