=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2012-07-25 14:44:02 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2013-04-19 15:58:28 +0000 @@ -27,14 +27,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE; +import static org.hisp.dhis.system.util.ValidationUtils.dataValueIsValid; import java.util.Calendar; import java.util.Collection; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementOperand; @@ -52,8 +50,6 @@ public class DefaultDataValueService implements DataValueService { - private static final Log log = LogFactory.getLog( DefaultDataValueService.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -71,7 +67,7 @@ public void addDataValue( DataValue dataValue ) { - if ( !dataValue.isNullValue() && isSignificant( dataValue ) ) + if ( !dataValue.isNullValue() && dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ) == null ) { dataValueStore.addDataValue( dataValue ); } @@ -81,9 +77,9 @@ { if ( dataValue.isNullValue() ) { - this.deleteDataValue( dataValue ); + deleteDataValue( dataValue ); } - else if ( isSignificant( dataValue ) ) + else if ( dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ) == null ) { dataValueStore.updateDataValue( dataValue ); } @@ -176,25 +172,12 @@ return dataValueStore.getDataValues( dataElement ); } - @Override public DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType, OrganisationUnit organisationUnit ) { return dataValueStore.getLatestDataValues( dataElement, periodType, organisationUnit ); } - private boolean isSignificant( DataValue dataValue ) - { - if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant() - && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) ) - { - log.debug( "DataValue was ignored as zero values are insignificant for this data element: " - + dataValue.getDataElement() ); - return false; - } - return true; - } - public int getDataValueCount( int days ) { Calendar cal = PeriodType.createCalendarInstance(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2013-04-19 15:02:38 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2013-04-19 15:58:28 +0000 @@ -212,7 +212,8 @@ /** * Checks if the given data value is valid according to the value type of the - * given data element. Returns a string if the valid is invalid, possible + * given data element. Considers the value to be valid if null or empty. + * Returns a string if the valid is invalid, possible * values are: * *