← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8251: Remove the option for selecting gateway in auto-send SMS function.

 

------------------------------------------------------------
revno: 8251
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-09-25 13:44:53 +0700
message:
  Remove the option for selecting gateway in auto-send SMS function.
renamed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetGatewayAction.java => dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.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/resources/META-INF/dhis/beans.xml
  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/ScheduleSendMessageTasksAction.java
  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/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.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-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-09-24 15:52:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-09-25 06:44:53 +0000
@@ -72,7 +72,6 @@
     final String KEY_TIME_FOR_SENDING_MESSAGE = "timeSendingMessage";
     final String KEY_SEND_MESSAGE_SCHEDULED_TASKS = "sendMessageScheduled";
     final String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
-    final String KEY_SEND_MESSAGE_GATEWAY = "keySendMessageGateway";
     final String PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
 
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;

=== 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-17 03:32:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java	2012-09-25 06:44:53 +0000
@@ -27,7 +27,6 @@
 
 package org.hisp.dhis.patient.scheduling;
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_GATEWAY;
 import static org.hisp.dhis.sms.outbound.OutboundSms.DHIS_SYSTEM_SENDER;
 
 import java.util.Collection;
@@ -35,7 +34,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;
@@ -49,14 +47,7 @@
  */
 public class SendScheduledMessageTask
     implements Runnable
