dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21361
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10084: Avoid storing empty values
------------------------------------------------------------
revno: 10084
committer: Magnus Korvald <korvald@xxxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2013-03-08 16:53:42 +0100
message:
Avoid storing empty values
modified:
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.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-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java 2013-03-05 17:06:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/parse/DefaultParserManager.java 2013-03-08 15:53:42 +0000
@@ -57,7 +57,7 @@
@Autowired
private DataElementCategoryService dataElementCategoryService;
-
+
@Autowired
private OutboundSmsTransportService transportService;
@@ -251,9 +251,7 @@
}
else if ( dv != null )
{
-
String value = dv.getValue();
-
if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
{
if ( "true".equals( value ) )
@@ -358,44 +356,44 @@
DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
String value = parsedMessage.get( upperCaseCode );
-
- boolean newDataValue = false;
- if ( dv == null )
- {
- dv = new DataValue();
- dv.setOptionCombo( optionCombo );
- dv.setSource( orgunit );
- dv.setDataElement( code.getDataElement() );
- dv.setPeriod( period );
- dv.setComment( "" );
- dv.setTimestamp( new java.util.Date() );
- dv.setStoredBy( storedBy );
- newDataValue = true;
- }
-
- if ( value != null && StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
- {
- if ( "Y".equals( value.toUpperCase() ) || "YES".equals( value.toUpperCase() ) )
- {
- value = "true";
- }
- else if ( "N".equals( value.toUpperCase() ) || "NO".equals( value.toUpperCase() ) )
- {
- value = "false";
- }
- }
-
- dv.setValue( value );
-
- if ( newDataValue )
- {
- dataValueService.addDataValue( dv );
- }
- else
- {
+ if ( !StringUtils.isEmpty( value ) )
+ {
+ boolean newDataValue = false;
+ if ( dv == null )
+ {
+ dv = new DataValue();
+ dv.setOptionCombo( optionCombo );
+ dv.setSource( orgunit );
+ dv.setDataElement( code.getDataElement() );
+ dv.setPeriod( period );
+ dv.setComment( "" );
+ dv.setTimestamp( new java.util.Date() );
+ dv.setStoredBy( storedBy );
+ newDataValue = true;
+ }
+
+ if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_BOOL ) )
+ {
+ if ( "Y".equals( value.toUpperCase() ) || "YES".equals( value.toUpperCase() ) )
+ {
+ value = "true";
+ }
+ else if ( "N".equals( value.toUpperCase() ) || "NO".equals( value.toUpperCase() ) )
+ {
+ value = "false";
+ }
+ }
+
dv.setValue( value );
- dv.setOptionCombo( optionCombo );
- dataValueService.updateDataValue( dv );
+
+ if ( newDataValue )
+ {
+ dataValueService.addDataValue( dv );
+ }
+ else
+ {
+ dataValueService.updateDataValue( dv );
+ }
}
}