← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8311: Minor fix for auto sending sms.

 

------------------------------------------------------------
revno: 8311
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-01 11:09:27 +0700
message:
  Minor fix for auto sending sms.
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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/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-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-25 06:44:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java	2012-10-01 04:09:27 +0000
@@ -73,8 +73,8 @@
     // Constructors
     // -------------------------------------------------------------------------
 
-    public SendScheduledMessageTask( ProgramStageInstanceService programStageInstanceService, JdbcTemplate jdbcTemplate,
-        OutboundSmsService outboundSmsService )
+    public SendScheduledMessageTask( ProgramStageInstanceService programStageInstanceService,
+        JdbcTemplate jdbcTemplate, OutboundSmsService outboundSmsService )
     {
         this.programStageInstanceService = programStageInstanceService;
         this.jdbcTemplate = jdbcTemplate;
@@ -122,27 +122,22 @@
         {
             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() + ","
-                        + (System.currentTimeMillis() / 1000) + ") ";
-
-                    jdbcTemplate.execute( sql );
-                }
-                catch ( SmsServiceException e )
-                {
-                    message = e.getMessage();
-                }
+            try
+            {
+                OutboundSms outboundSms = new OutboundSms( message, schedulingProgramObject.getPhoneNumber() );
+                outboundSms.setSender( DHIS_SYSTEM_SENDER );
+                outboundSmsService.saveOutboundSms( outboundSms );
+
+                String sql = "INSERT INTO programstageinstance_outboundsms"
+                    + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
+                    + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
+                    + (System.currentTimeMillis() / 1000) + ") ";
+
+                jdbcTemplate.execute( sql );
+            }
+            catch ( SmsServiceException e )
+            {
+                message = e.getMessage();
             }
         }
     }
@@ -150,6 +145,7 @@
     private void sendMessage()
     {
         List<OutboundSms> outboundSmsList = outboundSmsService.getOutboundSms( OutboundSmsStatus.OUTBOUND );
+
         for ( OutboundSms outboundSms : outboundSmsList )
         {
             outboundSms.setStatus( OutboundSmsStatus.SENT );

=== 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 09:11:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/HibernateOutboundSmsStore.java	2012-10-01 04:09:27 +0000
@@ -107,7 +107,7 @@
         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
         {
             List<OutboundSms> OutboundSmsList = jdbcTemplate.query( sql, new RowMapper<OutboundSms>()

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java	2012-06-13 03:59:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java	2012-10-01 04:09:27 +0000
@@ -28,13 +28,11 @@
 package org.hisp.dhis.patient.action.programstage;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.comparator.ProgramStageOrderComparator;
 
 import com.opensymphony.xwork2.Action;
 
@@ -102,8 +100,6 @@
 
         associations = new ArrayList<ProgramStage>( program.getProgramStages() );
 
-        Collections.sort( associations, new ProgramStageOrderComparator() );
-
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java	2012-09-25 06:44:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java	2012-10-01 04:09:27 +0000
@@ -33,7 +33,6 @@
 
 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;
@@ -53,13 +52,6 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SystemSettingManager systemSettingManager;
-
-    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
-    {
-        this.systemSettingManager = systemSettingManager;
-    }
-
     private ProgramStageInstanceService programStageInstanceService;
 
     public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
@@ -95,28 +87,24 @@
         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.sendMessage( outboundSms, null );
-
-                    String sql = "INSERT INTO programstageinstance_outboundsms"
-                        + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
-                        + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
-                        + (System.currentTimeMillis() / 1000) + ") ";
-
-                    jdbcTemplate.execute( sql );
-                }
-                catch ( SmsServiceException e )
-                {
-                    message = e.getMessage();
-                }
+            
+            try
+            {
+                OutboundSms outboundSms = new OutboundSms( message, phoneNumber );
+                outboundSms.setSender( DHIS_SYSTEM_SENDER );
+                outboundSmsService.sendMessage( outboundSms, null );
+
+                String sql = "INSERT INTO programstageinstance_outboundsms"
+                    + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
+                    + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
+                    + (System.currentTimeMillis() / 1000) + ") ";
+
+                jdbcTemplate.execute( sql );
+            }
+            catch ( SmsServiceException e )
+            {
+                message = e.getMessage();
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-25 09:51:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-10-01 04:09:27 +0000
@@ -895,7 +895,6 @@
  	<bean id="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
 		class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
 		scope="prototype">
-		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
 		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 		<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />