dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24358
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11924: fix bug which is unable to send SMS to multi raw phone numbers
------------------------------------------------------------
revno: 11924
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-05 13:05:43 +0700
message:
fix bug which is unable to send SMS to multi raw phone numbers
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsSender.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DefaultSmsSender.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java
dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java
dhis-2/dhis-web/dhis-web-sms/src/main/resources/META-INF/dhis/beans.xml
--
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/sms/SmsSender.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsSender.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/SmsSender.java 2013-09-05 06:05:43 +0000
@@ -28,7 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Set;
+import java.util.List;
+
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.user.User;
@@ -43,5 +44,5 @@
String sendMessage( String message, String phoneNumber )
throws SmsServiceException;
- String sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend );
+ String sendMessage( String subject, String text, User sender, List<User> users, boolean forceSend );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DefaultSmsSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DefaultSmsSender.java 2013-09-04 08:29:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DefaultSmsSender.java 2013-09-05 06:05:43 +0000
@@ -131,7 +131,7 @@
@Transactional
@Override
- public String sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend )
+ public String sendMessage( String subject, String text, User sender, List<User> users, boolean forceSend )
{
String message = null;
@@ -141,13 +141,13 @@
return message;
}
- Set<User> toSendList = new HashSet<User>();
+ List<User> toSendList = new ArrayList<User>();
String gatewayId = transportService.getDefaultGateway();
if ( gatewayId != null && !gatewayId.trim().isEmpty() )
{
- if ( forceSend )
+ if ( !forceSend )
{
for ( User user : users )
{
@@ -292,7 +292,7 @@
return (length > 160) ? text.substring( 0, 157 ) + "..." : text;
}
- private Set<String> getRecipientsPhoneNumber( Set<User> users )
+ private Set<String> getRecipientsPhoneNumber( List<User> users )
{
Set<String> recipients = new HashSet<String>();
=== 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 2013-08-29 17:04:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java 2013-09-05 06:05:43 +0000
@@ -100,11 +100,21 @@
if ( gatewayId != null && !gatewayId.trim().isEmpty() )
{
- for ( User user : users )
+ if( !forceSend )
{
- if ( currentUserService.getCurrentUser() != null )
+ for ( User user : users )
{
- if ( !currentUserService.getCurrentUser().equals( user ) )
+ if ( currentUserService.getCurrentUser() != null )
+ {
+ if ( !currentUserService.getCurrentUser().equals( user ) )
+ {
+ if ( isQualifiedReceiver( user ) )
+ {
+ toSendList.add( user );
+ }
+ }
+ }
+ else if ( currentUserService.getCurrentUser() == null )
{
if ( isQualifiedReceiver( user ) )
{
@@ -112,13 +122,10 @@
}
}
}
- else if ( currentUserService.getCurrentUser() == null )
- {
- if ( isQualifiedReceiver( user ) )
- {
- toSendList.add( user );
- }
- }
+ }
+ else
+ {
+ toSendList.addAll( users );
}
Set<String> phoneNumbers = null;
=== modified file 'dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java'
--- dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java 2013-09-04 14:04:01 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/outcoming/ProcessingSendSMSAction.java 2013-09-05 06:05:43 +0000
@@ -28,16 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.sms.SmsMessageSender;
+import org.hisp.dhis.sms.SmsSender;
import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
@@ -69,19 +69,16 @@
private CurrentUserService currentUserService;
@Autowired
- private PatientService patientService;
-
- @Autowired
private UserGroupService userGroupService;
@Autowired
private OutboundSmsTransportService transportService;
- private SmsMessageSender smsMessageSender;
+ private SmsSender smsSender;
- public void setSmsMessageSender( SmsMessageSender smsMessageSender )
+ public void setSmsSender( SmsSender smsSender )
{
- this.smsMessageSender = smsMessageSender;
+ this.smsSender = smsSender;
}
// -------------------------------------------------------------------------
@@ -174,7 +171,9 @@
User currentUser = currentUserService.getCurrentUser();
- Set<User> recipientsList = new HashSet<User>();
+ List<User> recipientsList = new ArrayList<User>();
+
+ // Set<User> recipientsList = new HashSet<User>();
if ( sendTarget != null && sendTarget.equals( "phone" ) )
{
@@ -196,7 +195,7 @@
}
// message = messageSender.sendMessage( smsSubject, smsMessage,
// currentUser, true, recipients, gatewayId );
- message = smsMessageSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
+ message = smsSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
}
else if ( sendTarget.equals( "userGroup" ) )
{
@@ -216,9 +215,11 @@
return ERROR;
}
+
// message = messageSender.sendMessage( smsSubject, smsMessage,
// currentUser, false, group.getMembers(), gatewayId );
- message = smsMessageSender.sendMessage( smsSubject, text, currentUser, group.getMembers(), false );
+ message = smsSender.sendMessage( smsSubject, text, currentUser, new ArrayList<User>( group.getMembers() ),
+ false );
}
else if ( sendTarget.equals( "user" ) )
{
@@ -240,7 +241,7 @@
// message = messageSender.sendMessage( smsSubject, smsMessage,
// currentUser, false, users, gatewayId );
- message = smsMessageSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
+ message = smsSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
}
}
else if ( sendTarget.equals( "unit" ) )
@@ -262,7 +263,7 @@
return ERROR;
}
- message = smsMessageSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
+ message = smsSender.sendMessage( smsSubject, text, currentUser, recipientsList, false );
}
=== modified file 'dhis-2/dhis-web/dhis-web-sms/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-sms/src/main/resources/META-INF/dhis/beans.xml 2013-08-22 08:03:53 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/resources/META-INF/dhis/beans.xml 2013-09-05 06:05:43 +0000
@@ -17,7 +17,7 @@
<bean id="org.hisp.dhis.sms.outcoming.ProcessingSendSMSAction"
class="org.hisp.dhis.sms.outcoming.ProcessingSendSMSAction" scope="prototype">
- <property name="smsMessageSender" ref="org.hisp.dhis.sms.SmsMessageSender" />
+ <property name="smsSender" ref="org.hisp.dhis.sms.SmsSender" />
</bean>
<bean id="org.hisp.dhis.sms.outcoming.SearchPatientAction" class="org.hisp.dhis.sms.outcoming.SearchPatientAction"