← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6264: (mobile) Sending SMS Message GUI - Done.

 

------------------------------------------------------------
revno: 6264
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-14 17:36:55 +0700
message:
  (mobile) Sending SMS Message GUI - Done.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/MobileHomePageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSFormAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm
  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/smsServiceConfiguration.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-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java	2012-03-14 10:36:55 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.sms.outbound;
 
+import java.util.Map;
+
 /*
  * Copyright (c) 2004-2011, University of Oslo
  * All rights reserved.
@@ -34,4 +36,5 @@
 public interface OutboundSmsTransportService
     extends OutboundSmsService
 {
+    Map<String, String> getGatewayMap();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java	2012-03-14 10:36:55 +0000
@@ -1,5 +1,8 @@
 package org.hisp.dhis.sms.outbound;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.sms.SmsServiceException;
@@ -10,9 +13,12 @@
 import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
 
 /**
- * Simple {@link OutboundSmsService} just logging invocations, only to be used for test purposes
+ * Simple {@link OutboundSmsService} just logging invocations, only to be used
+ * for test purposes
  * 
- * <p>Has the property enabled, defaulting to true, which is configured using {@link TestOutboundSmsService#initialize(SmsConfiguration)}
+ * <p>
+ * Has the property enabled, defaulting to true, which is configured using
+ * {@link TestOutboundSmsService#initialize(SmsConfiguration)}
  */
 public class TestOutboundSmsService
     implements OutboundSmsTransportService
@@ -25,14 +31,16 @@
     public void sendMessage( OutboundSms sms, String gatewayId )
         throws SmsServiceException
     {
-        if (!enabled)
+        if ( !enabled )
+        {
             throw new SmsServiceNotEnabledException();
-            
+        }
+
         log.debug( "Send message: " + sms );
     }
 
     @Override
-    public void initialize(SmsConfiguration config)
+    public void initialize( SmsConfiguration config )
         throws SmsServiceException
     {
         this.enabled = config.isEnabled();
@@ -45,4 +53,9 @@
         return this.enabled;
     }
 
+    @Override
+    public Map<String, String> getGatewayMap()
+    {
+        return new HashMap<String, String>();
+    }
 }

=== 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-03-09 09:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java	2012-03-14 10:36:55 +0000
@@ -28,11 +28,16 @@
  */
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.sms.SmsServiceException;
+import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
+import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
+import org.hisp.dhis.sms.config.GenericHttpGatewayConfig;
 import org.hisp.dhis.sms.config.SmsConfiguration;
 import org.hisp.dhis.sms.config.SmsGatewayConfig;
 import org.hisp.dhis.sms.outbound.OutboundSms;
