← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 190: code cleanup, enable name field for general use case

 

------------------------------------------------------------
revno: 190
committer: Long <Long@Long-Laptop>
branch nick: lwuit-tracking
timestamp: Thu 2013-11-28 14:12:43 +0700
message:
  code cleanup, enable name field for general use case
removed:
  src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java
added:
  src/org/hisp/dhis/mobile/connection/task/GetProgramsTask.java
modified:
  build.xml
  src/org/hisp/dhis/mobile/connection/ConnectionManager.java
  src/org/hisp/dhis/mobile/view/PersonRegistrationView.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 'build.xml'
--- build.xml	2013-11-01 10:05:16 +0000
+++ build.xml	2013-11-28 07:12:43 +0000
@@ -34,7 +34,7 @@
 	<!-- Which logo to use -->
 	<property name="logo" value="dhis2_logo.png" />
 	<!-- Server URL -->
-	<property name="server.url" value="http://localhost:9999"; />
+	<property name="server.url" value="http://apps.dhis2.org/dev"; />
 	<!-- User Name -->
 	<property name="username" value="mobile" />
 	<!-- Password -->

=== modified file 'src/org/hisp/dhis/mobile/connection/ConnectionManager.java'
--- src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-11-12 08:06:45 +0000
+++ src/org/hisp/dhis/mobile/connection/ConnectionManager.java	2013-11-28 07:12:43 +0000
@@ -34,7 +34,7 @@
 import org.hisp.dhis.mobile.connection.task.FindLostToFollowUpTask;
 import org.hisp.dhis.mobile.connection.task.FindPatientTask;
 import org.hisp.dhis.mobile.connection.task.GenerateRepeatableEventTask;
-import org.hisp.dhis.mobile.connection.task.GetAllAnonymousProgramTask;
+import org.hisp.dhis.mobile.connection.task.GetProgramsTask;
 import org.hisp.dhis.mobile.connection.task.GetVariesInfoTask;
 import org.hisp.dhis.mobile.connection.task.LoginTask;
 import org.hisp.dhis.mobile.connection.task.PersonRegistrationTask;
@@ -196,7 +196,7 @@
 
     public static void getAllAnonymousProgram( String programType, boolean isLostToFollowUp )
     {
-        GetAllAnonymousProgramTask getAllAnonymousProgramTask = new GetAllAnonymousProgramTask( programType,
+        GetProgramsTask getAllAnonymousProgramTask = new GetProgramsTask( programType,
             isLostToFollowUp );
         runTask( getAllAnonymousProgramTask );
     }

=== removed file 'src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java'
--- src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java	2013-10-21 02:58:54 +0000
+++ src/org/hisp/dhis/mobile/connection/task/GetAllAnonymousProgramTask.java	1970-01-01 00:00:00 +0000
@@ -1,155 +0,0 @@
-/*
- * 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.
- */
-package org.hisp.dhis.mobile.connection.task;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.Vector;
-
-import org.hisp.dhis.mobile.connection.ConnectionManager;
-import org.hisp.dhis.mobile.midlet.DHISMIDlet;
-import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
-import org.hisp.dhis.mobile.model.Program;
-import org.hisp.dhis.mobile.model.ProgramStage;
-import org.hisp.dhis.mobile.ui.Text;
-
-/**
- * @author Nguyen Kim Lai
- * 
- * @version GetAllAnonymousProgramTask.java 2:56:09 PM Mar 22, 2013 $
- */
-public class GetAllAnonymousProgramTask
-    extends AbstractTask
-{
-    String programType;
-
-    boolean isLostToFollowUp;
-
-    NameBasedMIDlet nameBasedMIDlet;
-
-    public GetAllAnonymousProgramTask( String programType, boolean isLostToFollowUp )
-    {
-        this.programType = programType;
-        this.isLostToFollowUp = isLostToFollowUp;
-    }
-
-    public void run()
-    {
-        this.nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
-        DataInputStream dataInputStream = null;
-        try
-        {
-            dataInputStream = this.download( programType, "programType" );
-            Program program = new Program();
-            program.deSerialize( dataInputStream );
-
-            // Anonymous is 3
-            if ( programType.equals( "3" ) )
-            {
-                ProgramStage programStage = (ProgramStage) program.getProgramStages().elementAt( 0 );
-
-                nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
-                nameBasedMIDlet.getTrackingDataEntryView().setTitle( program.getName() );
-                nameBasedMIDlet.getTrackingDataEntryView().showView();
-                programStage = null;
-            }
-            // Multiple events with registration is 1, or lost to follow up
-            // events
-            else
-            {
-                Vector programInfos = new Vector();
-                programInfos.addElement( program.getId() + "/" + program.getName() );
-                nameBasedMIDlet.getProgramSelectView().setProgramInfos( programInfos );
-                programInfos = null;
-                nameBasedMIDlet.getProgramSelectView().setProgramType( programType );
-                nameBasedMIDlet.getProgramSelectView().setLostToFollowUp( isLostToFollowUp );
-                nameBasedMIDlet.getProgramSelectView().showView();
-            }
-
-            dataInputStream = null;
-            programType = null;
-            program = null;
-            System.gc();
-        }
-        catch ( IOException e )
-        {
-
-            DHISMIDlet.debug( e.getMessage() );
-            e.printStackTrace();
-            String message = null;
-
-            message = e.getMessage();
-            if ( e.getMessage().equalsIgnoreCase( Text.HTTP_ERROR() ) )
-            {
-                nameBasedMIDlet.getAlertBoxView( "Internet is not available, Please try again later.", "Alert" ).showView();
-                nameBasedMIDlet.getTrackingMainMenuView().showView();
-            }
-            else if ( message.equalsIgnoreCase( "NO_PROGRAM_FOUND" ) )
-            {
-                nameBasedMIDlet.getAlertBoxView(
-                    "No program found for " + nameBasedMIDlet.getCurrentOrgUnit().getName(), "Opps" ).showView();
-                nameBasedMIDlet.getOrgUnitSelectView().setProgramType( programType );
-                //nameBasedMIDlet.getOrgUnitSelectView().showView();
-                ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
-                nameBasedMIDlet.getPersonRegistrationView().prepareView();
-                nameBasedMIDlet.getPersonRegistrationView().showView();
-            }
-            else
-            {
-                Vector programInfos = new Vector();
-                while ( message.length() > 0 )
-                {
-                    programInfos.addElement( message.substring( 0, message.indexOf( "$" ) ) );
-                    message = message.substring( message.indexOf( "$" ) + 1, message.length() );
-                }
-
-                // Anonymous is 3
-                if ( programType.equals( "3" ) )
-                {
-                    nameBasedMIDlet.getAnonymousProgramListView().setAnonymousProgramInfos( programInfos );
-                    nameBasedMIDlet.getAnonymousProgramListView().showView();
-                }
-                // Multiple events with registration is 1, or lost to follow up
-                // events
-                else
-                {
-                    nameBasedMIDlet.getProgramSelectView().setProgramInfos( programInfos );
-                    nameBasedMIDlet.getProgramSelectView().setProgramType( programType );
-                    nameBasedMIDlet.getProgramSelectView().setLostToFollowUp( isLostToFollowUp );
-                    nameBasedMIDlet.getProgramSelectView().showView();
-                }
-
-                message = null;
-                programInfos = null;
-            }
-            programType = null;
-            nameBasedMIDlet = null;
-            System.gc();
-        }
-    }
-
-}

=== added file 'src/org/hisp/dhis/mobile/connection/task/GetProgramsTask.java'
--- src/org/hisp/dhis/mobile/connection/task/GetProgramsTask.java	1970-01-01 00:00:00 +0000
+++ src/org/hisp/dhis/mobile/connection/task/GetProgramsTask.java	2013-11-28 07:12:43 +0000
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+package org.hisp.dhis.mobile.connection.task;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.Vector;
+
+import org.hisp.dhis.mobile.connection.ConnectionManager;
+import org.hisp.dhis.mobile.midlet.DHISMIDlet;
+import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
+import org.hisp.dhis.mobile.model.Program;
+import org.hisp.dhis.mobile.model.ProgramStage;
+import org.hisp.dhis.mobile.ui.Text;
+
+/**
+ * @author Nguyen Kim Lai
+ * 
+ * @version GetAllAnonymousProgramTask.java 2:56:09 PM Mar 22, 2013 $
+ */
+public class GetProgramsTask
+    extends AbstractTask
+{
+    public static final String ANONYMOUS_TYPE = "3";
+
+    public static final String MULTI_EVENT_TYPE = "1";
+
+    String programType;
+
+    boolean isLostToFollowUp;
+
+    NameBasedMIDlet nameBasedMIDlet;
+
+    public GetProgramsTask( String programType, boolean isLostToFollowUp )
+    {
+        this.programType = programType;
+        this.isLostToFollowUp = isLostToFollowUp;
+    }
+
+    public void run()
+    {
+        this.nameBasedMIDlet = (NameBasedMIDlet) ConnectionManager.getDhisMIDlet();
+        DataInputStream dataInputStream = null;
+        try
+        {
+            dataInputStream = this.download( programType, "programType" );
+            Program program = new Program();
+            program.deSerialize( dataInputStream );
+
+            // Anonymous is 3
+            if ( programType.equals( ANONYMOUS_TYPE ) )
+            {
+                ProgramStage programStage = (ProgramStage) program.getProgramStages().elementAt( 0 );
+
+                nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
+                nameBasedMIDlet.getTrackingDataEntryView().setTitle( program.getName() );
+                nameBasedMIDlet.getTrackingDataEntryView().showView();
+                programStage = null;
+            }
+            // Multiple events with registration is 1, or lost to follow up
+            // events
+            else
+            {
+                Vector programInfos = new Vector();
+                programInfos.addElement( program.getId() + "/" + program.getName() );
+                nameBasedMIDlet.getProgramSelectView().setProgramInfos( programInfos );
+                programInfos = null;
+                nameBasedMIDlet.getProgramSelectView().setProgramType( programType );
+                nameBasedMIDlet.getProgramSelectView().setLostToFollowUp( isLostToFollowUp );
+                nameBasedMIDlet.getProgramSelectView().showView();
+            }
+
+            dataInputStream = null;
+            programType = null;
+            program = null;
+            System.gc();
+        }
+        catch ( IOException e )
+        {
+            DHISMIDlet.debug( e.getMessage() );
+            e.printStackTrace();
+            String message = null;
+
+            message = e.getMessage();
+            if ( e.getMessage().equalsIgnoreCase( Text.HTTP_ERROR() ) )
+            {
+                nameBasedMIDlet.getAlertBoxView( "Internet is not available, Please try again later.", "Alert" )
+                    .showView();
+                nameBasedMIDlet.getTrackingMainMenuView().showView();
+            }
+            else if ( message.equalsIgnoreCase( "NO_PROGRAM_FOUND" ) )
+            {
+                nameBasedMIDlet.getAlertBoxView(
+                    "No program found for " + nameBasedMIDlet.getCurrentOrgUnit().getName(), "Opps" ).showView();
+                nameBasedMIDlet.getOrgUnitSelectView().setProgramType( programType );
+                // nameBasedMIDlet.getOrgUnitSelectView().showView();
+                ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
+                nameBasedMIDlet.getPersonRegistrationView().prepareView();
+                nameBasedMIDlet.getPersonRegistrationView().showView();
+            }
+            else
+            {
+                Vector programInfos = new Vector();
+                while ( message.length() > 0 )
+                {
+                    programInfos.addElement( message.substring( 0, message.indexOf( "$" ) ) );
+                    message = message.substring( message.indexOf( "$" ) + 1, message.length() );
+                }
+
+                // Anonymous is 3
+                if ( programType.equals( "3" ) )
+                {
+                    nameBasedMIDlet.getAnonymousProgramListView().setAnonymousProgramInfos( programInfos );
+                    nameBasedMIDlet.getAnonymousProgramListView().showView();
+                }
+                // Multiple events with registration is 1, or lost to follow up
+                // events
+                else
+                {
+                    nameBasedMIDlet.getProgramSelectView().setProgramInfos( programInfos );
+                    nameBasedMIDlet.getProgramSelectView().setProgramType( programType );
+                    nameBasedMIDlet.getProgramSelectView().setLostToFollowUp( isLostToFollowUp );
+                    nameBasedMIDlet.getProgramSelectView().showView();
+                }
+
+                message = null;
+                programInfos = null;
+            }
+            programType = null;
+            nameBasedMIDlet = null;
+            System.gc();
+        }
+    }
+
+}

=== modified file 'src/org/hisp/dhis/mobile/view/PersonRegistrationView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-11-14 09:48:20 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationView.java	2013-11-28 07:12:43 +0000
@@ -168,11 +168,11 @@
             }
         } );
 
