dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10301
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2834: Fixed bug 'Validation analysis result can be too long'
------------------------------------------------------------
revno: 2834
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-02-11 00:09:13 +0100
message:
Fixed bug 'Validation analysis result can be too long'
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java
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/dataanalysis/GapAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.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/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.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/responseValidationRule.vm
dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm
dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.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/dataanalysis/DataAnalysisService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 2010-04-12 03:47:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 2011-02-10 23:09:13 +0000
@@ -43,6 +43,8 @@
{
String ID = DataAnalysisService.class.getName();
+ int MAX_OUTLIERS = 500;
+
Collection<DeflatedDataValue> analyse( OrganisationUnit organisationUnit, Collection<DataElement> dataElements,
Collection<Period> periods, Double stdDevFactor );
}
=== 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-12-04 00:17:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java 2011-02-10 23:09:13 +0000
@@ -45,6 +45,8 @@
{
String ID = ValidationRuleService.class.getName();
+ int MAX_VIOLATIONS = 500;
+
// -------------------------------------------------------------------------
// ValidationRule business logic
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java 2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/GapAnalysisService.java 2011-02-10 23:09:13 +0000
@@ -72,7 +72,7 @@
Collection<DeflatedDataValue> gapCollection = new ArrayList<DeflatedDataValue>();
- for ( DataElement dataElement : dataElements )
+ loop : for ( DataElement dataElement : dataElements )
{
// TODO filter periods with data element period type
@@ -84,7 +84,12 @@
{
for ( OrganisationUnit unit : units )
{
- gapCollection.addAll( dataAnalysisStore.getDeflatedDataValueGaps( dataElement, categoryOptionCombo, periods, unit ) );
+ gapCollection.addAll( dataAnalysisStore.getDeflatedDataValueGaps( dataElement, categoryOptionCombo, periods, unit ) );
+
+ if ( gapCollection.size() > MAX_OUTLIERS )
+ {
+ break loop;
+ }
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java 2009-12-24 14:47:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java 2011-02-10 23:09:13 +0000
@@ -82,7 +82,7 @@
Collection<DeflatedDataValue> outlierCollection = new ArrayList<DeflatedDataValue>();
- for ( OrganisationUnit unit : units )
+ loop : for ( OrganisationUnit unit : units )
{
MinMaxValueMap map = getMinMaxValueMap( minMaxDataElementService.getMinMaxDataElements( unit, dataElements ) );
@@ -95,6 +95,11 @@
for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos )
{
outlierCollection.addAll( findOutliers( unit, dataElement, categoryOptionCombo, periods, map ) );
+
+ if ( outlierCollection.size() > MAX_OUTLIERS )
+ {
+ break loop;
+ }
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2011-02-10 23:09:13 +0000
@@ -76,7 +76,7 @@
Collection<DeflatedDataValue> outlierCollection = new ArrayList<DeflatedDataValue>();
- for ( DataElement dataElement : dataElements )
+ loop : for ( DataElement dataElement : dataElements )
{
// TODO filter periods with data element period type
@@ -91,6 +91,11 @@
{
outlierCollection.addAll( findOutliers( unit, dataElement, categoryOptionCombo, periods,
stdDevFactor ) );
+
+ if ( outlierCollection.size() > MAX_OUTLIERS )
+ {
+ break loop;
+ }
}
}
}
=== 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 2011-01-26 10:01:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2011-02-10 23:09:13 +0000
@@ -62,7 +62,7 @@
implements ValidationRuleService
{
private static final int DECIMALS = 1;
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -162,7 +162,7 @@
{
for ( Period period : periods )
{
- validationViolations.addAll( validateInternal( period, source, validationRules, true ) );
+ validationViolations.addAll( validateInternal( period, source, validationRules, true, validationViolations.size() ) );
}
}
@@ -187,7 +187,7 @@
{
for ( Period period : periods )
{
- validationViolations.addAll( validateInternal( period, source, validationRules, true ) );
+ validationViolations.addAll( validateInternal( period, source, validationRules, true, validationViolations.size() ) );
}
}
@@ -208,7 +208,7 @@
{
for ( Period period : relevantPeriods )
{
- validationViolations.addAll( validateInternal( period, source, relevantRules, false ) );
+ validationViolations.addAll( validateInternal( period, source, relevantRules, false, validationViolations.size() ) );
}
}
}
@@ -232,7 +232,7 @@
{
for ( Period period : relevantPeriods )
{
- validationViolations.addAll( validateInternal( period, source, relevantRules, false ) );
+ validationViolations.addAll( validateInternal( period, source, relevantRules, false, validationViolations.size() ) );
}
}
}
@@ -250,7 +250,7 @@
for ( Period period : relevantPeriods )
{
- validationViolations.addAll( validateInternal( period, source, relevantRules, false ) );
+ validationViolations.addAll( validateInternal( period, source, relevantRules, false, validationViolations.size() ) );
}
return validationViolations;
@@ -258,7 +258,7 @@
public Collection<ValidationResult> validate( DataSet dataSet, Period period, Source source )
{
- return validateInternal( period, source, getRelevantValidationRules( dataSet.getDataElements() ), false );
+ return validateInternal( period, source, getRelevantValidationRules( dataSet.getDataElements() ), false, 0 );
}
public Collection<DataElement> getDataElementsInValidationRules()
@@ -287,35 +287,38 @@
* @returns a collection of rules that did not pass validation.
*/
private Collection<ValidationResult> validateInternal( final Period period, final Source source,
- final Collection<ValidationRule> validationRules, boolean aggregate )
+ final Collection<ValidationRule> validationRules, boolean aggregate, int currentSize )
{
- final Collection<ValidationResult> validationResults = new HashSet<ValidationResult>();
-
- Double leftSide = null;
- Double rightSide = null;
-
- boolean violation = false;
-
- for ( final ValidationRule validationRule : validationRules )
- {
- if ( validationRule.getPeriodType() != null && validationRule.getPeriodType().equals( period.getPeriodType() ) )
+ final Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();
+
+ if ( currentSize < MAX_VIOLATIONS )
+ {
+ Double leftSide = null;
+ Double rightSide = null;
+
+ boolean violation = false;
+
+ for ( final ValidationRule validationRule : validationRules )
{
- leftSide = expressionService.getExpressionValue( validationRule.getLeftSide(), period, source, true, aggregate );
- rightSide = expressionService.getExpressionValue( validationRule.getRightSide(), period, source, true, aggregate );
-
- if ( leftSide != null && rightSide != null )
+ if ( validationRule.getPeriodType() != null && validationRule.getPeriodType().equals( period.getPeriodType() ) )
{
- violation = !expressionIsTrue( leftSide, validationRule.getOperator(), rightSide );
-
- if ( violation )
+ leftSide = expressionService.getExpressionValue( validationRule.getLeftSide(), period, source, true, aggregate );
+ rightSide = expressionService.getExpressionValue( validationRule.getRightSide(), period, source, true, aggregate );
+
+ if ( leftSide != null && rightSide != null )
{
- validationResults.add( new ValidationResult( period, source, validationRule, getRounded( leftSide, DECIMALS ), getRounded( rightSide, DECIMALS ) ) );
+ violation = !expressionIsTrue( leftSide, validationRule.getOperator(), rightSide );
+
+ if ( violation )
+ {
+ validationViolations.add( new ValidationResult( period, source, validationRule, getRounded( leftSide, DECIMALS ), getRounded( rightSide, DECIMALS ) ) );
+ }
}
}
}
}
- return validationResults;
+ return validationViolations;
}
/**
=== 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-09-06 04:37:19 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2011-02-10 23:09:13 +0000
@@ -108,6 +108,13 @@
// Input/output
// -------------------------------------------------------------------------
+ private boolean doDataMart;
+
+ public void setDoDataMart( boolean doDataMart )
+ {
+ this.doDataMart = doDataMart;
+ }
+
private Integer organisationUnitId;
public void setOrganisationUnitId( Integer organisationUnitId )
@@ -146,7 +153,7 @@
this.validationRuleGroupId = validationRuleGroupId;
}
- private List<ValidationResult> validationResults;
+ private List<ValidationResult> validationResults = new ArrayList<ValidationResult>();
public List<ValidationResult> getValidationResults()
{
@@ -171,12 +178,12 @@
{
this.aggregate = aggregate;
}
-
- private boolean doDataMart;
-
- public void setDoDataMart( boolean doDataMart )
+
+ private boolean maxExceeded;
+
+ public boolean isMaxExceeded()
{
- this.doDataMart = doDataMart;
+ return maxExceeded;
}
// -------------------------------------------------------------------------
@@ -247,6 +254,8 @@
}
}
+ maxExceeded = validationResults.size() > ValidationRuleService.MAX_VIOLATIONS;
+
Collections.sort( validationResults, new ValidationResultComparator() );
SessionUtils.setSessionVar( KEY_VALIDATIONRESULT, validationResults );
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java 2010-09-17 06:52:36 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java 2011-02-10 23:09:13 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -152,13 +153,20 @@
// Output
// -------------------------------------------------------------------------
- private Collection<DeflatedDataValue> dataValues;
+ private Collection<DeflatedDataValue> dataValues = new ArrayList<DeflatedDataValue>();
public Collection<DeflatedDataValue> getDataValues()
{
return dataValues;
}
+ private boolean maxExceeded;
+
+ public boolean isMaxExceeded()
+ {
+ return maxExceeded;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -189,6 +197,8 @@
if ( service != null ) // Follow-up analysis has no input params
{
dataValues = service.analyse( unit, dataElements, periods, standardDeviation );
+
+ maxExceeded = dataValues.size() > DataAnalysisService.MAX_OUTLIERS;
}
return SUCCESS;
=== 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 2011-01-25 19:26:03 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2011-02-10 23:09:13 +0000
@@ -145,4 +145,5 @@
specify_organisationunit_has_children = Please specify an organisationunit which has children.
get_report_as_xls = Download as Excel
get_report_as_csv = Download as CSV
-get_report_as_pdf = Download as PDF
\ No newline at end of file
+get_report_as_pdf = Download as PDF
+max_values_exceeded = More than 500 values found, please fix the violations or narrow the search to see all
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm 2009-09-05 09:34:43 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/responseValidationRule.vm 2011-02-10 23:09:13 +0000
@@ -3,7 +3,7 @@
<name>$!encoder.xmlEncode( $validationRule.name )</name>
<description>$!encoder.xmlEncode( $validationRule.description )</description>
<type>$!encoder.xmlEncode( $validationRule.type )</type>
- <operator>$!encoder.xmlEncode( $validationRule.operator )</operator>
+ <operator>$!encoder.xmlEncode( $validationRule.operator.mathematicalOperator )</operator>
<leftSideDescription>$!encoder.xmlEncode( $validationRule.leftSide.description )</leftSideDescription>
<rightSideDescription>$!encoder.xmlEncode( $validationRule.rightSide.description )</rightSideDescription>
</validationRule>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm 2011-01-14 19:33:18 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm 2011-02-10 23:09:13 +0000
@@ -7,7 +7,7 @@
#else
-<span id="info">$!dataValues.size() $i18n.getString( "values_found" )</span>
+<span id="info">#if( $maxExceeded )$i18n.getString( "max_values_exceeded" ) #else$!dataValues.size() $i18n.getString( "values_found" ) #end</span>
<input type="button" onclick="window.location.href='viewAnalysisForm.action?key=$!{key}'" value="Back" style="width:120px"><br><br>
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm 2010-12-29 21:08:09 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm 2011-02-10 23:09:13 +0000
@@ -27,9 +27,18 @@
<td colspan="5" height="15"></td>
</tr>
</table>
-#if ( $validationResults.size() == 0 )
- <span id="info">$i18n.getString( "validation_passed_successfully" )</span>
+
+<span id="info">
+#if( $validationResults.size() == 0 )
+ $i18n.getString( "validation_passed_successfully" )
+#elseif( $maxExceeded )
+ $i18n.getString( "max_values_exceeded" )
#else
+ $validationResults.size() $i18n.getString( "values_found" )
+#end
+</span>
+
+#if( $validationResults.size() > 0 )
<div id="validationResults">