@@ -50,10 +55,24 @@
 {
     private static final Log log = LogFactory.getLog( SmsLibService.class );
 
+    private Map<String, String> gatewayMap = new HashMap<String, String>();
+
     private GateWayFactory gatewayFactory = new GateWayFactory();
 
     private SmsConfiguration config;
 
+    private final String BULK_GATEWAY = "bulk_gw";
+
+    private final String CLICKATELL_GATEWAY = "clickatell_gw";
+
+    private final String HTTP_GATEWAY = "generic_http_gw";
+
+    private final String MODEM_GATEWAY = "modem_gateway";
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+
     @Override
     public boolean isEnabled()
     {
@@ -67,7 +86,7 @@
         String recipient;
 
         Set<String> recipients = sms.getRecipients();
-        
+
         if ( recipients.size() == 0 )
         {
             log.warn( "Trying to send sms without recipients: " + sms );
@@ -252,12 +271,34 @@
 
         service.getGateways().clear();
 
+        AGateway gateway = null;
+
         // Add gateways
         for ( SmsGatewayConfig gatewayConfig : config.getGateways() )
         {
             try
             {
-                service.addGateway( gatewayFactory.create( gatewayConfig ) );
+                gateway = gatewayFactory.create( gatewayConfig );
+
+                service.addGateway( gateway );
+
+                if ( gatewayConfig instanceof BulkSmsGatewayConfig )
+                {
+                    gatewayMap.put( BULK_GATEWAY, gateway.getGatewayId() );
+                }
+                else if ( gatewayConfig instanceof ClickatellGatewayConfig )
+                {
+                    gatewayMap.put( CLICKATELL_GATEWAY, gateway.getGatewayId() );
+                }
+                else if ( gatewayConfig instanceof GenericHttpGatewayConfig )
+                {
+                    gatewayMap.put( HTTP_GATEWAY, gateway.getGatewayId() );
+                }
+                else
+                {
+                    gatewayMap.put( MODEM_GATEWAY, gateway.getGatewayId() );
+                }
+
                 log.debug( "Added gateway " + gatewayConfig.getName() );
             }
             catch ( GatewayException e )
@@ -278,4 +319,15 @@
         }
     }
 
+    @Override
+    public Map<String, String> getGatewayMap()
+    {
+        if ( gatewayMap == null || gatewayMap.isEmpty() )
+        {
+            reloadConfig();
+        }
+        
+        return gatewayMap;
+    }
+
 }

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java	2012-03-14 10:36:55 +0000
@@ -0,0 +1,78 @@
+package org.hisp.dhis.mobile.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author 
+ * @version $Id$
+ */
+
+public class GetMobileConfigurationAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private SmsConfigurationManager smsConfigurationManager;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private SmsConfiguration smsConfig;
+
+    public SmsConfiguration getSmsConfig()
+    {
+        return smsConfig;
+    }
+
+    public boolean getSmsServiceStatus()
+    {
+        return this.smsConfig != null && this.smsConfig.isEnabled();
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        smsConfig = smsConfigurationManager.getSmsConfiguration();
+
+        return SUCCESS;
+    }
+}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/MobileHomePageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/MobileHomePageAction.java	2011-10-18 20:23:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/MobileHomePageAction.java	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-package org.hisp.dhis.mobile.action;
-
-/*
- * Copyright (c) 2004-2007, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.opensymphony.xwork2.Action;
-
-public class MobileHomePageAction
-    implements Action
-{
-
-    @Override
-    public String execute() throws Exception
-    {
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowMobileConfigurationFormAction.java	1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
-package org.hisp.dhis.mobile.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.sms.SmsConfigurationManager;
-import org.hisp.dhis.sms.config.SmsConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author 
- * @version $Id$
- */
-
-public class ShowMobileConfigurationFormAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    @Autowired
-    private SmsConfigurationManager smsConfigurationManager;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private SmsConfiguration smsConfig;
-
-    public SmsConfiguration getSmsConfig()
-    {
-        return smsConfig;
-    }
-
-    public void setSmsConfig( SmsConfiguration smsConfig )
-    {
-        this.smsConfig = smsConfig;
-    }
-
-    public boolean getSmsServiceStatus()
-    {
-        return this.smsConfig != null && this.smsConfig.isEnabled();
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        smsConfig = smsConfigurationManager.getSmsConfiguration();
-        return SUCCESS;
-    }
-}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowSendSMSFormAction.java	2012-03-14 10:36:55 +0000
@@ -0,0 +1,70 @@
+package org.hisp.dhis.mobile.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Map;
+
+import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+
+public class ShowSendSMSFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private OutboundSmsTransportService transportService;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    public Map<String, String> getGatewayMap()
+    {
+        return transportService.getGatewayMap();
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-03-14 10:36:55 +0000
@@ -6,7 +6,10 @@
   <bean id="org.hisp.dhis.mobile.action.NoAction" class="org.hisp.dhis.mobile.action.NoAction"
     scope="prototype" />
 
-  <bean id="org.hisp.dhis.mobile.action.MobileHomePageAction" class="org.hisp.dhis.mobile.action.MobileHomePageAction"
+  <bean id="org.hisp.dhis.mobile.action.GetMobileConfigurationAction" class="org.hisp.dhis.mobile.action.GetMobileConfigurationAction"
+    scope="prototype" />
+
+  <bean id="org.hisp.dhis.mobile.action.ShowSendSMSFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSFormAction"
     scope="prototype" />
 
   <bean id="org.hisp.dhis.mobile.action.ProcessingSendSMSAction" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction"
@@ -27,6 +30,7 @@
   </bean>
 	
  <!-- Mobile DataSet -->
+
   <bean id="org.hisp.dhis.mobile.action.MobileDataSetListAction" class="org.hisp.dhis.mobile.action.MobileDataSetListAction"
     scope="prototype">
     <property name="dataSetService">
@@ -41,7 +45,8 @@
     </property>
   </bean>
 
-  <!-- SMS Service Configuration -->	
+  <!-- SMS Service Configuration -->
+
   <bean id="org.hisp.dhis.mobile.action.ShowMobileConfigurationFormAction" class="org.hisp.dhis.mobile.action.ShowMobileConfigurationFormAction"
 	scope="prototype"/>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-03-04 13:26:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-03-14 10:36:55 +0000
@@ -41,4 +41,8 @@
 outbound=Outbound
 api_id=API ID
 save_settings=Save Settings
-show_send_sms_form=Show send SMS form
\ No newline at end of file
+show_send_sms_form=Show send SMS form
+bulk_gw=BulkSMS Gateway
+clickatell_gw=Clickatell Gateway
+generic_http_gw=Generic HTTP Gateway
+modem_gateway=Modem Gateway
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2012-03-14 10:36:55 +0000
@@ -15,15 +15,15 @@
       <param name="page">/dhis-web-maintenance-mobile/welcome.vm</param>
       <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
     </action>
-
-    <action name="sendSMS" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction">
+  
+	<action name="showSMSConfigureForm" class="org.hisp.dhis.mobile.action.GetMobileConfigurationAction">
       <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-maintenance-mobile/sendSMSPage.vm</param>
+      <param name="page">/dhis-web-maintenance-mobile/smsServiceConfiguration.vm</param>
       <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
-      <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
+	  <param name="requiredAuthorities">F_MOBILE_SETTINGS</param>
     </action>
   
-	<action name="showSMSForm" class="org.hisp.dhis.mobile.action.NoAction">
+	<action name="showSMSForm" class="org.hisp.dhis.mobile.action.ShowSendSMSFormAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-mobile/sendSMSPage.vm</param>
       <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
@@ -31,6 +31,11 @@
 	  <param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
     </action>
 
+    <action name="sendSMS" class="org.hisp.dhis.mobile.action.ProcessingSendSMSAction">
+      <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+
     <action name="mobileSettings" class="org.hisp.dhis.mobile.action.MobileSettingsAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-mobile/smsSettings.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm	2012-02-29 10:11:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/menu.vm	2012-03-14 10:36:55 +0000
@@ -3,6 +3,6 @@
 <!--    <li><a href = "mobileSettings.action">Settings</a></li>-->
 	<li><a href="patientMobileSetting.action">$i18n.getString( "patient_mobile_setting" )</a></li>
 	<li><a href="showMobileDataSet.action">$i18n.getString( "mobile_dataset" )&nbsp;</a></li>
-    <li><a href = "showSMSForm.action">$i18n.getString( "show_send_sms_form" )</a></li>
-    <li><a href = "showSMSServiceConfiguration.action">$i18n.getString( "sms_service_configuration" )</a></li>
+	<li><a href="showSMSConfigureForm.action">$i18n.getString( "sms_service_configuration" )</a></li>
+    <li><a href="showSMSForm.action">$i18n.getString( "show_send_sms_form" )</a></li>
 </ul>
\ No newline at end of file

=== 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-02-29 10:11:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm	2012-03-14 10:36:55 +0000
@@ -1,3 +1,14 @@
+<script type="text/javascript">
+	jQuery(document).ready( function() {
+		validation2( "sendSMSForm", function( form )
+		{
+			sendSMSMessage( form );
+		}, {
+			'rules' : getValidationRulesForSMSPage()
+		} );
+	});
+</script>
+
 <style type="text/css">
     .statusBar{
         color: white;
@@ -11,7 +22,7 @@
 <h3>Send SMS</h3>
 #if ( $smsServiceStatus )
 
-<form method="post">
+<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
 	<table id="detailsList">
 	    <col width="300px"/>
 		<col width="80px"/>
@@ -22,17 +33,18 @@
 			<tr>
 				<td><label for="type">$i18n.getString( "type" ):</label></td>
 				<td>
-					<select style="width: 100%;">
-						<option value="0">Modem</option>
-						<option value="1">Clickatell</option>
-						<option value="2">BulkSMS</option>
+				#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>
+						#end
 					</select>
 				</td>
 			</tr>
 			
 			<tr>
 				<td>$i18n.getString( "organisation_unit" )</td>
-				<td><input type="checkbox" onchange="toggleSMSGUI( this.checked );"/></td>
+				<td><input type="checkbox" id="sendTypeCB" onchange="toggleSMSGUI( this.checked );"/></td>
 			</tr>
 			
 			<tr><th colspan="2">$i18n.getString( "message" )</th></tr>
@@ -43,17 +55,17 @@
 	<table id="detailsList">
 		<col width="300px"/>
 		<col width="80px"/>
-		<tbody id="singleType">
+		<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>
 		</tbody>
 	
-		<tbody id="multipleType" style="display:none">
-			<tr><td>#organisationUnitSelectionTree( true, true, true )</td></tr>
+		<tbody id="orgunitType" style="display:none">
+			<tr><td>#organisationUnitSelectionTree( true, true, false )</td></tr>
 		</tbody>
 		
 		<tbody>
-			<tr><td><input type="submit" name="send" value="Send SMS"/></td></tr>
+			<tr><td><input type="submit" name="send" value="$i18n.getString( 'send_sms' )"/></td></tr>
 		</tbody>
 	</table>
 </form>
@@ -65,14 +77,55 @@
 #end
 
 <script type="text/javascript">
+
+	var isChecked = false;
+
 	function toggleSMSGUI( checked )
 	{
 		if ( checked ) {
-			hideById( 'singleType' );
-			showById( 'multipleType' );
-		} else {
-			showById( 'singleType' );
-			hideById( 'multipleType' );
-		}
+			hideById( 'phoneType' );
+			showById( 'orgunitType' );
+		} else {
+			showById( 'phoneType' );
+			hideById( 'orgunitType' );
+		}
+		
+		isChecked = checked;
+	}
+	
+	function sendSMSMessage( _form )
+	{
+		var params = "";
+
+		if ( !isChecked )
+		{
+			var list = getFieldValue( "recipient" ).split( ";" )
+			
+			for ( var i in list ) {
+				params += "recipients=" + list[i] + "&";
+			}
+
+			params = "?" + params.substring( 0, params.length - 1 );
+		}
+
+		jQuery.postUTF8( _form.action + params, {}, function ( json )
+		{
+			if ( json.response == "success" ) {
+				showSuccessMessage( json.message );
+			}
+		} );
+	}
+	
+	function getValidationRulesForSMSPage();
+	{
+		var rules = {};
+		
+		if ( isChecked ) {
+			rules = { 'treeSelectedId': { 'required': true } };
+		} else {
+			rules = { 'recipient': { 'required': true } };
+		}
+		
+		return rules;
 	}
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm	2011-11-14 08:57:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm	2012-03-14 10:36:55 +0000
@@ -9,8 +9,8 @@
 }
 </style>
 
