← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7689: add region option for Bulk SMS gateway

 

------------------------------------------------------------
revno: 7689
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-24 17:19:04 +0700
message:
  add region option for Bulk SMS gateway
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java
  dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java
  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/webapp/dhis-web-maintenance-mobile/javascript/gateway.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.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/config/BulkSmsGatewayConfig.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	2012-03-01 08:56:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/BulkSmsGatewayConfig.java	2012-07-24 10:19:04 +0000
@@ -35,6 +35,8 @@
     private String username;
 
     private String password;
+    
+    private String region;
 
     public String getUsername()
     {
@@ -55,6 +57,16 @@
     {
         this.password = password;
     }
+    
+    public String getRegion()
+    {
+        return region;
+    }
+
+    public void setRegion( String region )
+    {
+        this.region = region;
+    }
 
     @Override
     public boolean isInbound()

=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java	2012-03-01 08:56:47 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/GateWayFactory.java	2012-07-24 10:19:04 +0000
@@ -36,6 +36,7 @@
 import org.smslib.AGateway;
 import org.smslib.AGateway.Protocols;
 import org.smslib.http.BulkSmsHTTPGateway;
+import org.smslib.http.BulkSmsHTTPGateway.Regions;
 import org.smslib.http.ClickatellHTTPGateway;
 import org.smslib.modem.SerialModemGateway;
 
@@ -66,18 +67,46 @@
 
     public AGateway createBulkSmsGateway( BulkSmsGatewayConfig config )
     {
-        BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway( "bulksms.http.1", config.getUsername(), config
-            .getPassword() );
+        BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway( "bulksms.http.1", config.getUsername(),
+            config.getPassword(), this.getRegion( config.getRegion() ) );
         gateway.setOutbound( true );
         gateway.setInbound( false );
         return gateway;
     }
 
+    private Regions getRegion( String region )
+    {
+        if ( region.equals( "INTERNATIONAL" ) )
+        {
+            return BulkSmsHTTPGateway.Regions.INTERNATIONAL;
+        }
+        else if ( region.equals( "UNITEDKINGDOM" ) )
+        {
+            return BulkSmsHTTPGateway.Regions.UNITEDKINGDOM;
+        }
+        else if ( region.equals( "SOUTHAFRICA" ) )
+        {
+            return BulkSmsHTTPGateway.Regions.SOUTHAFRICA;
+        }
+        else if ( region.equals( "SPAIN" ) )
+        {
+            return BulkSmsHTTPGateway.Regions.SPAIN;
+        }
+        else if ( region.equals( "USA" ) )
+        {
+            return BulkSmsHTTPGateway.Regions.USA;
+        }
+        else
+        {
+            return BulkSmsHTTPGateway.Regions.GERMANY;
+        }
+    }
+
     public AGateway createModemGateway( ModemGatewayConfig c )
     {
         // TODO: DETECT MODEM CLASS AND INSTANTIATE
-        SerialModemGateway gateway = new SerialModemGateway( c.getName(), c.getPort(), c.getBaudRate(), c
-            .getManufacturer(), c.getModel() );
+        SerialModemGateway gateway = new SerialModemGateway( c.getName(), c.getPort(), c.getBaudRate(),
+            c.getManufacturer(), c.getModel() );
 
         if ( c.getSimMemLocation() != null )
         {
@@ -98,8 +127,8 @@
 
     public AGateway createClickatellGateway( ClickatellGatewayConfig c )
     {
-        ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( c.getName(), c.getApiId(), c.getUsername(), c
-            .getPassword() );
+        ClickatellHTTPGateway gateway = new ClickatellHTTPGateway( c.getName(), c.getApiId(), c.getUsername(),
+            c.getPassword() );
         gateway.setOutbound( true );
         gateway.setInbound( false );
         return gateway;
@@ -107,8 +136,8 @@
 
     public AGateway createSimplisticHttpGetGateway( GenericHttpGatewayConfig c )
     {
-        SimplisticHttpGetGateWay gateway = new SimplisticHttpGetGateWay( c.getName(), c.getUrlTemplate(), c
-            .getParameters() );
+        SimplisticHttpGetGateWay gateway = new SimplisticHttpGetGateWay( c.getName(), c.getUrlTemplate(),
+            c.getParameters() );
         gateway.setOutbound( true );
         gateway.setInbound( false );
         return gateway;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java	2012-03-21 02:20:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java	2012-07-24 10:19:04 +0000
@@ -73,6 +73,18 @@
     {
         this.username = username;
     }
+    
+    private String region;
+    
+    public String getRegion()
+    {
+        return region;
+    }
+
+    public void setRegion( String region )
+    {
+        this.region = region;
+    }
 
     private String gatewayType;
 
@@ -111,7 +123,8 @@
                 gatewayConfig.setName( name );
                 gatewayConfig.setPassword( password );
                 gatewayConfig.setUsername( username );
-
+                gatewayConfig.setRegion( region );
+                
                 if ( index >= 0 )
                 {
                     config.getGateways().set( index, gatewayConfig );

=== 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-06-27 07:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-07-24 10:19:04 +0000
@@ -126,4 +126,10 @@
 sms_command_form=SMS Commands
 add_command=Add command
 command_details=Command Details
-
+region=Region
+international=International
+uk=United Kingdom
+south_africa=South Africa
+spain=Spain
+usa=USA
+germany=Germany

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js	2012-04-03 03:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js	2012-07-24 10:19:04 +0000
@@ -89,7 +89,8 @@
 			gatewayType: getFieldValue( 'gatewayType' ),
 			name: getFieldValue( 'bulksmsFields input[id=name]' ),
 			username: getFieldValue( 'bulksmsFields input[id=username]' ),
-			password: getFieldValue( 'bulksmsFields input[id=password]' )
+			password: getFieldValue( 'bulksmsFields input[id=password]' ),
+			region: getFieldValue( 'bulksmsFields select[id=region]' )
 		}, function ( json ) {
 			showMessage( json );
 		} );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm	2012-03-26 04:42:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm	2012-07-24 10:19:04 +0000
@@ -91,6 +91,19 @@
 				<td>$i18n.getString( "password" ):</td>
 				<td><input type="text" name="password" id="password" style="width: 28em" value="$!bulkGateway.password"/></td>
 			</tr>
+			<tr>
+				<td>$i18n.getString( "region" ):</td>
+				<td>
+					<select id="region" name="region" style="width:100%;">
+						<option value="INTERNATIONAL" #if ( $bulkGateway.region == "INTERNATIONAL" ) selected #end>$i18n.getString( "international" )</option>
+						<option value="UNITEDKINGDOM" #if ( $bulkGateway.region == "UNITEDKINGDOM" ) selected #end>$i18n.getString( "uk" )</option>
+						<option value="SOUTHAFRICA" #if ( $bulkGateway.region == "SOUTHAFRICA" ) selected #end>$i18n.getString( "south_africa" )</option>
+						<option value="SPAIN" #if ( $bulkGateway.region == "SPAIN" ) selected #end>$i18n.getString( "spain" )</option>
+						<option value="USA" #if ( $bulkGateway.region == "USA" ) selected #end>$i18n.getString( "usa" )</option>
+						<option value="GERMANY" #if ( $bulkGateway.region == "GERMANY" ) selected #end>$i18n.getString( "germany" )</option>
+					</select>
+				</td>
+			</tr>
 		</tbody>
 		#set( $clickatellGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 1 ) ) )
 		<tbody id="clickatellFields">