← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16755: Reverted r 16754. Mysql not happy.

 

------------------------------------------------------------
revno: 16755
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-19 17:50:55 +0200
message:
  Reverted r 16754. Mysql not happy.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.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/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js


--
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/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-09-19 14:10:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-09-19 15:50:55 +0000
@@ -736,9 +736,6 @@
         executeSql( "alter table indicator drop column sortorder" );
         executeSql( "alter table dataset drop column sortorder" );
         
-        executeSql( "alter table datavalue alter column value type character varying" );
-        executeSql( "alter table datavalue alter column comment type character varying" );
-        
         upgradeDataValuesWithAttributeOptionCombo();
         upgradeCompleteDataSetRegistrationsWithAttributeOptionCombo();
         upgradeMapViewsToAnalyticalObject();

=== 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	2014-09-19 14:10:47 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2014-09-19 15:50:55 +0000
@@ -28,29 +28,21 @@
  * 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.dataelement.DataElement.VALUE_TYPE_BOOL;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_DATE;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_NEGATIVE_INT;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_NUMBER;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_PERCENTAGE;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_POSITIVE_INT;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_TRUE_ONLY;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_UNIT_INTERVAL;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT;
-
-import java.awt.geom.Point2D;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 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.dataelement.DataElement;
 import org.hisp.dhis.datavalue.DataValue;
 
+import java.awt.geom.Point2D;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static org.hisp.dhis.dataelement.DataElement.*;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -252,6 +244,7 @@
      * 
      * <ul>
      * <li>data_element_or_type_null_or_empty</li>
+     * <li>value_length_greater_than_max_length</li>
      * <li>value_not_numeric</li>
      * <li>value_not_unit_interval</li>
      * <li>value_not_percentage</li>
@@ -279,8 +272,16 @@
             return "data_element_or_type_null_or_empty";
         }
 
+        List<String> types = Arrays.asList( VALUE_TYPE_STRING, VALUE_TYPE_INT, VALUE_TYPE_NUMBER, 
+            VALUE_TYPE_POSITIVE_INT, VALUE_TYPE_NEGATIVE_INT, VALUE_TYPE_ZERO_OR_POSITIVE_INT );
+
         String type = dataElement.getDetailedNumberType();
 
+        if ( types.contains( type ) && value.length() > 255 )
+        {
+            return "value_length_greater_than_max_length";
+        }
+
         if ( VALUE_TYPE_NUMBER.equals( type ) && !MathUtils.isNumeric( value ) )
         {
             return "value_not_numeric";
@@ -365,6 +366,11 @@
             return null;
         }
         
+        if ( comment.length() > 360 )
+        {
+            return "comment_too_long";
+        }
+        
         return null;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2014-09-19 14:10:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2014-09-19 15:50:55 +0000
@@ -181,6 +181,10 @@
     {
         if ( type == 'string' || type == 'int' || type == 'number' || type == 'posInt' || type == 'negInt' || type == 'zeroPositiveInt' || type == 'unitInterval' || type == 'percentage' )
         {
+            if ( value.length > 255 )
+            {
+                return dhis2.de.alertField( fieldId, i18n_value_too_long + '\n\n' + dataElementName );
+            }
             if ( type == 'int' && !dhis2.validation.isInt( value ) )
             {
                 return dhis2.de.alertField( fieldId, i18n_value_must_integer + '\n\n' + dataElementName );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-09-19 14:10:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-09-19 15:50:55 +0000
@@ -5,6 +5,14 @@
 	
     var commentValue = $( '#commentTextArea' ).val();
 
+    if ( commentValue.length > 360 )
+    {
+        markComment( dhis2.de.cst.colorYellow );
+        window.alert(i18n_value_too_long + " for comment field");
+
+        return;
+    }
+
     var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, commentValue );
 
     commentSaver.save();