dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41385
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21079: minor, support validation valueType/values for non data element value types
------------------------------------------------------------
revno: 21079
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 15:08:32 +0700
message:
minor, support validation valueType/values for non data element value types
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.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-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 2015-09-21 12:17:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2015-11-17 08:08:32 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.system.util.ValidationUtils.dataValueIsValid;
+import static org.hisp.dhis.system.util.ValidationUtils.valueTypeIsValid;
import static org.hisp.dhis.system.util.ValidationUtils.dataValueIsZeroAndInsignificant;
import java.util.Calendar;
=== 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 2015-10-20 08:18:49 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2015-11-17 08:08:32 +0000
@@ -32,8 +32,8 @@
import org.apache.commons.validator.routines.DateValidator;
import org.apache.commons.validator.routines.EmailValidator;
import org.apache.commons.validator.routines.UrlValidator;
+import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.common.CodeGenerator;
-import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.dataelement.DataElement;
@@ -304,18 +304,26 @@
*/
public static String dataValueIsValid( String value, DataElement dataElement )
{
+ if ( dataElement == null || dataElement.getValueType() == null )
+ {
+ return "data_element_or_type_null_or_empty";
+ }
+
+ return dataValueIsValid( value, dataElement.getValueType() );
+ }
+
+ public static String dataValueIsValid( String value, ValueType valueType )
+ {
if ( value == null || value.trim().isEmpty() )
{
return null;
}
- if ( dataElement == null || dataElement.getValueType() == null )
+ if ( valueType == null )
{
return "data_element_or_type_null_or_empty";
}
- ValueType valueType = dataElement.getValueType();
-
if ( value.length() > VALUE_MAX_LENGTH )
{
return "value_length_greater_than_max_length";
@@ -380,10 +388,10 @@
{
return "value_not_valid_file_resource_uid";
}
-
- if ( ValueType.COORDINATE == valueType && !MathUtils.isCoordinate( value ))
+
+ if ( ValueType.COORDINATE == valueType && !MathUtils.isCoordinate( value ) )
{
- return "value_not_coordinate";
+ return "value_not_coordinate";
}
return null;
@@ -466,10 +474,10 @@
{
return value != null && HEX_COLOR_PATTERN.matcher( value ).matches();
}
-
+
/**
* Returns a string useful for substitution.
- *
+ *
* @param valueType the value type.
* @return the string.
*/