← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6326: (mobile) Fixed sending SMS problem.

 

------------------------------------------------------------
revno: 6326
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-21 15:24:25 +0700
message:
  (mobile) Fixed sending SMS problem.
modified:
  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/SmsMessageSender.java
  dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm


--
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-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-03-09 09:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java	2012-03-21 08:24:25 +0000
@@ -51,6 +51,7 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private OutboundSmsStore outboundSmsStore;
 
     public void setOutboundSmsStore( OutboundSmsStore outboundSmsStore )

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java	2012-03-21 08:24:25 +0000
@@ -68,7 +68,7 @@
     // MessageSender implementation
     // -------------------------------------------------------------------------
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public void sendMessage( String subject, String text, User sender, boolean isPhone, Set<?> recipients,
         String gatewayId )
     {
@@ -136,7 +136,16 @@
             name = sender.getUsername();
         }
 
-        text = "From " + name + " - " + subject + ": " + text;
+        if ( subject == null || subject.isEmpty() )
+        {
+            subject = "";
+        }
+        else
+        {
+            subject = " - " + subject;
+        }
+
+        text = "From " + name + subject + ": " + text;
 
         // Simplistic cutoff 160 characters..
         int length = text.length();

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2012-01-05 20:39:23 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/resources/META-INF/dhis/beans.xml	2012-03-21 08:24:25 +0000
@@ -8,16 +8,16 @@
   
   <!-- Outbound SMS service -->
 
+  <bean id="outboundSmsStore" class="org.hisp.dhis.sms.outbound.HibernateOutboundSmsStore">
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+  
   <bean id="org.hisp.dhis.sms.outbound.OutboundSmsService" class="org.hisp.dhis.sms.outbound.OutboundSmsServiceImpl" />
-
-  <bean id="OutboundSmsStore" class="org.hisp.dhis.sms.outbound.HibernateOutboundSmsStore">
-    <property name="sessionFactory" ref="sessionFactory" />
-  </bean>
   
-  <!--  Only for testing! OutboundSmsService stub just logging invocations, replacing the deafult one or use as the OutboundSmsTransportService..  -->
+  <!--  Only for testing! OutboundSmsService stub just logging invocations, replacing the default one or use as the OutboundSmsTransportService..  -->
   <!--  <bean id="TestOutboundSmsService" class="org.hisp.dhis.sms.outbound.TestOutboundSmsService" /> -->
 
-  <bean id="SmsLibService" class="org.hisp.dhis.sms.smslib.SmsLibService" />
+  <bean id="smsLibService" class="org.hisp.dhis.sms.smslib.SmsLibService" />
 
   <!--  SMS Message sender -->
 
@@ -26,5 +26,4 @@
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>
 
-
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm	2012-03-21 02:20:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm	2012-03-21 08:24:25 +0000
@@ -20,8 +20,7 @@
 </style>
 
 <h3>Send SMS</h3>
-#if ( $smsServiceStatus )
-
+#if ( !$smsServiceStatus )
 <form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
 	<table id="detailsList">
 	    <col width="300px"/>
@@ -33,10 +32,10 @@
 			<tr>
 				<td><label for="type">$i18n.getString( "type" ):</label></td>
 				<td>
-				#set( $keys = $!gatewayMap.keySet() )
+				#set( $keys = $gatewayMap.keySet() )
 					<select id="gatewayId" name="gatewayId" style="width: 100%;">
-						#foreach( $key in $!keys )
-						<option value="$!gatewayMap.get( $key )">$i18n.getString( $key )</option>
+						#foreach( $key in $keys )
+						<option value="$gatewayMap.get( $key )">$i18n.getString( $key )</option>
 						#end
 					</select>
 				</td>
@@ -48,7 +47,7 @@
 			</tr>
 			
 			<tr><th colspan="2">$i18n.getString( "message" )</th></tr>
-			<tr><td colspan="2"><textarea name="smsMessage" cols="95" rows="10"></textarea></td></tr>
+			<tr><td colspan="2"><textarea id="smsMessage" name="smsMessage" cols="95" rows="10" class="{validate:{required:true}}"></textarea></td></tr>
 		</tbody>
 	</table>
 
@@ -57,7 +56,7 @@
 		<col width="80px"/>
 		<tbody id="phoneType">
 			<tr><th colspan="2">$i18n.getString( "phone" ):</th></tr>
-			<tr><td colspan="2"><input type="text" name="recipient" style="width:520px" /></td></tr>
+			<tr><td colspan="2"><input type="text" id="recipient" name="recipient" style="width:520px" /></td></tr>
 		</tbody>
 	
 		<tbody id="orgunitType" style="display:none">
@@ -100,7 +99,7 @@
 		if ( !isChecked )
 		{
 			var list = getFieldValue( "recipient" ).split( ";" )
-			
+
 			for ( var i in list ) {
 				params += "recipients=" + list[i] + "&";
 			}
@@ -108,7 +107,10 @@
 			params = "?" + params.substring( 0, params.length - 1 );
 		}
 
-		jQuery.postUTF8( _form.action + params, {}, function ( json )
+		jQuery.postUTF8( _form.action + params,
+		{
+			smsMessage: getFieldValue( 'smsMessage' )
+		}, function ( json )
 		{
 			if ( json.response == "success" ) {
 				showSuccessMessage( json.message );