dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18963
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8084: Auto-send SMS (WIP).
------------------------------------------------------------
revno: 8084
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-09-14 16:11:26 +0700
message:
Auto-send SMS (WIP).
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.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 08:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java 2012-09-14 09:11:26 +0000
@@ -155,7 +155,7 @@
for ( OutboundSms outboundSms : outboundSmsList )
{
outboundSms.setStatus( OutboundSmsStatus.SENT );
- outboundSmsService.sendMessage( outboundSms, gatewayId );
+ outboundSmsService.sendMessage( outboundSms, gatewayId );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java 2012-09-14 09:11:26 +0000
@@ -90,10 +90,23 @@
}
@Override
- @SuppressWarnings( "unchecked" )
public List<OutboundSms> get( OutboundSmsStatus status )
{
- String sql = "select id from outbound_sms where status = 1";
+ int realStatus = 0;
+
+ if(status.equals( OutboundSmsStatus.OUTBOUND )){
+ realStatus = OutboundSmsStatus.OUTBOUND.ordinal();
+ }
+ else if(status.equals( OutboundSmsStatus.SENT )){
+ realStatus = OutboundSmsStatus.SENT.ordinal();
+ }
+ else{
+ realStatus = OutboundSmsStatus.ERROR.ordinal();
+ }
+
+ String sql = "select osm.id as outboundsmsid, message, ore.elt as phonenumber "
+ + "from outbound_sms osm inner join outbound_sms_recipients ore "
+ + "on osm.id=ore.outbound_sms_id where status = " + realStatus ;
try
{
@@ -102,7 +115,9 @@
public OutboundSms mapRow( ResultSet rs, int rowNum )
throws SQLException
{
- return get(rs.getInt( 1 ));
+ OutboundSms outboundSms = new OutboundSms( rs.getString( 2 ), rs.getString( 3 ) );
+ outboundSms.setId( rs.getInt( 1 ) );
+ return outboundSms;
}
} );
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-09-14 09:11:26 +0000
@@ -100,16 +100,7 @@
{
throw new SmsServiceNotEnabledException();
}
-
- if ( sms.getId() == 0 )
- {
- outboundSmsStore.save( sms );
- }
- else
- {
- outboundSmsStore.update( sms );
- }
-
+
if ( transportService != null )
{
return sendMessageInternal( sms, gatewayId );
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-09-14 09:11:26 +0000
@@ -199,7 +199,14 @@
sms.setStatus( OutboundSmsStatus.ERROR );
}
- this.saveOutboundSms( sms );
+ if ( sms.getId() == 0 )
+ {
+ outboundSmsStore.save( sms );
+ }
+ else
+ {
+ outboundSmsStore.update( sms );
+ }
return message;
}