dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42955
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21870: New TIME / time of day valuetype for data elements; including validation and updated forms for da...
Merge authors:
Stian Sandvold (stian-sandvold)
------------------------------------------------------------
revno: 21870 [merge]
committer: Stian Sandvold <stian.sandvold@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-02-03 12:38:29 +0100
message:
New TIME / time of day valuetype for data elements; including validation and updated forms for dataelements
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java
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/sectionForm.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/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<ValueType> INTEGER_TYPES = Sets.newHashSet(
INTEGER, INTEGER_POSITIVE, INTEGER_NEGATIVE, INTEGER_ZERO_OR_POSITIVE );
@@ -70,13 +71,13 @@
public static final Set<ValueType> BOOLEAN_TYPES = Sets.newHashSet(
BOOLEAN, TRUE_ONLY );
-
- public static final Set<ValueType> TEXT_TYPES = Sets.newHashSet(
- TEXT, LONG_TEXT, LETTER, COORDINATE );
-
+
+ public static final Set<ValueType> TEXT_TYPES = Sets.newHashSet(
+ TEXT, LONG_TEXT, LETTER, COORDINATE, TIME );
+
public static final Set<ValueType> 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 @@
"<input type=\"file\" style=\"display: none;\">" +
"</div>";
}
+ 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<Character> 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:
- * <p>
+ * <p/>
* <ul>
* <li>Be between 8 and 80 characters long</li>
* <li>Include at least one digit</li>
@@ -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:
- * <p>
+ * <p/>
* <ul>
* <li>data_element_or_type_null_or_empty</li>
* <li>value_length_greater_than_max_length</li>
@@ -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 @@
</select></td>
#elseif( $dataElement.valueType == 'TRUE_ONLY' )
<td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+ #elseif( $dataElement.valueType == "TIME" )
+ <td><input type="time" class="entrytime" name="entrytime" id="$dataEntryId" tabindex="$tabIndex"/> </td>
#else
#if( $dataElement.optionSet )
<td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
@@ -170,6 +172,8 @@
</select></td>
#elseif( $dataElement.valueType == 'TRUE_ONLY' )
<td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+ #elseif( $dataElement.valueType == "TIME" )
+ <td><input type="time" class="entrytime" name="entrytime" id="$dataEntryId" tabindex="$tabIndex"/> </td>
#else
#if( $dataElement.optionSet )
<td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
@@ -219,6 +223,8 @@
</select></td>
#elseif( $dataElement.valueType == 'TRUE_ONLY' )
<td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+ #elseif( $dataElement.valueType == "TIME" )
+ <td><input type="time" class="entrytime" name="entrytime" id="$dataEntryId" tabindex="$tabIndex"/> </td>
#else
#if( $dataElement.optionSet )
<td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
=== 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 @@
<input type="file" style="display: none;">
</div>
</td>
+ #elseif( $dataElement.valueType == "TIME" )
+ <td>
+ <input type="time" name="entrytime" id="${dataentryId}" tabindex="${tabIndex}" />
+ </td>
#else
#if( $dataElement.optionSet )
<td><input name="entryoptionset" class="entryoptionset" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end><img class="commentlink" id="${commentId}"></td>