dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38829
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19727: Option set, trim to null before save
------------------------------------------------------------
revno: 19727
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-06 14:24:02 +0200
message:
Option set, trim to null before save
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
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.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 2015-03-20 07:08:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2015-08-06 12:24:02 +0000
@@ -29,12 +29,13 @@
*/
import com.opensymphony.xwork2.Action;
+
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -208,8 +209,8 @@
}
}
- Attribute attribute = new Attribute( name, valueType );
- attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
+ Attribute attribute = new Attribute( StringUtils.trimToNull( name ), StringUtils.trimToNull( valueType ) );
+ attribute.setCode( StringUtils.trimToNull( 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 2015-03-20 07:08:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2015-08-06 12:24:02 +0000
@@ -29,12 +29,13 @@
*/
import com.opensymphony.xwork2.Action;
+
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -219,9 +220,9 @@
attribute.setOptionSet( optionSet );
}
- attribute.setName( name );
- attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
- attribute.setValueType( valueType );
+ attribute.setName( StringUtils.trimToNull( name ) );
+ attribute.setCode( StringUtils.trimToNull( code ) );
+ attribute.setValueType( StringUtils.trimToNull( valueType ) );
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/constant/AddConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java 2015-05-21 13:11:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/AddConstantAction.java 2015-08-06 12:24:02 +0000
@@ -98,7 +98,7 @@
@Override
public String execute()
{
- Constant constant = new Constant( name, Double.parseDouble( value ) );
+ Constant constant = new Constant( StringUtils.trimToNull( name ), Double.parseDouble( value ) );
constant.setShortName( StringUtils.trimToNull( shortName ) );
constant.setCode( StringUtils.trimToNull( code ) );
constant.setDescription( StringUtils.trimToNull( description ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java 2015-05-21 13:11:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/constant/UpdateConstantAction.java 2015-08-06 12:24:02 +0000
@@ -107,7 +107,7 @@
{
Constant constant = constantService.getConstant( id );
- constant.setName( name );
+ constant.setName( StringUtils.trimToNull( name ) );
constant.setShortName( StringUtils.trimToNull( shortName ) );
constant.setCode( StringUtils.trimToNull( code ) );
constant.setDescription( StringUtils.trimToNull( description ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java 2015-08-06 12:24:02 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.option.Option;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
@@ -93,7 +94,9 @@
{
OptionSet optionSet = optionService.getOptionSet( optionSetId );
- Option option = new Option( name, code );
+ Option option = new Option();
+ option.setName( StringUtils.trimToNull( name ) );
+ option.setCode( StringUtils.trimToNull( code ) );
optionSet.getOptions().add( option );
optionService.updateOptionSet( optionSet );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2015-03-27 11:01:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2015-08-06 12:24:02 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
@@ -76,8 +77,8 @@
public String execute()
throws Exception
{
- OptionSet optionSet = new OptionSet( name );
- optionSet.setCode( code );
+ OptionSet optionSet = new OptionSet( StringUtils.trimToNull( name ) );
+ optionSet.setCode( StringUtils.trimToNull( code ) );
optionSet.setVersion( 1 );
optionService.saveOptionSet( optionSet );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java 2015-08-06 12:24:02 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.option.Option;
import org.hisp.dhis.option.OptionService;
@@ -91,7 +92,7 @@
throws Exception
{
Option option = optionService.getOption( optionId );
- option.setName( name );
+ option.setName( StringUtils.trimToNull( name ) );
optionService.updateOption( option );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2015-03-27 11:01:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2015-08-06 12:24:02 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
@@ -85,8 +86,8 @@
throws Exception
{
OptionSet optionSet = optionService.getOptionSet( id );
- optionSet.setName( name );
- optionSet.setCode( code );
+ optionSet.setName( StringUtils.trimToNull( name ) );
+ optionSet.setCode( StringUtils.trimToNull( code ) );
optionService.updateOptionSet( optionSet );