dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18964
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8085: Auto-sending SMS (WIP).
------------------------------------------------------------
revno: 8085
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-09-14 16:41:13 +0700
message:
Auto-sending SMS (WIP).
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.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-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java 2012-09-14 09:11:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java 2012-09-14 09:41:13 +0000
@@ -97,9 +97,9 @@
// Params
// -------------------------------------------------------------------------
- private boolean sendingMessage;
+ private Boolean sendingMessage;
- public void setSendingMessage( boolean sendingMessage )
+ public void setSendingMessage( Boolean sendingMessage )
{
this.sendingMessage = sendingMessage;
}
@@ -115,50 +115,57 @@
if ( gatewayId != null )
{
- Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
- .getSendMesssageEvents();
-
if ( sendingMessage )
{
- for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
- {
- String message = schedulingProgramObject.getMessage();
-
- String phoneNumber = schedulingProgramObject.getPhoneNumber();
-
- if ( phoneNumber != null && !phoneNumber.isEmpty() )
- {
- try
- {
- OutboundSms outboundSms = new OutboundSms( message, phoneNumber );
- outboundSms.setSender( DHIS_SYSTEM_SENDER );
- outboundSmsService.saveOutboundSms( outboundSms );
-
- String sql = "INSERT INTO programstageinstance_outboundsms"
- + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
- + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId()
- + ",1) ";
-
- jdbcTemplate.execute( sql );
- }
- catch ( SmsServiceException e )
- {
- message = e.getMessage();
- }
- }
- }
+ sendMessage( gatewayId );
}
else
{
-
- List<OutboundSms> outboundSmsList = outboundSmsService.getOutboundSms( OutboundSmsStatus.OUTBOUND );
- for ( OutboundSms outboundSms : outboundSmsList )
- {
- outboundSms.setStatus( OutboundSmsStatus.SENT );
- outboundSmsService.sendMessage( outboundSms, gatewayId );
- }
- }
- }
-
+ scheduleMessage();
+ }
+ }
+ }
+
+ private void scheduleMessage()
+ {
+ Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
+ .getSendMesssageEvents();
+
+ for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
+ {
+ String message = schedulingProgramObject.getMessage();
+
+ String phoneNumber = schedulingProgramObject.getPhoneNumber();
+
+ if ( phoneNumber != null && !phoneNumber.isEmpty() )
+ {
+ try
+ {
+ OutboundSms outboundSms = new OutboundSms( message, phoneNumber );
+ outboundSms.setSender( DHIS_SYSTEM_SENDER );
+ outboundSmsService.saveOutboundSms( outboundSms );
+
+ String sql = "INSERT INTO programstageinstance_outboundsms"
+ + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
+ + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ",1) ";
+
+ jdbcTemplate.execute( sql );
+ }
+ catch ( SmsServiceException e )
+ {
+ message = e.getMessage();
+ }
+ }
+ }
+ }
+
+ private void sendMessage( String gatewayId )
+ {
+ List<OutboundSms> outboundSmsList = outboundSmsService.getOutboundSms( OutboundSmsStatus.OUTBOUND );
+ for ( OutboundSms outboundSms : outboundSmsList )
+ {
+ outboundSms.setStatus( OutboundSmsStatus.SENT );
+ outboundSmsService.sendMessage( outboundSms, gatewayId );
+ }
}
}