← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 183: combine person registration task vs find latest person task; change "Offline" to "Pending Registr...

 

------------------------------------------------------------
revno: 183
committer: Hong Em <em.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Tue 2013-11-05 15:47:26 +0700
message:
  combine person registration task vs find latest person task; change "Offline" to "Pending Registration" in Tracking Main Menu View
removed:
  src/org/hisp/dhis/mobile/connection/task/FindLatestPersonTask.java
modified:
  src/org/hisp/dhis/mobile/connection/ConnectionManager.java
  src/org/hisp/dhis/mobile/connection/task/AbstractTask.java
  src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java
  src/org/hisp/dhis/mobile/model/OrgUnit.java
  src/org/hisp/dhis/mobile/view/DashboardLinkView.java
  src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java


--
lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking
https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking

Your team DHIS mobile developers is subscribed to branch lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking/+edit-subscription
=== modified file 'src/org/hisp/dhis/mobile/connection/ConnectionManager.java'
--- src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-10-30 09:20:56 +0000
+++ src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-11-05 08:47:26 +0000
@@ -31,7 +31,6 @@
 import org.hisp.dhis.mobile.connection.task.DownloadAllResourceTask;
 import org.hisp.dhis.mobile.connection.task.EnrollProgramTask;
 import org.hisp.dhis.mobile.connection.task.FindAnonymousProgramTask;
-import org.hisp.dhis.mobile.connection.task.FindLatestPersonTask;
 import org.hisp.dhis.mobile.connection.task.FindLostToFollowUpTask;
 import org.hisp.dhis.mobile.connection.task.FindPatientTask;
 import org.hisp.dhis.mobile.connection.task.GenerateRepeatableEventTask;
@@ -197,7 +196,8 @@
 
     public static void getAllAnonymousProgram( String programType, boolean isLostToFollowUp )
     {
-        GetAllAnonymousProgramTask getAllAnonymousProgramTask = new GetAllAnonymousProgramTask( programType, isLostToFollowUp );
+        GetAllAnonymousProgramTask getAllAnonymousProgramTask = new GetAllAnonymousProgramTask( programType,
+            isLostToFollowUp );
         runTask( getAllAnonymousProgramTask );
     }
 
@@ -206,7 +206,7 @@
         FindAnonymousProgramTask findProgramTask = new FindAnonymousProgramTask( keyword );
         runTask( findProgramTask );
     }
-    
+
     public static void registerPerson( Patient patient, String enrollProgramId )
     {
         PersonRegistrationTask registerTask = new PersonRegistrationTask( patient, enrollProgramId );
@@ -220,36 +220,30 @@
         runTask( getVariesInfoTask );
     }
 
-    public static void findLatestPerson()
-    {
-        FindLatestPersonTask findLatestPersonTask = new FindLatestPersonTask();
-        runTask( findLatestPersonTask );
-    }
-
     public static void registerAllOfflinePatient( Patient patient )
     {
         RegisterAllOfflinePatientTask registerAllOfflinePatientTask = new RegisterAllOfflinePatientTask( patient );
         runTask( registerAllOfflinePatientTask );
     }
-    
+
     public static void findLostToFollowUp( String programId )
     {
         FindLostToFollowUpTask findLostToFollowUpTask = new FindLostToFollowUpTask( programId );
         runTask( findLostToFollowUpTask );
     }
-    
+
     public static void sendLostToFollowUp( LostEvent lostEvent )
     {
         SendLostToFollowUpTask sendLostToFollowUpTask = new SendLostToFollowUpTask( lostEvent );
         runTask( sendLostToFollowUpTask );
     }
-    
+
     public static void saveUnregisterdPatient( Patient patient )
     {
         SaveUnregisteredPersonTask saveUnregisteredPersonTask = new SaveUnregisteredPersonTask( patient );
         runTask( saveUnregisteredPersonTask );
     }
