← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16757: Set max length for datavalue value and comment + audit value to 50 000 characters

 

------------------------------------------------------------
revno: 16757
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-19 19:13:55 +0200
message:
  Set max length for datavalue value and comment + audit value to 50 000 characters
modified:
  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/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml
  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/history.vm
  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/form.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 15:50:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-09-19 17:13:55 +0000
@@ -735,6 +735,10 @@
         executeSql( "alter table dataelement drop column sortorder" );
         executeSql( "alter table indicator drop column sortorder" );
         executeSql( "alter table dataset drop column sortorder" );
+
+        executeSql( "alter table datavalue alter column value type character varying(50000)" );
+        executeSql( "alter table datavalue alter column comment type character varying(50000)" );
+        executeSql( "alter table datavalueaudit alter column value type character varying(50000)" );
         
         upgradeDataValuesWithAttributeOptionCombo();
         upgradeCompleteDataSetRegistrationsWithAttributeOptionCombo();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2014-07-07 10:45:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2014-09-19 17:13:55 +0000
@@ -14,7 +14,7 @@
       <key-many-to-one name="attributeOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="attributeoptioncomboid" foreign-key="fk_datavalue_attributeoptioncomboid" />
     </composite-id>
 
-    <property name="value" length="255" />
+    <property name="value" length="50000" />
 
     <property name="storedBy" column="storedby" length="100" />
 
@@ -22,7 +22,7 @@
 
     <property name="lastUpdated" column="lastupdated" type="timestamp" index="in_datavalue_lastupdated" />
 
-    <property name="comment" length="360" />
+    <property name="comment" length="50000" />
 
     <property name="followup" />
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml	2014-07-09 13:43:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml	2014-09-19 17:13:55 +0000
@@ -22,7 +22,7 @@
     <many-to-one name="categoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
                      column="categoryoptioncomboid" foreign-key="fk_datavalueaudit_categoryoptioncomboid" not-null="true"/>
 
-    <property name="value" length="255" />
+    <property name="value" length="50000" />
 
     <property name="timestamp" column="timestamp" type="timestamp" not-null="true" index="id_datavalueaudit_timestamp"/>
 

=== 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 15:50:55 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2014-09-19 17:13:55 +0000
@@ -28,21 +28,29 @@
  * 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$
@@ -53,6 +61,7 @@
     private static Pattern DIGIT_PATTERN = Pattern.compile( ".*\\d.*" );
     private static Pattern UPPERCASE_PATTERN = Pattern.compile( ".*[A-Z].*" );
 
+    private static int VALUE_MAX_LENGTH = 50000;
     private static int LONG_MAX = 180;
     private static int LONG_MIN = -180;
     private static int LAT_MAX = 90;
@@ -272,12 +281,9 @@
             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 )
+        if ( value.length() > VALUE_MAX_LENGTH )
         {
             return "value_length_greater_than_max_length";
         }
@@ -366,7 +372,7 @@
             return null;
         }
         
-        if ( comment.length() > 360 )
+        if ( comment.length() > VALUE_MAX_LENGTH )
         {
             return "comment_too_long";
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2014-07-23 12:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2014-09-19 17:13:55 +0000
@@ -34,7 +34,7 @@
     <tr>
 		<td valign="top">
 			<div id="commentOptionDiv" style="display:none;"><input type="text" id="commentOptionSet" style="width:240px"></div>
-			<textarea id="commentTextArea" maxlength="360" style="height:130px; width:240px;">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
+			<textarea id="commentTextArea" style="height:130px; width:240px;">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
 			<input type="button" value="$i18n.getString( 'save_comment' )" style="width:130px" onclick="saveComment()">
 		</td>		
         <td valign="top">

=== 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 15:50:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2014-09-19 17:13:55 +0000
@@ -181,7 +181,7 @@
     {
         if ( type == 'string' || type == 'int' || type == 'number' || type == 'posInt' || type == 'negInt' || type == 'zeroPositiveInt' || type == 'unitInterval' || type == 'percentage' )
         {
-            if ( value.length > 255 )
+            if ( value.length > dhis2.de.cst.valueMaxLength )
             {
                 return dhis2.de.alertField( fieldId, i18n_value_too_long + '\n\n' + dataElementName );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-09-18 12:50:44 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-09-19 17:13:55 +0000
@@ -83,6 +83,7 @@
 dhis2.de.cst.dropDownMaxItems = 30;
 dhis2.de.cst.formulaPattern = /#\{.+?\}/g;
 dhis2.de.cst.separator = '.';
+dhis2.de.cst.valueMaxLength = 50000;
 
 // Colors
 

=== 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 15:50:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-09-19 17:13:55 +0000
@@ -5,7 +5,7 @@
 	
     var commentValue = $( '#commentTextArea' ).val();
 
-    if ( commentValue.length > 360 )
+    if ( commentValue.length > dhis2.de.cst.valueMaxLength )
     {
         markComment( dhis2.de.cst.colorYellow );
         window.alert(i18n_value_too_long + " for comment field");