← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8030: Automatic SMS reminder (Done).

 

------------------------------------------------------------
revno: 8030
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-09-11 11:54:34 +0700
message:
  Automatic SMS reminder (Done).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/SchedulingProgramObject.java
  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/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties


--
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/program/SchedulingProgramObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/SchedulingProgramObject.java	2012-09-10 10:28:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/SchedulingProgramObject.java	2012-09-11 04:54:34 +0000
@@ -36,7 +36,7 @@
 {
     private String phoneNumber;
 
-    private ProgramStageInstance programStageInstance;
+    private Integer programStageInstanceId;
 
     private String message;
 
@@ -45,10 +45,10 @@
 
     }
 
-    public SchedulingProgramObject( String phonenumber, ProgramStageInstance programStageInstance, String message )
+    public SchedulingProgramObject( String phonenumber, Integer programStageInstanceId, String message )
     {
         this.phoneNumber = phonenumber;
-        this.programStageInstance = programStageInstance;
+        this.programStageInstanceId = programStageInstanceId;
         this.message = message;
     }
 
@@ -62,14 +62,14 @@
         this.phoneNumber = phoneNumber;
     }
 
-    public ProgramStageInstance getProgramStageInstance()
+    public Integer getProgramStageInstanceId()
     {
-        return programStageInstance;
+        return programStageInstanceId;
     }
 
-    public void setProgramStageInstance( ProgramStageInstance programStageInstance )
+    public void setProgramStageInstanceId( Integer programStageInstanceId )
     {
-        this.programStageInstance = programStageInstance;
+        this.programStageInstanceId = programStageInstanceId;
     }
 
     public String getMessage()

=== 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-11 03:54:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java	2012-09-11 04:54:34 +0000
@@ -31,13 +31,13 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.SchedulingProgramObject;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.sms.SmsServiceException;
 import org.hisp.dhis.sms.outbound.OutboundSms;
 import org.hisp.dhis.sms.outbound.OutboundSmsService;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
  * @author Chau Thu Tran
@@ -60,28 +60,32 @@
     {
         this.programStageInstanceService = programStageInstanceService;
     }
+    
+    private JdbcTemplate jdbcTemplate;
 
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+    
     private OutboundSmsService outboundSmsService;
 
     public void setOutboundSmsService( OutboundSmsService outboundSmsService )
     {
         this.outboundSmsService = outboundSmsService;
     }
-
+    
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
-    public SendScheduledMessageTask()
-    {
-    }
-    
     public SendScheduledMessageTask( SystemSettingManager systemSettingManager,
-        ProgramStageInstanceService programStageInstanceService, OutboundSmsService outboundSmsService )
+        ProgramStageInstanceService programStageInstanceService, OutboundSmsService outboundSmsService,JdbcTemplate jdbcTemplate )
     {
         this.systemSettingManager = systemSettingManager;
         this.programStageInstanceService = programStageInstanceService;
         this.outboundSmsService = outboundSmsService;
+        this.jdbcTemplate = jdbcTemplate;
     }
 
     // -------------------------------------------------------------------------
@@ -101,27 +105,21 @@
             for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
             {
                 String message = schedulingProgramObject.getMessage();
-                 
+
                 String phoneNumber = schedulingProgramObject.getPhoneNumber();
                 
-                ProgramStageInstance programStageInstance = schedulingProgramObject.getProgramStageInstance();
-                
                 if ( phoneNumber != null && !phoneNumber.isEmpty() )
                 {
                     try
                     {
                         OutboundSms outboundSms = new OutboundSms( message, phoneNumber );
                         outboundSmsService.sendMessage( outboundSms, gatewayId );
-                        System.out.println("\n\n === \n outboundSms : " + outboundSms.getId() );
-
-//                        List<OutboundSms> outboundSmsList = programStageInstance.getOutboundSms();
-//                        if ( outboundSmsList == null )
-//                        {
-//                            outboundSmsList = new ArrayList<OutboundSms>();
-//                        }
-//                        outboundSmsList.add( outboundSms );
-//                        programStageInstance.setOutboundSms( outboundSmsList );
-//                        programStageInstanceService.updateProgramStageInstance( programStageInstance );
+                        
+                        String sql = " INSERT INTO programstageinstance_outboundsms"
+                            + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
+                            + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ",1) ";
+                        
+                       jdbcTemplate.execute( sql );
                     }
                     catch ( SmsServiceException e )
                     {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-09-11 03:54:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-09-11 04:54:34 +0000
@@ -319,7 +319,7 @@
             }
 
             SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
-            schedulingProgramObject.setProgramStageInstance( get(rs.getInt( "programstageinstanceid" )) );
+            schedulingProgramObject.setProgramStageInstanceId(rs.getInt( "programstageinstanceid" ) );
             schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
             schedulingProgramObject.setMessage( message );
             

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-10 10:28:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-11 04:54:34 +0000
@@ -405,6 +405,7 @@
  		<constructor-arg ref="org.hisp.dhis.program.ProgramStageInstanceService" />
  		<constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
  		<constructor-arg ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+ 		<constructor-arg ref="jdbcTemplate" />
  	</bean>
  	
  	<bean id="sendMessageScheduled" class="org.hisp.dhis.patient.scheduling.SendScheduledMessageTask" parent="sendMessageScheduledTasks">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-09-11 03:54:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-09-11 04:54:34 +0000
@@ -281,6 +281,7 @@
 days_since_due_date = Days since due date
 scheduling = Scheduling
 schedule_sending_message = Schedule sending message
+intro_schedule_sending_message = schedule sending message for persons
 schedule = Schedule
 start = Start
 stop = Stop