-<h3>$i18n.getString("sms_service_configuration")</h3>
-#if($smsServiceStatus)
+<h3>$i18n.getString( "sms_service_configuration" )</h3>
+#if( $smsServiceStatus )
 <form id="add" name="addGateWayConfig" action="addGateWayConfig.action" method="post" >
   <table id="detailsList">
     <col/> ## Labels
@@ -24,7 +24,7 @@
 		<tr>
 			<td colspan="2">
 				<div class="overlaps" id="noOverlapsDiv" style="display: block;">
-					#if($smsService.isRunning())
+					#if( $smsService.isRunning() )
 						$i18n.getString("sms_service_is_runnning")
 					#else
 						$i18n.getString("sms_service_is_stopped")
@@ -61,7 +61,7 @@
 					<thead>
 						<tr>
 							<th>$i18n.getString("gateways")</th>
-							<th style="text-align:center; width: 50px;">$i18n.getString("operation")</th>
+							<th style="text-align:center; width: 50px;">$i18n.getString( "operation" )</th>
 						</tr>
 					</thead>
 					<tbody>
@@ -70,8 +70,8 @@
 						<tr>
 							<td>$gateWay.name</td>
 							<td style="text-align:right">
-							  <a title="Edit" href="editGateWayConfig.action?gateWayID="><img alt="Edit" src="../images/edit.png"></a>
-							  <a title="Remove" href="#"><img alt="Remove" src="../images/delete.png"></a>
+							  <a title="$i18n.getString( 'edit' )" href="editGateWayConfig.action?gateWayID="><img alt="$i18n.getString( 'edit' )" src="../images/edit.png"/></a>
+							  <a title="$i18n.getString( 'remove' )" href="#"><img alt="$i18n.getString( 'remove' )" src="../images/delete.png"/></a>
 							</td>
 						</tr>
 					#end