-    
+
     public static void generateRepeatableEvent( String eventInfo )
     {
         GenerateRepeatableEventTask generateRepeatableEventTask = new GenerateRepeatableEventTask( eventInfo );

=== modified file 'src/org/hisp/dhis/mobile/connection/task/AbstractTask.java'
--- src/org/hisp/dhis/mobile/connection/task/AbstractTask.java	2013-09-10 09:08:58 +0000
+++ src/org/hisp/dhis/mobile/connection/task/AbstractTask.java	2013-11-05 08:47:26 +0000
@@ -411,4 +411,94 @@
         return responseMessage.toString();
     }
 
+    protected DataInputStream download( byte[] request_body, String additionalProperty, String additionalPropertyName )
+        throws IOException
+    {
+        HttpConnection hcon = null;
+        DataOutputStream dos = null;
+        try
+        {
+            int redirectTimes = 0;
+            DataInputStream inputStream = null;
+            boolean redirect;
+            do
+            {
+                redirect = false;
+                hcon = ConnectionManager.createConnection();
+                hcon.setRequestProperty( additionalPropertyName, additionalProperty );
+                hcon.setRequestProperty( "Content-Length", "" + request_body.toString().length() );
+                hcon.setRequestMethod( HttpConnection.POST );
+
+                dos = hcon.openDataOutputStream();
+                for ( int i = 0; i < request_body.length; i++ )
+                {
+                    dos.writeByte( request_body[i] );
+                }
+                dos.flush();
+
+                int status = hcon.getResponseCode();
+
+                DHISMIDlet.debug( "Response code: " + status );
+
+                switch ( status )
+                {
+                case HttpConnection.HTTP_OK:
+                    inputStream = new DataInputStream( hcon.openInputStream() );
+                    if ( inputStream != null )
+                    {
+                        return getDecompressedStream( inputStream );
+                    }
+                case HttpConnection.HTTP_SEE_OTHER:
+                case HttpConnection.HTTP_TEMP_REDIRECT:
+                case HttpConnection.HTTP_MOVED_TEMP:
+                case HttpConnection.HTTP_MOVED_PERM:
+                    ConnectionManager.setUrl( hcon.getHeaderField( "location" ) );
+                    if ( hcon != null )
+                        hcon.close();
+                    hcon = null;
+                    redirectTimes++;
+                    redirect = true;
+                    break;
+                case HttpConnection.HTTP_CONFLICT:
+                    handleError( "Problem with sent data", hcon );
+                case HttpConnection.HTTP_INTERNAL_ERROR:
+                    hcon.close();
+                    throw new IOException( Text.SERVER_ERROR() );
+                case HttpConnection.HTTP_UNAUTHORIZED:
+                    hcon.close();
+                    throw new IOException( Text.INVALID_USER_PASS() );
+                case HttpConnection.HTTP_NOT_FOUND:
+                    hcon.close();
+                    throw new IOException( Text.CONN_NOT_FOUND() );
+                default:
+                    hcon.close();
+                }
+
+            }
+            while ( redirect == true && redirectTimes < 5 );
+
+            if ( redirectTimes == 5 )
+            {
+                throw new IOException( Text.TOO_MUCH_REDIRECT() );
+            }
+        }
+        finally
+        {
+            try
+            {
+                if ( hcon != null )
+                    hcon.close();
+                if ( hcon != null )
+                    dos.close();
+                System.gc();
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();
+            }
+        }
+        return null;
+
+    }
+
 }
\ No newline at end of file

