dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10175
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2799: Fix for nullpointer prone code
------------------------------------------------------------
revno: 2799
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-02-01 21:58:31 +0100
message:
Fix for nullpointer prone code
modified:
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.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-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java 2011-02-01 20:58:31 +0000
@@ -58,7 +58,7 @@
statementManager.initialise();
- log.info( "Initialising statement manager" );
+ log.debug( "Initialising statement manager" );
try
{
@@ -68,7 +68,7 @@
{
statementManager.destroy();
- log.info( "Destroying statement manager" );
+ log.debug( "Destroying statement manager" );
}
return object;
=== 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 2010-04-29 04:33:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java 2011-02-01 20:58:31 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -158,7 +159,7 @@
return rightsideFormulaMap;
}
- private Collection<DeflatedDataValue> dataValues;
+ private Collection<DeflatedDataValue> dataValues = new HashSet<DeflatedDataValue>();
public Collection<DeflatedDataValue> getDataValues()
{
@@ -177,63 +178,67 @@
Period selectedPeriod = selectedStateManager.getSelectedPeriod();
- Period period = periodService.getPeriod( selectedPeriod.getStartDate(), selectedPeriod.getEndDate(),
- selectedPeriod.getPeriodType() );
-
- DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
- // ---------------------------------------------------------------------
- // Min-max and outlier analysis
- // ---------------------------------------------------------------------
- Collection<MinMaxDataElement> minmaxs = minMaxDataElementService.getMinMaxDataElements( orgUnit, dataSet
- .getDataElements() );
- if ( minmaxs == null )
- {
-
- Double factor = (Double) systemSettingManager.getSystemSetting(
- SystemSettingManager.KEY_FACTOR_OF_DEVIATION, 2.0 );
-
- Collection<DeflatedDataValue> stdDevs = stdDevOutlierAnalysisService.analyse( orgUnit, dataSet
- .getDataElements(), ListUtils.getCollection( period ), factor );
-
- Collection<DeflatedDataValue> minMaxs = minMaxOutlierAnalysisService.analyse( orgUnit, dataSet
- .getDataElements(), ListUtils.getCollection( period ), null );
-
- dataValues = CollectionUtils.union( stdDevs, minMaxs );
- }
- else
- {
- dataValues = minMaxValuesGenerationService.findOutliers( orgUnit, ListUtils.getCollection( period ),
- minmaxs );
- }
-
- log.info( "Number of outlier values: " + dataValues.size() );
-
- // ---------------------------------------------------------------------
- // Validation rule analysis
- // ---------------------------------------------------------------------
-
- results = new ArrayList<ValidationResult>( validationRuleService.validate( dataSet, period, orgUnit ) );
-
- log.info( "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() ) );
- }
- }
-
+ if ( orgUnit != null && selectedPeriod != null )
+ {
+ Period period = periodService.getPeriod( selectedPeriod.getStartDate(), selectedPeriod.getEndDate(),
+ selectedPeriod.getPeriodType() );
+
+ DataSet dataSet = selectedStateManager.getSelectedDataSet();
+
+ // ---------------------------------------------------------------------
+ // Min-max and outlier analysis
+ // ---------------------------------------------------------------------
+
+ Collection<MinMaxDataElement> minmaxs = minMaxDataElementService.getMinMaxDataElements( orgUnit, dataSet.getDataElements() );
+
+ if ( minmaxs == null )
+ {
+
+ Double factor = (Double) systemSettingManager.getSystemSetting(
+ SystemSettingManager.KEY_FACTOR_OF_DEVIATION, 2.0 );
+
+ Collection<DeflatedDataValue> stdDevs = stdDevOutlierAnalysisService.analyse( orgUnit, dataSet
+ .getDataElements(), ListUtils.getCollection( period ), factor );
+
+ Collection<DeflatedDataValue> minMaxs = minMaxOutlierAnalysisService.analyse( orgUnit, dataSet
+ .getDataElements(), ListUtils.getCollection( period ), null );
+
+ dataValues = CollectionUtils.union( stdDevs, minMaxs );
+ }
+ else
+ {
+ dataValues = minMaxValuesGenerationService.findOutliers( orgUnit, ListUtils.getCollection( period ),
+ minmaxs );
+ }
+
+ log.info( "Number of outlier values: " + dataValues.size() );
+
+ // ---------------------------------------------------------------------
+ // Validation rule analysis
+ // ---------------------------------------------------------------------
+
+ results = new ArrayList<ValidationResult>( validationRuleService.validate( dataSet, period, orgUnit ) );
+
+ log.info( "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 dataValues.size() == 0 && results.size() == 0 ? NONE : SUCCESS;
}
}