dhis-mobile-devs team mailing list archive
-
dhis-mobile-devs team
-
Mailing list archive
-
Message #00415
[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 224: remove offline patient from the list after register
------------------------------------------------------------
revno: 224
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Fri 2014-05-23 17:03:40 +0700
message:
remove offline patient from the list after register
modified:
src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java
src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java
src/org/hisp/dhis/mobile/recordstore/OfflinePatientRecordStore.java
src/org/hisp/dhis/mobile/view/TrackingDataEntryView.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/task/PersonRegistrationTask.java'
--- src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java 2014-05-22 07:59:58 +0000
+++ src/org/hisp/dhis/mobile/connection/task/PersonRegistrationTask.java 2014-05-23 10:03:40 +0000
@@ -2,10 +2,13 @@
import java.io.DataInputStream;
+import javax.microedition.rms.RecordStoreException;
+
import org.hisp.dhis.mobile.connection.ConnectionManager;
import org.hisp.dhis.mobile.log.LogMan;
import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
import org.hisp.dhis.mobile.model.Patient;
+import org.hisp.dhis.mobile.recordstore.OfflinePatientRecordStore;
import org.hisp.dhis.mobile.util.SerializationUtil;
public class PersonRegistrationTask
@@ -40,6 +43,18 @@
if ( inputStream != null )
{
+ if ( patient.getId() == 0 )
+ {
+ try
+ {
+ OfflinePatientRecordStore.deleteOfflinePatient( patient );
+ }
+ catch ( RecordStoreException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
patientNew.deSerialize( inputStream );
nameBasedMIDlet.getDashboardLinkView().setPatient( patientNew );
=== modified file 'src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java'
--- src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java 2014-04-03 01:58:41 +0000
+++ src/org/hisp/dhis/mobile/connection/task/UploadTrackingFormTask.java 2014-05-23 10:03:40 +0000
@@ -29,6 +29,10 @@
import java.io.DataInputStream;
import java.io.IOException;
+import javax.microedition.rms.RecordStoreException;
+import javax.microedition.rms.RecordStoreFullException;
+import javax.microedition.rms.RecordStoreNotFoundException;
+
import org.hisp.dhis.mobile.connection.ConnectionManager;
import org.hisp.dhis.mobile.log.LogMan;
import org.hisp.dhis.mobile.midlet.DHISMIDlet;
@@ -36,6 +40,7 @@
import org.hisp.dhis.mobile.model.Patient;
import org.hisp.dhis.mobile.model.ProgramStage;
import org.hisp.dhis.mobile.model.Section;
+import org.hisp.dhis.mobile.recordstore.OfflinePatientRecordStore;
import org.hisp.dhis.mobile.ui.Text;
import org.hisp.dhis.mobile.util.SerializationUtil;
@@ -48,7 +53,7 @@
extends AbstractTask
{
private static final String CLASS_TAG = "UploadTrackingFormTask";
-
+
private static final String PROGRAM_STAGE_UPLOADED = "program_stage_uploaded";
private static final String PROGRAM_STAGE_SECTION_UPLOADED = "program_stage_section_uploaded";
@@ -104,6 +109,8 @@
// }
// }
// }
+
+
nameBasedMIDlet.getTrackingDataEntryView().setSection( null );
if ( programStage.isRepeatable() )
{
@@ -136,6 +143,7 @@
nameBasedMIDlet.getTrackingMainMenuView().showView();
}
+
patient = null;
programStage = null;
uploadProgramStage = null;
=== modified file 'src/org/hisp/dhis/mobile/recordstore/OfflinePatientRecordStore.java'
--- src/org/hisp/dhis/mobile/recordstore/OfflinePatientRecordStore.java 2014-05-22 07:59:58 +0000
+++ src/org/hisp/dhis/mobile/recordstore/OfflinePatientRecordStore.java 2014-05-23 10:03:40 +0000
@@ -21,6 +21,7 @@
public class OfflinePatientRecordStore
{
public static final String CLASS_TAG = "OfflinePatientRecordStore";
+
public static final String OFFLINEPATIENT_DB = "OFFLINEPATIENT";
public OfflinePatientRecordStore()
@@ -70,6 +71,35 @@
}
+ public static boolean deleteOfflinePatient( Patient patient )
+ throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException, IOException
+ {
+ try
+ {
+ RecordStore recordStore = RecordStore.openRecordStore( OFFLINEPATIENT_DB, true );
+ OfflinePatientFilter offlinePatientFilter = new OfflinePatientFilter( patient );
+ RecordEnumeration recordEnum = recordStore.enumerateRecords( offlinePatientFilter, null, false );
+
+ if ( recordEnum.numRecords() > 0 )
+ {
+ int id = recordEnum.nextRecordId();
+ recordStore.deleteRecord( id );
+ return true;
+ }
+
+ recordEnum.destroy();
+ recordStore.closeRecordStore();
+
+ }
+ finally
+ {
+ System.gc();
+ }
+
+ return false;
+
+ }
+
public static Vector loadAllOfflinePatients()
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException, IOException
{
@@ -95,7 +125,7 @@
return offlinePatientVector;
}
-
+
public static Vector loadAllOfflinePatientsByTrackedEntity()
throws RecordStoreFullException, RecordStoreNotFoundException, RecordStoreException, IOException
{
@@ -109,11 +139,12 @@
{
Patient patient = new Patient();
SerializationUtil.deSerialize( patient, recordEnum.nextRecord() );
-
+
int index;
for ( index = offlinePatientVector.size(); index > 0; index-- )
{
- if ( ((Patient)offlinePatientVector.elementAt( index - 1 )).getTrackedEntityName().equals( patient.getTrackedEntityName() ) )
+ if ( ((Patient) offlinePatientVector.elementAt( index - 1 )).getTrackedEntityName().equals(
+ patient.getTrackedEntityName() ) )
{
break;
}
=== modified file 'src/org/hisp/dhis/mobile/view/TrackingDataEntryView.java'
--- src/org/hisp/dhis/mobile/view/TrackingDataEntryView.java 2014-05-22 07:59:58 +0000
+++ src/org/hisp/dhis/mobile/view/TrackingDataEntryView.java 2014-05-23 10:03:40 +0000
@@ -459,9 +459,9 @@
for ( int j = 0; j < programStageVector.size(); i++ )
{
ProgramStage offlineProgramStage = (ProgramStage) programStageVector.elementAt( j );
- if ( offlineProgramStage.getName().equals( programStage.getName() ) )
+ if ( offlineProgramStage.getName().equals( uploadProgramStage.getName() ) )
{
- programStageVector.setElementAt( programStage, j );
+ programStageVector.setElementAt( uploadProgramStage, j );
programInstance.setProgramStageInstances( programStageVector );