=== removed file 'src/org/hisp/dhis/mobile/connection/task/FindLatestPersonTask.java'
--- src/org/hisp/dhis/mobile/connection/task/FindLatestPersonTask.java	2013-05-16 09:14:12 +0000
+++ src/org/hisp/dhis/mobile/connection/task/FindLatestPersonTask.java	1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
-package org.hisp.dhis.mobile.connection.task;
-
-import java.io.DataInputStream;
-
-import org.hisp.dhis.mobile.connection.ConnectionManager;
-import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
-import org.hisp.dhis.mobile.model.Patient;
-
-public class FindLatestPersonTask
-    extends AbstractTask
-{
-
-    NameBasedMIDlet nameBasedMIDlet;
-
-    public FindLatestPersonTask()
-    {
-
-    }
-
-    public void run()
-    {
-        this.nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
-        DataInputStream inputStream = null;
-        Patient patientNew = new Patient();
-        try
-        {
-            inputStream = this.download();
-
-            if ( inputStream != null )
-            {
-                patientNew.deSerialize( inputStream );
-                nameBasedMIDlet.getPersonDashboardView().setPatient( patientNew );
-                nameBasedMIDlet.getPersonDashboardView().showView();
-            }
-            inputStream = null;
-            patientNew = null;
-            System.gc();
-
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-
-    }
-
-}

=== modified file 'src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java'
--- src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java	2013-10-23 04:32:49 +0000
+++ src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java	2013-11-05 08:47:26 +0000
@@ -11,8 +11,6 @@
     extends AbstractTask
 {
 
-    private static final String PATIENT_REGISTERED = "patient_registered";
-
     private Patient patient;
 
     private NameBasedMIDlet nameBasedMIDlet;
@@ -31,17 +29,27 @@
 
         try
         {
-            DataInputStream messageStream = this.upload( SerializationUtil.serialize( this.patient ), enrollProgramId,
+            DataInputStream inputStream = this.download( SerializationUtil.serialize( this.patient ), enrollProgramId,
                 "programid" );
-            String message = this.readMessage( messageStream );
-            if ( message.equalsIgnoreCase( PATIENT_REGISTERED ) )
+            Patient patientNew = new Patient();
+
+            if ( inputStream != null )
             {
-                nameBasedMIDlet.getWaitingView().showView();
+                patientNew.deSerialize( inputStream );
+                nameBasedMIDlet.getDashboardLinkView().setPatient( patientNew );
                 nameBasedMIDlet.getDashboardLinkView().showView();
             }
-            else
-            {
-            }
+
+            // String message = this.readMessage( messageStream );
+            //
+            // if ( message.equalsIgnoreCase( PATIENT_REGISTERED ) )
+            // {
+            // nameBasedMIDlet.getWaitingView().showView();
+            // nameBasedMIDlet.getDashboardLinkView().showView();
+            // }
+            // else
+            // {
+            // }
         }
 
         catch ( Exception e )

=== modified file 'src/org/hisp/dhis/mobile/model/OrgUnit.java'
--- src/org/hisp/dhis/mobile/model/OrgUnit.java	2013-10-31 08:42:12 +0000
+++ src/org/hisp/dhis/mobile/model/OrgUnit.java	2013-11-05 08:47:26 +0000
@@ -67,14 +67,12 @@
 
     private String findProgramUrl;
 
-    private String findLatestPersonUrl;
-    
     private String findPatientInAdvancedUrl;
-    
+
     private String findLostToFollowUpUrl;
-    
+
     private String handleLostToFollowUpUrl;
-    
+
     private String generateRepeatableEventUrl;
 
     public static double serverVersion;
@@ -184,11 +182,6 @@
         return findProgramUrl;
     }
 
-    public String getFindLatestPersonUrl()
-    {
-        return findLatestPersonUrl;
-    }
-
     public String getFindPatientInAdvancedUrl()
     {
         return findPatientInAdvancedUrl;
@@ -198,7 +191,7 @@
     {
         return findLostToFollowUpUrl;
     }
-   
+
     public String getHandleLostToFollowUpUrl()
     {
         return handleLostToFollowUpUrl;
@@ -231,7 +224,6 @@
         dataOutputStream.writeUTF( addRelationshipUrl );
         dataOutputStream.writeUTF( downloadAnonymousProgramUrl );
         dataOutputStream.writeUTF( findProgramUrl );
-        dataOutputStream.writeUTF( findLatestPersonUrl );
         dataOutputStream.writeUTF( findPatientInAdvancedUrl );
         dataOutputStream.writeUTF( findLostToFollowUpUrl );
         dataOutputStream.writeUTF( handleLostToFollowUpUrl );
@@ -260,7 +252,6 @@
         addRelationshipUrl = dataInputStream.readUTF();
         downloadAnonymousProgramUrl = dataInputStream.readUTF();
         findProgramUrl = dataInputStream.readUTF();
-        findLatestPersonUrl = dataInputStream.readUTF();
         findPatientInAdvancedUrl = dataInputStream.readUTF();
         findLostToFollowUpUrl = dataInputStream.readUTF();
         handleLostToFollowUpUrl = dataInputStream.readUTF();

=== modified file 'src/org/hisp/dhis/mobile/view/DashboardLinkView.java'
--- src/org/hisp/dhis/mobile/view/DashboardLinkView.java	2013-05-16 09:14:12 +0000
+++ src/org/hisp/dhis/mobile/view/DashboardLinkView.java	2013-11-05 08:47:26 +0000
@@ -134,8 +134,8 @@
             try
             {
                 nameBasedMIDlet.getWaitingView().showView();
-                ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getFindLatestPersonUrl() );
-                ConnectionManager.findLatestPerson();
+                nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+                nameBasedMIDlet.getPersonDashboardView().showView();
                 dashboardLinkForm = null;
                 backCommand = null;
                 nextCommand = null;

=== modified file 'src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java'
--- src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-10-31 08:06:34 +0000
+++ src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-11-05 08:47:26 +0000
@@ -64,6 +64,7 @@
 
     public void prepareView()
     {
+
         System.gc();
         getMenuForm();
     }
@@ -137,21 +138,17 @@
                     ConnectionManager.getAllAnonymousProgram( "1", true );
                 }
             }
-            /*else if ( nextPageName.equals( "Anonymous" ) )
-            {
-                if ( sizeOfOrgUnits > 1 )
-                {
-                    nameBasedMidlet.getWaitingView().showView();
-                    nameBasedMidlet.getOrgUnitSelectView().setProgramType( "3" );
-                    nameBasedMidlet.getOrgUnitSelectView().setLostToFollowUp( false );
-                    nameBasedMidlet.getOrgUnitSelectView().showView();
-                }
-                else
-                {
-                    ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
-                    ConnectionManager.getAllAnonymousProgram( "3", false );
-                }
-            }*/
+            /*
+             * else if ( nextPageName.equals( "Anonymous" ) ) { if (
+             * sizeOfOrgUnits > 1 ) {
+             * nameBasedMidlet.getWaitingView().showView();
+             * nameBasedMidlet.getOrgUnitSelectView().setProgramType( "3" );
+             * nameBasedMidlet.getOrgUnitSelectView().setLostToFollowUp( false
+             * ); nameBasedMidlet.getOrgUnitSelectView().showView(); } else {
+             * ConnectionManager.setUrl(
+             * nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl
+             * () ); ConnectionManager.getAllAnonymousProgram( "3", false ); } }
+             */
             else if ( nextPageName.equals( "History" ) )
             {
                 ModelList modelList = PatientRecordStore.getCurrentPatients();
@@ -159,7 +156,7 @@
                 nameBasedMidlet.getHistoryPersonListView().showView();
 
             }
-            else if ( nextPageName.equals( "Offline" ) )
+            else if ( nextPageName.equals( "Pending Registration" ) )
             {
                 nameBasedMidlet.getWaitingView().showView();
                 nameBasedMidlet.getOfflineOrgUnitSelectView().showView();
@@ -177,7 +174,9 @@
     {
         // String[] menuItems = { "Find Person", "Person Registration",
         // "Anonymous", "Message", "Update Contact", "Setting" };
-        String[] menuItems = { "Find Person", "Add Person", "Lost to Follow Up", "History", "Offline"};
+
+        String[] menuItems = { "Find Person", "Add Person", "Lost to Follow Up", "History", "Pending Registration" };
+
         if ( menuList == null )
         {
             menuList = new List( menuItems );