dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08168
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1912: store url in SETTING_DB
------------------------------------------------------------
revno: 1912
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: cbhis-mobile
timestamp: Mon 2010-09-06 15:24:48 +0700
message:
store url in SETTING_DB
now URL is available to change if api's address change (later uses).
modified:
mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DownloadManager.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/AlertConfirmListener.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DefaultAlertConfirmListener.java
mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DnlActivitiesConfirmAlertListener.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/DownloadManager.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DownloadManager.java 2010-08-31 09:00:31 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/connection/DownloadManager.java 2010-09-06 08:24:48 +0000
@@ -79,7 +79,7 @@
for ( int i = 0; i < programStagesVector.size(); i++ )
{
form = (ProgramStageForm) programStagesVector.elementAt( i );
- completeForm = (ProgramStageForm) download( "http://localhost:8080/api/forms/" + form.getId(), new FormParser() );
+ completeForm = (ProgramStageForm) download( dhisMIDlet.getUrl().getString() + "forms/" + form.getId(), new FormParser() );
form.setDataElements( completeForm.getDataElements() );
}
form = null;
=== 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-06 03:04:35 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/ui/DHISMIDlet.java 2010-09-06 08:24:48 +0000
@@ -18,9 +18,7 @@
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStoreException;
-
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;
@@ -70,8 +68,6 @@
private TextField url;
- private TextField adminPass;
-
private Form dataEntryForm;
private Form form;
@@ -82,7 +78,6 @@
private Form waitForm;
- // add one more form to handle downloaded form list
private List downloadedFormsList;
private TextField userName;
@@ -140,6 +135,8 @@
private TextField pinTextField;
+ private TextField urlInSetting;
+
/**
* The DHISMIDlet constructor.
*/
@@ -269,8 +266,6 @@
}
else if ( command == getMnuListDnldCmd() )
{
- // clear DataValue
-
this.getDisplay().setCurrent(
AlertUtil.getConfirmAlert( "Warning",
"All data which are not sent to the server will be clear, do you want to continue ?",
@@ -290,7 +285,7 @@
}
else if ( command == stngsOkCmd )
{
- // save new settings
+ saveSettings();
switchDisplayable( null, getMainMenuList() );
}
}
@@ -341,6 +336,7 @@
// Load Activities
switchDisplayable( null,
this.getWaitForm( "Load Activities", "Loading.....please wait" ) );
+ this.loadSettings();
this.loadForms();
this.loadActivities();
@@ -358,6 +354,9 @@
}
else
{
+ // Save URL
+ System.out.println( "save url:" + getUrl().getString() );
+ settingRs.put( "url", getUrl().getString() );
// Save PIN
settingRs.put( "pin", this.getPinTextField().getString() );
settingRs.save();
@@ -480,7 +479,7 @@
{
selectedActivity = (Activity) activitiesVector.elementAt( getActivitiesList().getSelectedIndex() );
ProgramStageForm formOfActivity = Storage.fetchForm( selectedActivity.getTask().getProgStageId() );
- this.renderForm( formOfActivity, getForm() );
+ this.getForm( formOfActivity );
}
private DataValue getDataValue( int progStageId, int dataElementID, String value )
@@ -804,13 +803,10 @@
if ( settingsForm == null )
{
// settingsForm = new Form( "Configurable Parameters", new Item[] {
- // getUrl(), getAdminPass() } );
// settingsForm = new Form( "Configurable Parameters", new Item[] {
// getUrl() } );
- System.out.println( getUrl().getString() );
settingsForm = new Form( "Configurable Parameters" );
-
- // settingsForm.append( getUrlInSetting() );
+ settingsForm.append( getUrlInSetting() );
settingsForm.addCommand( getSetngsBakCmd() );
settingsForm.addCommand( getStngsOkCmd() );
settingsForm.setCommandListener( this );
@@ -875,17 +871,33 @@
}
/**
- * Returns an initiliazed instance of adminPass component.
+ * Returns an initiliazed instance of url component in setting form.
*
* @return the initialized component instance
*/
- public TextField getAdminPass()
+ private TextField getUrlInSetting()
{
- if ( adminPass == null )
- {
- adminPass = new TextField( "Admin Password", "", 32, TextField.ANY | TextField.PASSWORD );
- }
- return adminPass;
+ String urlBase = "";
+ try
+ {
+ SettingsRectordStore settingRs = new SettingsRectordStore( "SETTINGS" );
+ urlBase = settingRs.get( "url" );
+ System.out.println( "Base URL:" + urlBase );
+ settingRs = null;
+ }
+ catch ( RecordStoreException e )
+ {
+ e.printStackTrace();
+ }
+ if ( urlInSetting == null )
+ {
+ urlInSetting = new TextField( "URL Server", urlBase, 64, TextField.URL );
+ }
+ else
+ {
+ urlInSetting.setString( urlBase );
+ }
+ return urlInSetting;
}
/**
@@ -1017,11 +1029,20 @@
// Real downloaded forms select
public Form getForm( ProgramStageForm selectedForm )
{
- form = new Form( "From" );
- form.addCommand( getBackCommand() );
- form.addCommand( getScreenCommand() );
- form.setCommandListener( this );
- renderForm( selectedForm, form );
+ if ( form == null )
+ {
+ form = new Form( "From" );
+ form.addCommand( getBackCommand() );
+ form.addCommand( getScreenCommand() );
+ form.addCommand( getSaveCommand() );
+ form.setCommandListener( this );
+ renderForm( selectedForm, form );
+ }
+ else
+ {
+ form.deleteAll();
+ renderForm( selectedForm, form );
+ }
return form;
}
@@ -1211,20 +1232,26 @@
private void saveSettings()
{
-
SettingsRectordStore settingsRecord;
try
{
settingsRecord = new SettingsRectordStore( "SETTINGS" );
- settingsRecord.put( "url", url.getString() );
- // settingsRecord.put( "adminPass", adminPass.getString() );
+ settingsRecord.put( "url", urlInSetting.getString() );
+ getUrl().setString( urlInSetting.getString() );
+ this.orgUnit.setActivitiesLink( urlInSetting.getString()
+ + this.orgUnit.getActivitiesLink().substring( this.orgUnit.getActivitiesLink().indexOf( "orgUnits" ) ) );
+ this.orgUnit.setProgramFormsLink( urlInSetting.getString()
+ + this.orgUnit.getProgramFormsLink()
+ .substring( this.orgUnit.getProgramFormsLink().indexOf( "orgUnits" ) ) );
+
+ this.saveOrgUnit( this.orgUnit );
+ // settingsRecord.put( "adminPass", adminPass.getString() );
settingsRecord.save();
}
catch ( RecordStoreException rse )
{
}
-
settingsRecord = null;
}
@@ -1237,7 +1264,7 @@
settingsRecord = new SettingsRectordStore( "SETTINGS" );
getUrl().setString( settingsRecord.get( "url" ) );
- getAdminPass().setString( settingsRecord.get( "adminPass" ) );
+ settingsRecord = null;
}
catch ( RecordStoreException rse )
{
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/AlertConfirmListener.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/AlertConfirmListener.java 2010-08-30 08:09:07 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/AlertConfirmListener.java 2010-09-06 08:24:48 +0000
@@ -7,6 +7,10 @@
import org.hisp.dhis.mobile.ui.DHISMIDlet;
+/**
+ * @author Tran Ng Minh Luan
+ *
+ */
public abstract class AlertConfirmListener implements CommandListener
{
protected Displayable currentScrren;
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DefaultAlertConfirmListener.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DefaultAlertConfirmListener.java 2010-08-30 08:09:07 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DefaultAlertConfirmListener.java 2010-09-06 08:24:48 +0000
@@ -6,6 +6,10 @@
import org.hisp.dhis.mobile.ui.DHISMIDlet;
+/**
+ * @author Tran Ng Minh Luan
+ *
+ */
public class DefaultAlertConfirmListener extends AlertConfirmListener
{
public DefaultAlertConfirmListener(){
=== modified file 'mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DnlActivitiesConfirmAlertListener.java'
--- mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DnlActivitiesConfirmAlertListener.java 2010-08-30 08:09:07 +0000
+++ mobile/dhis-mobile/src/org/hisp/dhis/mobile/util/DnlActivitiesConfirmAlertListener.java 2010-09-06 08:24:48 +0000
@@ -4,8 +4,14 @@
import javax.microedition.lcdui.Displayable;
+import org.hisp.dhis.mobile.db.ModelRecordStore;
+import org.hisp.dhis.mobile.db.Storage;
import org.hisp.dhis.mobile.ui.DHISMIDlet;
+/**
+ * @author Tran Ng Minh Luan
+ *
+ */
public class DnlActivitiesConfirmAlertListener
extends AlertConfirmListener
{
@@ -20,6 +26,7 @@
{
if(c.getCommandType() == Command.OK){
((DHISMIDlet)this.midlet).switchDisplayable(null,nextScreen);
+ Storage.clear( ModelRecordStore.DATAVALUE_DB );
((DHISMIDlet)this.midlet).downloadActivities();
}else if(c.getCommandType() == Command.CANCEL){
((DHISMIDlet)this.midlet).switchDisplayable(null,currentScrren);