← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13794: minor fix, check for empty code string in add/update-attribute

 

------------------------------------------------------------
revno: 13794
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-21 14:03:21 +0700
message:
  minor fix, check for empty code string in add/update-attribute
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.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-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2014-01-20 10:20:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2014-01-21 07:03:21 +0000
@@ -31,6 +31,7 @@
 import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
+import org.springframework.util.StringUtils;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -159,7 +160,7 @@
     public String execute()
     {
         Attribute attribute = new Attribute( name, valueType );
-        attribute.setCode( code );
+        attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
         attribute.setMandatory( mandatory );
         attribute.setDataElementAttribute( dataElementAttribute );
         attribute.setDataElementGroupAttribute( dataElementGroupAttribute );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2014-01-20 10:20:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2014-01-21 07:03:21 +0000
@@ -32,6 +32,7 @@
 import org.hisp.dhis.attribute.AttributeService;
 
 import com.opensymphony.xwork2.Action;
+import org.springframework.util.StringUtils;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -171,7 +172,7 @@
         if ( attribute != null )
         {
             attribute.setName( name );
-            attribute.setCode( code );
+            attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
             attribute.setValueType( valueType );
             attribute.setMandatory( mandatory );
             attribute.setDataElementAttribute( dataElementAttribute );