← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10462: edit SmsInput format handler

 

------------------------------------------------------------
revno: 10462
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-03 17:50:16 +0700
message:
  edit SmsInput format handler
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  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-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-04-03 08:06:46 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-04-03 10:50:16 +0000
@@ -1149,9 +1149,22 @@
         List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
             + lastName, orgUnitId );
 
+        //remove the own searcher
+        removeIfDuplicated( patients, enrollmentRelationship.getPersonAId());
+        
         if ( patients.size() > 1 )
         {
-            throw NotAllowedException.NEED_MORE_SPECIFIC;
+            String patientsInfo = new String();
+
+            DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+
+            for ( Patient each : patients )
+            {
+                patientsInfo += each.getId() + "/" + each.getFullName() + "/"
+                    + dateFormat.format( each.getBirthDate() ) + "$";
+            }
+
+            throw new NotAllowedException( patientsInfo );
         }
         else if ( patients.size() == 0 )
         {
@@ -1324,6 +1337,18 @@
 
         return anonymousProgramMobile;
     }
+    
+    private List<Patient> removeIfDuplicated( List<Patient> patients, int patientId )
+    {
+        for ( Patient each : patients )
+        {
+            if ( each.getId() == patientId )
+            {
+                patients.remove( each );
+            }
+        }
+        return patients;
+    }
 
     private void saveDataValues( ActivityValue activityValue, ProgramStageInstance programStageInstance,
         Map<Integer, DataElement> dataElementMap )

=== 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	2013-04-03 04:12:05 +0000
+++ dhis-2/dhis-web/dhis-web-sms/src/main/java/org/hisp/dhis/sms/input/SMSInput.java	2013-04-03 10:50:16 +0000
@@ -15,9 +15,9 @@
     implements Action
 {
 
-    private String sender, message;
+    private String sender, phone, number, msisdn;
 
-    private String phone, text;
+    private String message, text, content;
 
     private IncomingSmsService incomingSmsService;
 
@@ -27,41 +27,45 @@
     {
         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 )
-        {
+        // setter for sms's originator
+        if ( sender != null)
+        {
+            sms.setOriginator( sender );
+        }
+        else if ( phone != null )
+        {
+            sms.setOriginator( phone );
+        }
+        else if ( number != null )
+        {
+            sms.setOriginator( number );
+        }
+        else if ( msisdn != null )
+        {
+            sms.setOriginator( msisdn );
+        }
+
+        // setter for sms's text
+        if ( message != null)
+        {
+            sms.setText( message );
+        }
+        else if ( text != null )
+        {
+            sms.setText( text );
+        }
+        else if ( content != null )
+        {
+            sms.setText( content );
+        }
+        
+        // check whether 2 necessary attributes are null 
+        if ( sms.getOriginator() == null || sms.getText() == null )
+        {
+            setNullToAll();
             return ERROR;
         }
+        
         java.util.Date rec = new java.util.Date();
         sms.setReceivedDate( rec );
         sms.setSentDate( rec );
@@ -80,24 +84,11 @@
     public void setNullToAll()
     {
         sender = null;
+        phone = null;
+        number = null;
         message = null;
-        phone = null;
         text = null;
-    }
-
-    public String getMessage()
-    {
-        return message;
-    }
-
-    public void setMessage( String message )
-    {
-        this.message = message;
-    }
-
-    public String getSender()
-    {
-        return sender;
+        content =null;
     }
 
     public void setSender( String sender )
@@ -109,11 +100,31 @@
     {
         this.phone = phone;
     }
-
+    
+    public void setNumber( String number )
+    {
+        this.number = number;
+    }
+
+    public void setMsisdn( String msisdn )
+    {
+        this.msisdn = msisdn;
+    }
+
+    public void setMessage( String message )
+    {
+        this.message = message;
+    }
+    
     public void setText( String text )
     {
         this.text = text;
     }
+    
+    public void setContent( String content )
+    {
+        this.content = content;
+    }
 
     public void setIncomingSmsService( IncomingSmsService incomingSmsService )
     {