← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1814: Improved validation of concept name

 

------------------------------------------------------------
revno: 1814
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-04-26 14:30:32 +0200
message:
  Improved validation of concept name
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.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-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java	2010-04-26 12:30:32 +0000
@@ -84,7 +84,6 @@
     {
         this.conceptName = conceptName;
     }
-    
 
     // -------------------------------------------------------------------------
     // Output
@@ -121,16 +120,19 @@
             }
         }
 
-            if ( conceptName != null || !conceptName.isEmpty()) {
-            
-            // This string will be used as an XML attribute name.  So:
-            // Start with a letter. No funny characters please.  max length 10.
-            Pattern conceptNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_]{0,9}$");
-            Matcher matcher = conceptNamePattern.matcher(conceptName);
-
-            if (!matcher.matches())
+        if ( conceptName != null || !conceptName.isEmpty() )
+        {
+            // -----------------------------------------------------------------
+            // This string will be used as an XML attribute name.
+            // Start with a letter. No funny characters please. Max length 10.
+            // -----------------------------------------------------------------
+
+            Pattern conceptNamePattern = Pattern.compile( "^[a-zA-Z][a-zA-Z0-9_]{0,9}$" );
+            Matcher matcher = conceptNamePattern.matcher( conceptName );
+
+            if ( !matcher.matches() )
             {
-                message = i18n.getString( "illegal_conceptName" );
+                message = i18n.getString( "illegal_concept_name" );
 
                 return INPUT;
             }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2010-03-30 04:36:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2010-04-26 12:30:32 +0000
@@ -384,7 +384,7 @@
 mark_value_for_followup							= Mark value for follow-up
 unmark_value_for_followup						= Unmark value for follow-up
 concept_name									= Concept name
-illegal_conceptName                             = Concept name must 10 or less alphanumeric or '_' characters
+illegal_concept_name                            = Concept name must contain alphanumeric characters only and have maximum 10 characters
 switch_view										= Switch View
 available_groups								= Available Groups
 assign_groups_for_dataelement					= Assign Groups for Data Element

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js	2010-03-30 04:36:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js	2010-04-26 12:30:32 +0000
@@ -136,7 +136,8 @@
 		{
 			setMessage( xmlObject.firstChild.nodeValue );
 		}
-		else if(mode == "update"){
+		else if ( mode == "update" )
+		{
 			updateCategoryOptionName();
 		}
 		else

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2010-03-30 04:36:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2010-04-26 12:30:32 +0000
@@ -34,7 +34,7 @@
     </tr>      
     <tr>
       <td><label>$i18n.getString( "concept_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-      <td><input type="text" id="conceptName" name="conceptName" style="width:25em" maxlength="160" class="{validate:{minlength:2,maxlength:160}}"></td>
+      <td><input type="text" id="conceptName" name="conceptName" style="width:25em" maxlength="10" class="{validate:{minlength:2,maxlength:10}}"></td>
       <td></td>
     </tr>   
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2010-03-30 04:36:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2010-04-26 12:30:32 +0000
@@ -37,7 +37,7 @@
     </tr>      
     <tr>
       <td><label>$i18n.getString( "concept_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-      <td><input type="text" id="conceptName" name="conceptName" value="$!encoder.htmlEncode( $dataElementCategory.conceptName )" style="width:25em" maxlength="160" class="{validate:{minlength:2,maxlength:160}}"></td>
+      <td><input type="text" id="conceptName" name="conceptName" value="$!encoder.htmlEncode( $dataElementCategory.conceptName )" style="width:25em" maxlength="10" class="{validate:{minlength:2,maxlength:10}}"></td>
       <td></td>
     </tr>  
     <tr>