dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32709
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16681: fix bug on sms alert
------------------------------------------------------------
revno: 16681
committer: Ngo Thanh Long <thanhlongngo1988@xxxxxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-09-10 11:36:51 +0700
message:
fix bug on sms alert
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DHISMessageAlertListener.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js
--
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-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2014-07-30 04:28:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2014-09-10 04:36:51 +0000
@@ -45,6 +45,8 @@
public static final String NO_USER_MESSAGE = "No user associated with this phone number. Please contact your supervisor.";
+ public static final String ALERT_FEEDBACK = "Your alert message sent";
+
//Completeness method code
public static final int RECEIVE_ALL_DATAVALUE = 1;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DHISMessageAlertListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DHISMessageAlertListener.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DHISMessageAlertListener.java 2014-09-10 04:36:51 +0000
@@ -37,6 +37,8 @@
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.sms.incoming.IncomingSms;
import org.hisp.dhis.sms.incoming.IncomingSmsListener;
+import org.hisp.dhis.sms.incoming.IncomingSmsService;
+import org.hisp.dhis.sms.incoming.SmsMessageStatus;
import org.hisp.dhis.sms.parse.ParserType;
import org.hisp.dhis.sms.parse.SMSParserException;
import org.hisp.dhis.smscommand.SMSCommand;
@@ -58,6 +60,8 @@
private SmsMessageSender smsMessageSender;
+ private IncomingSmsService incomingSmsService;
+
public SMSCommandService getSmsCommandService()
{
return smsCommandService;
@@ -145,8 +149,19 @@
// confirm SMS was received and forwarded completely
Set<User> feedbackList = new HashSet<>();
feedbackList.add( sender );
- smsMessageSender.sendMessage( smsCommand.getName(), smsCommand.getReceivedMessage(), null,
- feedbackList, true );
+
+ String confirmMessage = smsCommand.getReceivedMessage();
+
+ if ( confirmMessage == null )
+ {
+ confirmMessage = SMSCommand.ALERT_FEEDBACK;
+ }
+
+ smsMessageSender.sendMessage( smsCommand.getName(), confirmMessage, null, feedbackList, true );
+
+ sms.setParsed( true );
+ sms.setStatus( SmsMessageStatus.PROCESSED );
+ incomingSmsService.update( sms );
}
else if ( users == null || users.size() == 0 )
{
@@ -185,4 +200,14 @@
{
this.smsMessageSender = smsMessageSender;
}
+
+ public IncomingSmsService getIncomingSmsService()
+ {
+ return incomingSmsService;
+ }
+
+ public void setIncomingSmsService( IncomingSmsService incomingSmsService )
+ {
+ this.incomingSmsService = incomingSmsService;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java 2014-09-10 04:36:51 +0000
@@ -57,6 +57,7 @@
private static final Log log = LogFactory.getLog( SmsMessageSender.class );
private static int MAX_CHAR = 160;
+
private static final String GW_BULK = "bulk_gw";
// -------------------------------------------------------------------------
@@ -89,7 +90,8 @@
{
String message = null;
- Map<String, String> gatewayMap = outboundSmsTransportService != null ? outboundSmsTransportService.getGatewayMap() : null;
+ Map<String, String> gatewayMap = outboundSmsTransportService != null ? outboundSmsTransportService
+ .getGatewayMap() : null;
String gatewayId = StringUtils.trimToNull( outboundSmsTransportService.getDefaultGateway() );
@@ -101,12 +103,12 @@
Set<User> toSendList = new HashSet<>();
User currentUser = currentUserService.getCurrentUser();
-
+
if ( !forceSend )
{
for ( User user : users )
{
- if ( currentUser == null || ( currentUser != null && !currentUser.equals( user ) ) )
+ if ( currentUser == null || (currentUser != null && !currentUser.equals( user )) )
{
if ( isQualifiedReceiver( user ) )
{
@@ -127,11 +129,11 @@
text = createMessage( subject, text, sender );
// Bulk is limited in sending long SMS, need to split in pieces
-
+
if ( gatewayId.equals( gatewayMap.get( GW_BULK ) ) )
{
// Check if text contain any specific character
-
+
for ( char each : text.toCharArray() )
{
if ( !Character.UnicodeBlock.of( each ).equals( UnicodeBlock.BASIC_LATIN ) )
@@ -144,7 +146,7 @@
{
List<String> splitTextList = new ArrayList<>();
splitTextList = splitLongUnicodeString( text, splitTextList );
-
+
for ( String each : splitTextList )
{
if ( !phoneNumbers.isEmpty() && phoneNumbers.size() > 0 )
@@ -182,11 +184,13 @@
{
return true;
}
- else // Receiver is user
+ else
+ // Receiver is user
{
- UserSetting userSetting = userService.getUserSetting( user, UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION );
+ UserSetting userSetting = userService
+ .getUserSetting( user, UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION );
- return ( userSetting != null && userSetting.getValue() != null ) ? (Boolean) userSetting.getValue() : false;
+ return (userSetting != null && userSetting.getValue() != null) ? (Boolean) userSetting.getValue() : false;
}
}
@@ -234,7 +238,7 @@
private String sendMessage( String text, Set<String> recipients, String gateWayId )
{
String message = null;
-
+
OutboundSms sms = new OutboundSms();
sms.setMessage( text );
sms.setRecipients( recipients );
@@ -249,7 +253,7 @@
log.warn( "Unable to send message through SMS: " + sms, e );
}
-
+
return message;
}
@@ -272,7 +276,7 @@
if ( secondTempString.length() <= MAX_CHAR )
{
result.add( secondTempString );
-
+
return result;
}
else
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-09-08 10:23:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-09-10 04:36:51 +0000
@@ -907,6 +907,7 @@
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
<property name="smsMessageSender" ref="org.hisp.dhis.sms.SmsMessageSender" />
<property name="userService" ref="org.hisp.dhis.user.UserService" />
+ <property name="incomingSmsService" ref="org.hisp.dhis.sms.incoming.IncomingSmsService" />
</bean>
<bean id="org.hisp.dhis.sms.SmsMessageSender" class="org.hisp.dhis.sms.SmsMessageSender">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js 2014-07-30 04:28:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js 2014-09-10 04:36:51 +0000
@@ -19,6 +19,7 @@
hideById( "dataSetParser" );
hideById( "alertParser" );
hideById( "anonymousProgramParser" );
+ hideById( "registrationParser" );
}
function generateSpecialCharactersForm()