dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08171
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1915: Pull "Send record data" from Input Form Screen to MainMenu Screen: all data will be sent at once
------------------------------------------------------------
revno: 1915
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: cbhis-mobile
timestamp: Thu 2010-09-16 10:34:37 +0700
message:
Pull "Send record data" from Input Form Screen to MainMenu Screen: all data will be sent at once
Add Complete button into Input Form Screen: after filingl all required data, this activity will be marked completed and will not be loaded.
added:
mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordFilter.java
modified:
mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DataValueUploadManager.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordOrdUnitIdFilter.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordStore.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/DataValueRecordStore.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/Storage.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/StringUtil.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 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DataValueUploadManager.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DataValueUploadManager.java 2010-09-13 03:48:16 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DataValueUploadManager.java 2010-09-16 03:34:37 +0000
@@ -6,6 +6,7 @@
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Vector;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
@@ -22,7 +23,7 @@
{
private DHISMIDlet dhisMidlet;
- private Hashtable dataValueTable;
+ private Vector dataValueVector;
private String url;
@@ -30,10 +31,10 @@
private User user;
- public DataValueUploadManager( DHISMIDlet dhisMidlet, Hashtable dataValueTable, String url, OrgUnit orgUnit,
+ public DataValueUploadManager( DHISMIDlet dhisMidlet, Vector dataValueVector, String url, OrgUnit orgUnit,
User user )
{
- this.dataValueTable = dataValueTable;
+ this.dataValueVector = dataValueVector;
this.url = url;
this.orgUnit = orgUnit;
this.user = user;
@@ -86,13 +87,13 @@
// System.out.println( "Status: " + connection.getResponseCode() );
// }
- int numOfDataValue = dataValueTable.size();
+ int numOfDataValue = dataValueVector.size();
System.out.println( "No of DataValues: " + numOfDataValue );
dos = new DataOutputStream( opt );
dos.writeInt( numOfDataValue );
dos.writeInt( orgUnit.getId() );
- en = dataValueTable.elements();
+ en = dataValueVector.elements();
while ( en.hasMoreElements() )
{
DataValue dataValue = (DataValue) en.nextElement();
@@ -111,7 +112,7 @@
}
System.out.println( buffer.toString() );
dhisMidlet.switchDisplayable( AlertUtil.getInfoAlert( "Result", buffer.toString() ),
- dhisMidlet.getActivitiesList() );
+ dhisMidlet.getMainMenuList() );
}
catch ( Exception e )
{
=== added file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordFilter.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordFilter.java 1970-01-01 00:00:00 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordFilter.java 2010-09-16 03:34:37 +0000
@@ -0,0 +1,165 @@
+package org.hisp.dhis.mobile.db;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import javax.microedition.rms.RecordFilter;
+
+/**
+ * @author Tran Ng Minh Luan
+ *
+ */
+public class ActivityRecordFilter implements RecordFilter{
+ public static final String filterByOrgUnitId = "FILTER_BY_ORGUNIT";
+
+ public static final String filterByProgStageInstId = "FILTER_BY_PROGSTAGEINSTID";
+
+ public static final String filterByStatusComplete = "FILTER_BY_STATUS_COMPLETE";
+
+ public static final String filterByStatusIncomplete = "FILTER_BY_STATUS_INCOMPLETE";
+
+ private int orgUnitId;
+
+ private int progStageInstId;
+
+ private String filter;
+
+ public ActivityRecordFilter(String filter) {
+ this.filter = filter;
+ }
+
+
+
+ public int getProgStageInstId()
+ {
+ return progStageInstId;
+ }
+
+ public void setProgStageInstId( int progStageInstId )
+ {
+ this.progStageInstId = progStageInstId;
+ }
+
+ public int getOrgUnitId() {
+ return orgUnitId;
+ }
+
+ public void setOrgUnitId(int orgUnitId) {
+ this.orgUnitId = orgUnitId;
+ }
+
+ public boolean matches(byte[] candidate){
+ if(this.filter.equals( filterByOrgUnitId )){
+ ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
+ DataInputStream dis = new DataInputStream(bis);
+ try{
+ if(dis.readInt() == this.orgUnitId){
+ return true;
+ }else{
+ return false;
+ }
+ }catch(Exception e){
+ System.out.println("Activity Filter get exception");
+ return false;
+ }
+ finally{
+ try {
+ bis.close();
+ dis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }else if(this.filter.equals( filterByStatusComplete )){
+ ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
+ DataInputStream dis = new DataInputStream(bis);
+
+ try{
+ dis.readInt();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readLong();
+ dis.readInt();
+ dis.readInt();
+ if(dis.readBoolean() == true){
+ return true;
+ }else{
+ return false;
+ }
+ }catch(Exception e){
+ System.out.println("Activity Filter get exception");
+ return false;
+ }
+ finally{
+ try {
+ bis.close();
+ dis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }else if(this.filter.equals( filterByStatusIncomplete )){
+ ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
+ DataInputStream dis = new DataInputStream(bis);
+ try{
+ dis.readInt();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readLong();
+ dis.readInt();
+ dis.readInt();
+ if(dis.readBoolean() == false){
+ return true;
+ }else{
+ return false;
+ }
+ }catch(Exception e){
+ System.out.println("Activity Filter get exception");
+ return false;
+ }
+ finally{
+ try {
+ bis.close();
+ dis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }else if(this.filter.equals( filterByProgStageInstId )){
+ ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
+ DataInputStream dis = new DataInputStream(bis);
+ try{
+ dis.readInt();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readUTF();
+ dis.readLong();
+ if(dis.readInt() == this.progStageInstId){
+ return true;
+ }else{
+ return false;
+ }
+ }catch(Exception e){
+ System.out.println("Activity Filter get exception");
+ return false;
+ }
+ finally{
+ try {
+ bis.close();
+ dis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ return false;
+
+ }
+}
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordOrdUnitIdFilter.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordOrdUnitIdFilter.java 2010-08-28 10:25:49 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordOrdUnitIdFilter.java 2010-09-16 03:34:37 +0000
@@ -1,51 +1,51 @@
-package org.hisp.dhis.mobile.db;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-import javax.microedition.rms.RecordFilter;
-
-/**
- * @author Tran Ng Minh Luan
- *
- */
-public class ActivityRecordOrdUnitIdFilter implements RecordFilter{
- private int orgUnitId;
-
- public ActivityRecordOrdUnitIdFilter(int orgUnitId) {
- this.orgUnitId = orgUnitId;
- }
-
- public int getOrgUnitId() {
- return orgUnitId;
- }
-
- public void setOrgUnitId(int orgUnitId) {
- this.orgUnitId = orgUnitId;
- }
-
- public boolean matches(byte[] candidate){
- ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
- DataInputStream dis = new DataInputStream(bis);
- try{
- if(dis.readInt() == this.orgUnitId){
- return true;
- }else{
- return false;
- }
- }catch(Exception e){
- System.out.println("Activity Filter get exception");
- return false;
- }
- finally{
- try {
- bis.close();
- dis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
- }
-}
+//package org.hisp.dhis.mobile.db;
+//
+//import java.io.ByteArrayInputStream;
+//import java.io.DataInputStream;
+//import java.io.IOException;
+//
+//import javax.microedition.rms.RecordFilter;
+//
+///**
+// * @author Tran Ng Minh Luan
+// *
+// */
+//public class ActivityRecordOrdUnitIdFilter implements RecordFilter{
+// private int orgUnitId;
+//
+// public ActivityRecordOrdUnitIdFilter(int orgUnitId) {
+// this.orgUnitId = orgUnitId;
+// }
+//
+// public int getOrgUnitId() {
+// return orgUnitId;
+// }
+//
+// public void setOrgUnitId(int orgUnitId) {
+// this.orgUnitId = orgUnitId;
+// }
+//
+// public boolean matches(byte[] candidate){
+// ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
+// DataInputStream dis = new DataInputStream(bis);
+// try{
+// if(dis.readInt() == this.orgUnitId){
+// return true;
+// }else{
+// return false;
+// }
+// }catch(Exception e){
+// System.out.println("Activity Filter get exception");
+// return false;
+// }
+// finally{
+// try {
+// bis.close();
+// dis.close();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+//
+// }
+// }
+//}
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordStore.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordStore.java 2010-08-28 10:25:49 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/ActivityRecordStore.java 2010-09-16 03:34:37 +0000
@@ -5,6 +5,8 @@
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
+import javax.microedition.rms.RecordStoreFullException;
+import javax.microedition.rms.RecordStoreNotFoundException;
import javax.microedition.rms.RecordStoreNotOpenException;
import org.hisp.dhis.mobile.model.Activity;
@@ -32,6 +34,65 @@
}
//Supportive methods
+
+ public void update(Activity activity){
+ RecordStore rs = null;
+ int recordId = 0;
+ recordId = this.getRecordId( activity );
+ if(recordId > 0){
+ try
+ {
+ rs = RecordStore.openRecordStore(dbName, true);
+ byte[] newData = Activity.activityToRecord( activity );
+ rs.setRecord( recordId, newData, 0, newData.length );
+ }
+ catch ( RecordStoreFullException e )
+ {
+ e.printStackTrace();
+ }
+ catch ( RecordStoreNotFoundException e )
+ {
+ e.printStackTrace();
+ }
+ catch ( RecordStoreException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ }
+
+ private int getRecordId(Activity activity){
+ RecordStore rs = null;
+ RecordEnumeration re = null;
+ ActivityRecordFilter rf = new ActivityRecordFilter( ActivityRecordFilter.filterByProgStageInstId );
+ rf.setProgStageInstId( activity.getTask().getProgStageInstId() );
+ int recordId = 0;
+ try {
+ rs = RecordStore.openRecordStore(dbName, true);
+ re = rs.enumerateRecords(rf, null, false);
+ while (re.hasNextElement()) {
+ recordId = re.nextRecordId();
+ return recordId;
+ }
+ return recordId;
+ } catch (Exception e) {
+
+ } finally {
+ if (re != null)
+ re.destroy();
+ if (rs != null)
+ try {
+ rs.closeRecordStore();
+ } catch (RecordStoreNotOpenException e) {
+ e.printStackTrace();
+ } catch (RecordStoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return recordId;
+ }
public void save() {
RecordStore rs = null;
clear();
@@ -93,33 +154,59 @@
}
}
+// public Vector loadAll(){
+// RecordStore rs = null;
+// RecordEnumeration re = null;
+// activityVector = new Vector();
+// try {
+// rs = RecordStore.openRecordStore(dbName, true);
+// re = rs.enumerateRecords(null, null, false);
+// while (re.hasNextElement()) {
+// activityVector.addElement(Activity.recordToActivity(re.nextRecord()));
+// }
+// } catch (Exception e) {
+//
+// } finally {
+// if (re != null)
+// re.destroy();
+// if (rs != null)
+// try {
+// rs.closeRecordStore();
+// } catch (RecordStoreNotOpenException e) {
+// e.printStackTrace();
+// } catch (RecordStoreException e) {
+// e.printStackTrace();
+// }
+// }
+// return getActivityVector();
+// }
public Vector loadAll(){
- RecordStore rs = null;
- RecordEnumeration re = null;
- activityVector = new Vector();
- try {
- rs = RecordStore.openRecordStore(dbName, true);
- re = rs.enumerateRecords(null, null, false);
- while (re.hasNextElement()) {
- activityVector.addElement(Activity.recordToActivity(re.nextRecord()));
- }
- } catch (Exception e) {
+ RecordStore rs = null;
+ RecordEnumeration re = null;
+ activityVector = new Vector();
+ try {
+ rs = RecordStore.openRecordStore(dbName, true);
+ re = rs.enumerateRecords(new ActivityRecordFilter( ActivityRecordFilter.filterByStatusIncomplete ), null, false);
+ while (re.hasNextElement()) {
+ activityVector.addElement(Activity.recordToActivity(re.nextRecord()));
+ }
+ } catch (Exception e) {
- } finally {
- if (re != null)
- re.destroy();
- if (rs != null)
- try {
- rs.closeRecordStore();
- } catch (RecordStoreNotOpenException e) {
- e.printStackTrace();
- } catch (RecordStoreException e) {
- e.printStackTrace();
- }
- }
- return getActivityVector();
- }
-
+ } finally {
+ if (re != null)
+ re.destroy();
+ if (rs != null)
+ try {
+ rs.closeRecordStore();
+ } catch (RecordStoreNotOpenException e) {
+ e.printStackTrace();
+ } catch (RecordStoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return getActivityVector();
+ }
+
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/DataValueRecordStore.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/DataValueRecordStore.java 2010-08-31 09:00:31 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/DataValueRecordStore.java 2010-09-16 03:34:37 +0000
@@ -1,6 +1,8 @@
package org.hisp.dhis.mobile.db;
+import java.util.Date;
import java.util.Hashtable;
+import java.util.Vector;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
@@ -8,6 +10,8 @@
import org.hisp.dhis.mobile.model.Activity;
import org.hisp.dhis.mobile.model.DataValue;
+import org.hisp.dhis.mobile.model.DataElement;
+import org.hisp.dhis.mobile.util.StringUtil;
public class DataValueRecordStore
{
@@ -35,6 +39,53 @@
}
}
+ public Vector loadAllDataValues(){
+ Vector dataValuesTable = new Vector();
+ Hashtable dataElmntsTable = new Hashtable();
+ RecordStore rs = null;
+ RecordStore rs2 = null;
+ RecordEnumeration re = null;
+ RecordEnumeration re2 = null;
+ DataElement dataElement = null;
+ Date date = new Date();
+ try
+ {
+ rs2 = RecordStore.openRecordStore( ModelRecordStore.DATAELEMENT_DB, true );
+ re2 = rs2.enumerateRecords( null, null, false );
+ while ( re2.hasNextElement() )
+ {
+ dataElement = DataElement.recordToDataElement( re2.nextRecord() );
+ dataElmntsTable.put( String.valueOf(dataElement.getId()), String.valueOf(dataElement.getType()) );
+ }
+
+ rs = RecordStore.openRecordStore( ModelRecordStore.DATAVALUE_DB, true );
+ re = rs.enumerateRecords( null, null, false );
+ while ( re.hasNextElement() )
+ {
+ DataValue dataValue = DataValue.recordToDataValue( re.nextRecord() );
+ if(dataElmntsTable.get( String.valueOf(dataValue.getDataElementId())).equals( "3")){
+ System.out.println("date and type");
+ date.setTime(Long.parseLong(dataValue.getValue()));
+ dataValue.setValue( StringUtil.getStringFromDate(date ));
+ dataValuesTable.addElement( dataValue );
+ }else{
+ System.out.println("other");
+ dataValuesTable.addElement( dataValue );
+ }
+ System.out.println("temporary loaded datavalue:"+dataValuesTable.size());
+ }
+ re = null;
+ rs = null;
+ System.out.println("Loaded datavalue:"+dataValuesTable.size());
+ return dataValuesTable;
+ }
+ catch ( RecordStoreException rse )
+ {
+ rse.printStackTrace();
+ return null;
+ }
+ }
+
public Hashtable loadDataValues( Activity activity )
{
Hashtable dataValuesTable = new Hashtable();
@@ -49,11 +100,12 @@
DataValue dataValue = DataValue.recordToDataValue( re.nextRecord() );
if ( dataValue.getProgramInstanceId() == activity.getTask().getProgStageInstId() )
{
- dataValuesTable.put( String.valueOf( dataValue.getDataElementId() ), dataValue.getValue() );
- }
+ dataValuesTable.put( String.valueOf( dataValue.getDataElementId() ), dataValue );
+ }
}
re = null;
rs = null;
+ System.out.println("Loaded datavalue of certain activity:"+dataValuesTable.size());
return dataValuesTable;
}
catch ( RecordStoreException rse )
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/Storage.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/Storage.java 2010-09-13 03:48:16 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/db/Storage.java 2010-09-16 03:34:37 +0000
@@ -175,35 +175,42 @@
ModelRecordStore modelRecordStore;
modelRecordStore = new ModelRecordStore( ModelRecordStore.DATAVALUE_DB );
modelRecordStore.addRecord( DataValue.dataValueToRecord( dataValue ) );
-
- }
-
+ }
+
+ public static Vector loadAllDataValues( )
+ {
+ DataValueRecordStore dataValueRs = new DataValueRecordStore();
+ return dataValueRs.loadAllDataValues();
+ }
+
public static Hashtable loadDataValues( Activity activity )
{
- Hashtable dataValuesTable = new Hashtable();
- RecordStore rs = null;
- RecordEnumeration re = null;
- try
- {
- rs = RecordStore.openRecordStore( ModelRecordStore.DATAVALUE_DB, true );
- re = rs.enumerateRecords( null, null, false );
- while ( re.hasNextElement() )
- {
- DataValue dataValue = DataValue.recordToDataValue( re.nextRecord() );
- if ( dataValue.getProgramInstanceId() == activity.getTask().getProgStageInstId() )
- {
- dataValuesTable.put( String.valueOf( dataValue.getDataElementId() ), dataValue );
- }
- }
- re = null;
- rs = null;
- return dataValuesTable;
- }
- catch ( RecordStoreException rse )
- {
- rse.printStackTrace();
- return null;
- }
+ DataValueRecordStore dataValueRs = new DataValueRecordStore();
+ return dataValueRs.loadDataValues( activity );
+// Hashtable dataValuesTable = new Hashtable();
+// RecordStore rs = null;
+// RecordEnumeration re = null;
+// try
+// {
+// rs = RecordStore.openRecordStore( ModelRecordStore.DATAVALUE_DB, true );
+// re = rs.enumerateRecords( null, null, false );
+// while ( re.hasNextElement() )
+// {
+// DataValue dataValue = DataValue.recordToDataValue( re.nextRecord() );
+// if ( dataValue.getProgramInstanceId() == activity.getTask().getProgStageInstId() )
+// {
+// dataValuesTable.put( String.valueOf( dataValue.getDataElementId() ), dataValue );
+// }
+// }
+// re = null;
+// rs = null;
+// return dataValuesTable;
+// }
+// catch ( RecordStoreException rse )
+// {
+// rse.printStackTrace();
+// return null;
+// }
}
public static void updateDataValue( Activity activity, DataValue newDataValue )
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java 2010-09-13 03:48:16 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java 2010-09-16 03:34:37 +0000
@@ -21,6 +21,7 @@
import org.hisp.dhis.mobile.connection.DataValueUploadManager;
import org.hisp.dhis.mobile.connection.DownloadManager;
+import org.hisp.dhis.mobile.db.ActivityRecordStore;
import org.hisp.dhis.mobile.db.SettingsRectordStore;
import org.hisp.dhis.mobile.db.Storage;
import org.hisp.dhis.mobile.model.AbstractModel;
@@ -33,6 +34,7 @@
import org.hisp.dhis.mobile.util.AlertUtil;
import org.hisp.dhis.mobile.util.DnlActivitiesConfirmAlertListener;
import org.hisp.dhis.mobile.util.ReinitConfirmListener;
+import org.hisp.dhis.mobile.util.StringUtil;
public class DHISMIDlet
extends MIDlet
@@ -139,6 +141,8 @@
private TextField urlInSetting;
+ private Command completeCmd;
+
/**
* The DHISMIDlet constructor.
*/
@@ -227,11 +231,20 @@
}
else if ( command == screenCommand )
{
- sendRecordedData();
+ //sendRecordedData();
}
else if ( command == saveCommand )
{
saveDataValues();
+ }else if(command == completeCmd){
+ selectedActivity.getTask().setComplete( true );
+ ActivityRecordStore activityRs = new ActivityRecordStore();
+ activityRs.update( selectedActivity );
+ activityRs = null;
+ switchDisplayable( null, getWaitForm( "Reload Activities", "Reloading....." ) );
+ activitiesVector = Storage.loadActivities();
+ displayCurActivities();
+ //switchDisplayable( null, getActivitiesList() );
}
}
else if ( displayable == formDownloadList )
@@ -441,7 +454,7 @@
if ( dateField.getDate() != null )
{
Storage.storeDataValue( getDataValue( selectedActivity.getTask().getProgStageInstId(), de.getId(),
- String.valueOf( dateField.getDate().getTime() ) ) );
+ String.valueOf( dateField.getDate().getTime() ) )) ;
System.out.println( "Store new: " + de.getName() );
}
}
@@ -668,7 +681,8 @@
}
else if ( __selectedString.equals( "Send Finished Records" ) )
{
-
+ switchDisplayable( null, getWaitForm( "Send DataValues", "Sending, please wait" ) );
+ sendRecordedData();
}
// else if ( __selectedString.equals( "Record Data" ) )
// {
@@ -974,8 +988,9 @@
{
form = new Form( "Form" );
form.addCommand( getBackCommand() );
- form.addCommand( getScreenCommand() );
+ //form.addCommand( getScreenCommand() );
form.addCommand( getSaveCommand() );
+ form.addCommand( getCompleteCommand() );
form.setCommandListener( this );
}
else
@@ -984,6 +999,13 @@
}
return form;
}
+ private Command getCompleteCommand()
+ {
+ if(this.completeCmd == null){
+ this.completeCmd = new Command("Complete", Command.SCREEN, 0);
+ }
+ return this.completeCmd;
+ }
private Command getSaveCommand()
{
@@ -1428,6 +1450,10 @@
switchDisplayable( null, form );
}
+ private Vector loadAllDataValues(){
+ return Storage.loadAllDataValues();
+ }
+
private void loadDataValues( Activity activity )
{
dataValueTable = Storage.loadDataValues( selectedActivity );
@@ -1444,7 +1470,7 @@
// Need more test
try
{
- this.saveDataValueToRMS();
+ //this.saveDataValueToRMS();
}
catch ( Exception e )
{
@@ -1453,8 +1479,9 @@
// If you are running Apache Tomcat, use the URL
// http://localhost:8080/dhis-web-api/dhis-web-api/importDataValue.action
// Otherwise, use http://localhost:8080/dhis-web-api/importDataValue.action for Jetty
- DataValueUploadManager uploadManager = new DataValueUploadManager( this, dataValueTable,
- "http://localhost:8080/dhis-web-api/importDataValue.action", orgUnit, user );
+ System.out.println("DataValue's quantity will be sent:"+dataValueTable.size());
+ DataValueUploadManager uploadManager = new DataValueUploadManager( this, loadAllDataValues(),
+ "http://localhost:8080/dhis-web-api/dhis-web-api/importDataValue.action", orgUnit, user );
this.switchDisplayable( null, this.getWaitForm( "Please wait", "Uploading..." ) );
uploadManager.start();
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/StringUtil.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/StringUtil.java 2010-08-26 19:55:46 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/StringUtil.java 2010-09-16 03:34:37 +0000
@@ -55,5 +55,17 @@
cal.set( Calendar.YEAR, year );
return cal.getTime();
}
+
+ public static String getStringFromDate(Date date){
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+ int d = c.get(Calendar.DATE);
+
+ int m = c.get(Calendar.MONTH)+1;
+
+ int y = c.get(Calendar.YEAR);
+
+ return y+"-"+(m<10? "0": "")+m+"-"+(d<10? "0": "")+d;
+ }
}