-        // Hide full name text field for Uganda case
-        // personRegistrationForm.addComponent( getRequiredLabel() );
-        // personRegistrationForm.addComponent( fullNameLabel );
-        // personRegistrationForm.addComponent( getFullNameTextField() );
-        // fullNameTextField.requestFocus();
+        // Hide full name text field in Uganda case
+        // mainForm.addComponent( getRequiredLabel() );
+        mainForm.addComponent( fullNameLabel );
+        mainForm.addComponent( getFullNameTextField() );
+        fullNameTextField.requestFocus();
 
         // add identifier
         try
@@ -452,9 +452,10 @@
     private Patient collectData()
     {
         // No fullName for Uganda case
-        // String fullName = this.getFullNameTextField().getText().trim();
+        // String fullName = "";
+        
+        String fullName = this.getFullNameTextField().getText().trim();
         isValid = true;
-        String fullName = "";
         String gender = (String) getGenderComboBox().getSelectedItem();
         String dobType = (String) getDateOfBirthComboBox().getSelectedItem();
         String dateOfBirth = getDateOfBirthTextFiled().getText();

=== modified file 'src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java'
--- src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-11-19 03:19:28 +0000
+++ src/org/hisp/dhis/mobile/view/TrackingMainMenuView.java	2013-11-28 07:12:43 +0000
@@ -20,6 +20,7 @@
  */
 
 import org.hisp.dhis.mobile.connection.ConnectionManager;
+import org.hisp.dhis.mobile.connection.task.GetProgramsTask;
 import org.hisp.dhis.mobile.midlet.DHISMIDlet;
 import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
 import org.hisp.dhis.mobile.model.ModelList;
@@ -117,7 +118,7 @@
                 else
                 {
                     ConnectionManager.setUrl( nameBasedMidlet.getCurrentOrgUnit().getDownloadAnonymousProgramUrl() );
-                    ConnectionManager.getAllAnonymousProgram( "1", false );
+                    ConnectionManager.getAllAnonymousProgram( GetProgramsTask.MULTI_EVENT_TYPE, false );
                 }
             }
             else if ( nextPageName.equals( "Lost to Follow Up" ) )
@@ -157,9 +158,6 @@
 
     public List getMenuList()
     {
-        // String[] menuItems = { "Find Person", "Person Registration",
-        // "Anonymous", "Message", "Update Contact", "Setting" };
-
         String[] menuItems = { "Find Person", "Add Person", "Lost to Follow Up", "History", "Pending Registration" };
 
         if ( menuList == null )