← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10456: minor fix in SMS input

 

------------------------------------------------------------
revno: 10456
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-03 11:12:05 +0700
message:
  minor fix in SMS input
modified:
  dhis-2/dhis-web/dhis-web-api-mobile/pom.xml
  dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/input/SMSInput.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-web/dhis-web-api-mobile/pom.xml'
--- dhis-2/dhis-web/dhis-web-api-mobile/pom.xml	2013-03-22 13:47:40 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/pom.xml	2013-04-03 04:12:05 +0000
@@ -10,7 +10,7 @@
   
 
   <artifactId>dhis-web-api-mobile</artifactId>
-  <packaging>jar</packaging>
+  <packaging>war</packaging>
   <name>DHIS Mobile API</name>
 
   <dependencies>

=== modified file 'dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/input/SMSInput.java'
--- dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/input/SMSInput.java	2012-11-20 13:34:03 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/input/SMSInput.java	2013-04-03 04:12:05 +0000
@@ -16,22 +16,52 @@
 {
 
     private String sender, message;
+
+    private String phone, text;
+
     private IncomingSmsService incomingSmsService;
 
     @Override
     public String execute()
         throws Exception
     {
-
-        if(sender == null || message == null ){
+        IncomingSms sms = new IncomingSms();
+
+        // case 1 for sender and message
+        if ( sender != null || message != null )
+        {
+            if ( sender == null || message == null )
+            {
+                setNullToAll();
+                return ERROR;
+            }
+            else
+            {
+                sms.setText( message );
+                sms.setOriginator( sender );
+            }
+        }
+
+        // case 2 for phone and text
+        if ( phone != null || text != null )
+        {
+            if ( phone == null || text == null )
+            {
+                setNullToAll();
+                return ERROR;
+            }
+            else
+            {
+                sms.setText( text );
+                sms.setOriginator( phone );
+            }
+        }
+
+        // case 3 for all is null
+        if ( sender == null && message == null && phone == null && text == null )
+        {
             return ERROR;
         }
-        
-        System.out.println( "Sender: " + sender + ", Message: " + message );
-        IncomingSms sms = new IncomingSms();
-        sms.setText( message );
-        sms.setOriginator( sender );
-
         java.util.Date rec = new java.util.Date();
         sms.setReceivedDate( rec );
         sms.setSentDate( rec );
@@ -42,10 +72,17 @@
 
         incomingSmsService.save( sms );
 
+        setNullToAll();
+
+        return SUCCESS;
+    }
+
+    public void setNullToAll()
+    {
         sender = null;
         message = null;
-        
-        return SUCCESS;
+        phone = null;
+        text = null;
     }
 
     public String getMessage()
@@ -68,6 +105,16 @@
         this.sender = sender;
     }
 
+    public void setPhone( String phone )
+    {
+        this.phone = phone;
+    }
+
+    public void setText( String text )
+    {
+        this.text = text;
+    }
+
     public void setIncomingSmsService( IncomingSmsService incomingSmsService )
     {
         this.incomingSmsService = incomingSmsService;