dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04333
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1423: Validation of concept name
------------------------------------------------------------
revno: 1423
committer: Bob Jolliffe <bobj@bobj-laptop>
branch nick: trunk
timestamp: Fri 2010-02-12 12:22:25 +0000
message:
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/responseCategory.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 2009-11-03 10:17:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/ValidateDataElementCategoryAction.java 2010-02-12 12:22:25 +0000
@@ -32,6 +32,8 @@
import org.hisp.dhis.i18n.I18n;
import com.opensymphony.xwork2.Action;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* @author Abyot Asalefew
@@ -76,6 +78,14 @@
this.name = name;
}
+ private String conceptName;
+
+ public void setConceptName( String conceptName )
+ {
+ this.conceptName = conceptName;
+ }
+
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -110,6 +120,20 @@
return INPUT;
}
}
+
+ if ( conceptName != null || !conceptName.isEmpty()) {
+ // No funny characters please. max length 10.
+ Pattern conceptNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z_]+$");
+ Matcher matcher = conceptNamePattern.matcher(conceptName);
+
+ if (conceptName.length()>10 || !matcher.matches())
+ {
+ message = i18n.getString( "illegal_conceptName" );
+
+ return INPUT;
+ }
+ }
+
message = "ok";
return SUCCESS;
=== 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-02-11 14:26:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2010-02-12 12:22:25 +0000
@@ -384,4 +384,5 @@
view_all = View all
mark_value_for_followup = Mark value for follow-up
unmark_value_for_followup = Unmark value for follow-up
-concept_name = Concept name
\ No newline at end of file
+concept_name = Concept name
+illegal_conceptName = Concept name must 10 or less alphanumeric or '_' characters
=== 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-02-10 17:00:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js 2010-02-12 12:22:25 +0000
@@ -59,7 +59,9 @@
}
var requestString = 'validateDataElementCategory.action?name=' + htmlEncode( document.getElementById( 'name' ).value );
-
+
+ requestString += "&conceptName=" + htmlEncode( document.getElementById( 'conceptName' ).value );
+
requestString += "&" + getParamString( 'categoryOptionNames' );
request.send( requestString );
@@ -92,6 +94,8 @@
var requestString = 'validateDataElementCategory.action?id=' + document.getElementById( 'id' ).value +
'&name=' + htmlEncode( document.getElementById( 'name' ).value );
+ requestString += "&conceptName=" + htmlEncode( document.getElementById( 'conceptName' ).value );
+
requestString += "&" + getParamString( 'categoryOptions' );
request.send( requestString );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/responseCategory.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/responseCategory.vm 2009-10-19 17:10:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/responseCategory.vm 2010-02-12 12:22:25 +0000
@@ -1,5 +1,6 @@
<dataElementCategory>
<id>$dataElementCategory.id</id>
<name>$encoder.xmlEncode( $dataElementCategory.name )</name>
- <categoryOptionCount>$dataElementCategory.categoryOptions.size()</categoryOptionCount>
-</dataElementCategory>
\ No newline at end of file
+ <conceptName>$encoder.xmlEncode( $dataElementCategory.conceptName )</conceptName>
+ <categoryOptionCount>$dataElementCategory.categoryOptions.size()</categoryOptionCount>
+</dataElementCategory>