-{   
-    private SystemSettingManager systemSettingManager;
-
-    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
-    {
-        this.systemSettingManager = systemSettingManager;
-    }
-
+{
     private ProgramStageInstanceService programStageInstanceService;
 
     public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
@@ -82,11 +73,9 @@
     // Constructors
     // -------------------------------------------------------------------------
 
-    public SendScheduledMessageTask( SystemSettingManager systemSettingManager,
-        ProgramStageInstanceService programStageInstanceService, JdbcTemplate jdbcTemplate,
+    public SendScheduledMessageTask( ProgramStageInstanceService programStageInstanceService, JdbcTemplate jdbcTemplate,
         OutboundSmsService outboundSmsService )
     {
-        this.systemSettingManager = systemSettingManager;
         this.programStageInstanceService = programStageInstanceService;
         this.jdbcTemplate = jdbcTemplate;
         this.outboundSmsService = outboundSmsService;
@@ -110,26 +99,25 @@
     @Override
     public void run()
     {
-        String gatewayId = (String) systemSettingManager.getSystemSetting( KEY_SEND_MESSAGE_GATEWAY );
-
-        if ( gatewayId != null )
-        {
-            if ( sendingMessage )
-            {
-                sendMessage( gatewayId );
-            }
-            else
-            {
-                scheduleMessage();
-            }
+        if ( sendingMessage )
+        {
+            sendMessage();
+        }
+        else
+        {
+            scheduleMessage();
         }
     }
 
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
     private void scheduleMessage()
     {
         Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
             .getSendMesssageEvents();
-        
+
         for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
         {
             String message = schedulingProgramObject.getMessage();
@@ -146,7 +134,8 @@
 
                     String sql = "INSERT INTO programstageinstance_outboundsms"
                         + "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
-                        + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + "," + ( System.currentTimeMillis() / 1000 ) + ") ";
+                        + schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
+                        + (System.currentTimeMillis() / 1000) + ") ";
 
                     jdbcTemplate.execute( sql );
                 }
@@ -158,13 +147,13 @@
         }
     }
 
-    private void sendMessage( String gatewayId )
-    {    
+    private void sendMessage()
+    {
         List<OutboundSms> outboundSmsList = outboundSmsService.getOutboundSms( OutboundSmsStatus.OUTBOUND );
         for ( OutboundSms outboundSms : outboundSmsList )
         {
             outboundSms.setStatus( OutboundSmsStatus.SENT );
-            outboundSmsService.sendMessage( outboundSms, gatewayId );
+            outboundSmsService.sendMessage( outboundSms, null );
         }
     }
 }

=== 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-14 10:05:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-25 06:44:53 +0000
@@ -379,7 +379,6 @@
   
  	<bean id="abstractScheduledMessageTask" class="org.hisp.dhis.patient.scheduling.SendScheduledMessageTask" >
  		<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>

=== 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-17 03:32:13 +0000
+++ 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
@@ -27,7 +27,6 @@
 
 package org.hisp.dhis.patient.action.schedule;
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_GATEWAY;
 import static org.hisp.dhis.sms.outbound.OutboundSms.DHIS_SYSTEM_SENDER;
 
 import java.util.Collection;
@@ -89,42 +88,39 @@
     @Override
     public String execute()
     {
-        String gatewayId = (String) systemSettingManager.getSystemSetting( KEY_SEND_MESSAGE_GATEWAY );
-
-        if ( gatewayId != null )
+
+        Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
+            .getSendMesssageEvents();
+
+        for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
         {
-            Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
-                .getSendMesssageEvents();
-
-            for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
+            String message = schedulingProgramObject.getMessage();
+
+            String phoneNumber = schedulingProgramObject.getPhoneNumber();
+
+            if ( phoneNumber != null && !phoneNumber.isEmpty() )
             {
-                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, gatewayId );
-
-                        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();
                 }
             }
         }
-        
+
         return SUCCESS;
     }
-    
+
 }

=== renamed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetGatewayAction.java' => 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetGatewayAction.java	2012-09-11 01:58:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java	2012-09-25 06:44:53 +0000
@@ -27,10 +27,8 @@
 
 package org.hisp.dhis.patient.action.schedule;
 
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_TIME_FOR_SENDING_MESSAGE;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_TIME_FOR_SENDING_MESSAGE;
-import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_TIME_FOR_SENDING_MESSAGE;
-
-import java.util.Map;
 
 import org.hisp.dhis.patient.scheduling.ProgramSchedulingManager;
 import org.hisp.dhis.setting.SystemSettingManager;
@@ -43,9 +41,9 @@
 /**
  * @author Chau Thu Tran
  * 
- * @version GetGatewayAction.java 10:57:08 AM Aug 9, 2012 $
+ * @version GetScheduleParamsAction.java 10:57:08 AM Aug 9, 2012 $
  */
-public class GetGatewayAction
+public class GetScheduleParamsAction
     implements Action
 {
     // -------------------------------------------------------------------------
@@ -80,13 +78,6 @@
         return timeSendingMessage;
     }
 
-    public Map<String, String> gatewayMap;
-
-    public Map<String, String> getGatewayMap()
-    {
-        return gatewayMap;
-    }
-
     private String status;
 
     public String getStatus()
@@ -111,8 +102,6 @@
     {
         timeSendingMessage = (String)systemSettingManager.getSystemSetting( KEY_TIME_FOR_SENDING_MESSAGE, DEFAULT_TIME_FOR_SENDING_MESSAGE );
         
-        gatewayMap = transportService.getGatewayMap();
-
         status = schedulingManager.getTaskStatus();
         running = Scheduler.STATUS_RUNNING.equals( status );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java	2012-09-14 08:13:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java	2012-09-25 06:44:53 +0000
@@ -28,10 +28,9 @@
 package org.hisp.dhis.patient.action.schedule;
 
 import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_TIME_FOR_SENDING_MESSAGE;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_GATEWAY;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_MESSAGE_TASKS;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_SCHEDULED_TASKS;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_TIME_FOR_SENDING_MESSAGE;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_SCHEDULED_TASKS;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_MESSAGE_TASKS;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -85,14 +84,7 @@
     {
         this.schedule = schedule;
     }
-
-    private String gateWayId;
-
-    public void setGateWayId( String gateWayId )
-    {
-        this.gateWayId = gateWayId;
-    }
-
+    
     private String timeSendingMessage;
 
     public void setTimeSendingMessage( String timeSendingMessage )
@@ -125,8 +117,7 @@
     public String execute()
     {
         systemSettingManager.saveSystemSetting( KEY_TIME_FOR_SENDING_MESSAGE, timeSendingMessage );
-        systemSettingManager.saveSystemSetting( KEY_SEND_MESSAGE_GATEWAY, gateWayId );
-
+        
         if ( execute )
         {
             schedulingManager.executeTasks();

=== 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-17 03:32:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-09-25 06:44:53 +0000
@@ -883,8 +883,8 @@
 	
 	<!-- Scheduling -->
 	
-	<bean id="org.hisp.dhis.patient.action.schedule.GetGatewayAction"
-		class="org.hisp.dhis.patient.action.schedule.GetGatewayAction"
+	<bean id="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
+		class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
 		scope="prototype">
 		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
 		<property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-09-17 06:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-09-25 06:44:53 +0000
@@ -928,7 +928,7 @@
 		
 		<!-- Scheduling -->
 		
-		<action name="viewScheduleTasks" class="org.hisp.dhis.patient.action.schedule.GetGatewayAction">
+		<action name="viewScheduleTasks" class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction">
 	      <result name="success" type="velocity">/main.vm</result>
 	      <param name="page">/dhis-web-maintenance-patient/scheduleSendMessage.vm</param>
 	      <param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
@@ -945,7 +945,7 @@
 	    
 	    <action name="executeSendMessage" class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction">
 	      <result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-maintenance-patient/ajax/jsonResponseScheduleTasks.vm</result>
 	      <param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
 	    </action>
 		

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm	2012-09-11 03:54:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm	2012-09-25 06:44:53 +0000
@@ -7,18 +7,6 @@
 				<input type="text" id="timeSendingMessage" name="timeSendingMessage" value="$!timeSendingMessage" style="width:295px;"/>
 			</td>
 		</tr>
-
-		<tr>
-			<td>$i18n.getString( "gateway_type" )</td>
-			<td>
-				#set( $keys = $!gatewayMap.keySet() )
-				<select id="gatewayId" name="gatewayId" style="width:300px;">
-					#foreach( $key in $!keys )
-					<option value="$gatewayMap.get( $key )" >$i18n.getString( $key )</option>
-					#end
-				</select>
-			</td>
-		</tr>
 		
 		<tr>
 			<td></td>