=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2016-01-13 13:38:09 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2016-02-02 11:10:58 +0000 @@ -50,6 +50,7 @@ TRUE_ONLY( Boolean.class ), DATE( Date.class ), DATETIME( Date.class ), + TIME( String.class ), NUMBER( Double.class ), UNIT_INTERVAL( Double.class ), PERCENTAGE( Double.class ), @@ -60,7 +61,7 @@ TRACKER_ASSOCIATE( TrackedEntityInstance.class ), USERNAME( String.class ), FILE_RESOURCE( String.class ), - COORDINATE( String.class); + COORDINATE( String.class ); public static final Set INTEGER_TYPES = Sets.newHashSet( INTEGER, INTEGER_POSITIVE, INTEGER_NEGATIVE, INTEGER_ZERO_OR_POSITIVE ); @@ -70,13 +71,13 @@ public static final Set BOOLEAN_TYPES = Sets.newHashSet( BOOLEAN, TRUE_ONLY ); - - public static final Set TEXT_TYPES = Sets.newHashSet( - TEXT, LONG_TEXT, LETTER, COORDINATE ); - + + public static final Set TEXT_TYPES = Sets.newHashSet( + TEXT, LONG_TEXT, LETTER, COORDINATE, TIME ); + public static final Set DATE_TYPES = Sets.newHashSet( DATE, DATETIME ); - + private final Class javaClass; private ValueType() @@ -103,7 +104,7 @@ { return NUMERIC_TYPES.contains( this ); } - + public boolean isBoolean() { return BOOLEAN_TYPES.contains( this ); @@ -123,9 +124,9 @@ { return this == FILE_RESOURCE; } - + public boolean isCoordinate() { - return this == COORDINATE; + return this == COORDINATE; } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2016-02-02 11:10:58 +0000 @@ -399,6 +399,9 @@ "" + ""; } + else if ( ValueType.TIME == valueType ) { + appendCode += " type=\"time\" name=\"entrytime\" class=\"entrytime\" tabindex=\"" + i++ + "\"" + TAG_CLOSE; + } else { appendCode += " type=\"text\" name=\"entryfield\" class=\"entryfield\" tabindex=\"" + i++ + "\"" + TAG_CLOSE; === 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 2016-01-18 10:08:12 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2016-02-02 11:10:58 +0000 @@ -51,14 +51,23 @@ public class ValidationUtils { private static final Pattern POINT_PATTERN = Pattern.compile( "\\[(.+),\\s?(.+)\\]" ); + private static final Pattern DIGIT_PATTERN = Pattern.compile( ".*\\d.*" ); + private static final Pattern UPPERCASE_PATTERN = Pattern.compile( ".*[A-Z].*" ); + private static final Pattern HEX_COLOR_PATTERN = Pattern.compile( "^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" ); + private static final Pattern TIME_OF_DAY_PATTERN = Pattern.compile( "^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$" ); + private static final int VALUE_MAX_LENGTH = 50000; + private static final int LONG_MAX = 180; + private static final int LONG_MIN = -180; + private static final int LAT_MAX = 90; + private static final int LAT_MIN = -90; private static final Set SQL_VALID_CHARS = Sets.newHashSet( @@ -135,6 +144,17 @@ } /** + * Validates whether a string is valid for the HH:mm time format. + * + * @param time the time string + * @return true if the time string is valid, false otherwise + */ + public static boolean timeIsValid( String time ) + { + return TIME_OF_DAY_PATTERN.matcher( time ).matches(); + } + + /** * Validates whether an URL string is valid. * * @param url the URL string. @@ -147,7 +167,7 @@ /** * Validates whether a password is valid. A password must: - *

+ *

*

    *
  • Be between 8 and 80 characters long
  • *
  • Include at least one digit
  • @@ -242,7 +262,6 @@ return matcher.find() ? matcher.group( 2 ) : null; } - /** * Returns the longitude and latitude from the given coordinate. * @@ -260,9 +279,11 @@ if ( matcher.find() && matcher.groupCount() == 2 ) { - return new Point2D.Double( Double.parseDouble( matcher.group( 1 ) ), Double.parseDouble( matcher.group( 2 ) ) ); + return new Point2D.Double( Double.parseDouble( matcher.group( 1 ) ), + Double.parseDouble( matcher.group( 2 ) ) ); } - else return null; + else + return null; } /** @@ -283,7 +304,7 @@ * given data element. Considers the value to be valid if null or empty. * Returns a string if the valid is invalid, possible * values are: - *

    + *

    *

      *
    • data_element_or_type_null_or_empty
    • *
    • value_length_greater_than_max_length
    • @@ -408,7 +429,8 @@ { AggregationType aggregationType = dataElement.getAggregationType(); - return dataElement.getValueType().isNumeric() && MathUtils.isZero( value ) && !dataElement.isZeroIsSignificant() && + return dataElement.getValueType().isNumeric() && MathUtils.isZero( value ) && + !dataElement.isZeroIsSignificant() && !(aggregationType == AggregationType.AVERAGE_SUM_ORG_UNIT || aggregationType == AggregationType.AVERAGE); } === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm 2015-12-17 14:12:16 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm 2016-01-14 15:53:19 +0000 @@ -89,6 +89,8 @@ #elseif( $dataElement.valueType == 'TRUE_ONLY' ) + #elseif( $dataElement.valueType == "TIME" ) + #else #if( $dataElement.optionSet ) @@ -170,6 +172,8 @@ #elseif( $dataElement.valueType == 'TRUE_ONLY' ) + #elseif( $dataElement.valueType == "TIME" ) + #else #if( $dataElement.optionSet ) @@ -219,6 +223,8 @@ #elseif( $dataElement.valueType == 'TRUE_ONLY' ) + #elseif( $dataElement.valueType == "TIME" ) + #else #if( $dataElement.optionSet ) === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2015-12-08 13:14:21 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2016-01-14 15:53:19 +0000 @@ -133,6 +133,10 @@ + #elseif( $dataElement.valueType == "TIME" ) + + + #else #if( $dataElement.optionSet )