dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26253
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13006: prepare for special characters befor parsing sms command
------------------------------------------------------------
revno: 13006
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-11-22 16:05:23 +0700
message:
prepare for special characters befor parsing sms command
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.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-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-11-15 09:01:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-11-22 09:05:23 +0000
@@ -38,9 +38,11 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -63,6 +65,7 @@
import org.hisp.dhis.smscommand.SMSCode;
import org.hisp.dhis.smscommand.SMSCommand;
import org.hisp.dhis.smscommand.SMSCommandService;
+import org.hisp.dhis.smscommand.SMSSpecialCharacter;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
@@ -148,6 +151,7 @@
{
if ( parsedMessage.containsKey( code.getCode().toUpperCase() ) )
{
+ //potential bugs [noted by Lai]
valueStored = storeDataValue( senderPhoneNumber, orgUnit, parsedMessage, code, smsCommand, date,
smsCommand.getDataset() );
}
@@ -332,6 +336,18 @@
DataValue dv = dataValueService.getDataValue( orgunit, code.getDataElement(), period, optionCombo );
String value = parsedMessage.get( upperCaseCode );
+
+ Set<SMSSpecialCharacter> specialCharacters = command.getSpecialCharacters();
+
+ //Check for special character cases
+ for( SMSSpecialCharacter each: specialCharacters )
+ {
+ if ( each.getName().equals( value ) )
+ {
+ value = each.getValue();
+ }
+ }
+
if ( !StringUtils.isEmpty( value ) )
{
boolean newDataValue = false;
@@ -360,16 +376,7 @@
else if ( StringUtils.equals( dv.getDataElement().getType(), DataElement.VALUE_TYPE_INT ) )
{
try
- {
- if( value.equals( "l" ) )
- {
- value = "1";
- }
- else if( value.equals( "o" ) )
- {
- value = "0";
- }
-
+ {
Integer.parseInt( value );
}
catch ( NumberFormatException e )