← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1919: Add Reinit (delete all record, start from beginning) + Pin Form

 

------------------------------------------------------------
revno: 1919
committer: Long <thanhlongngo1988>
branch nick: cbhis-mobile
timestamp: Wed 2010-10-06 11:47:32 +0700
message:
  Add Reinit (delete all record, start from beginning) + Pin Form
added:
  DHISMobile/src/org/hisp/dhis/mobile/reporting/util/
  DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertConfirmListener.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertUtil.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/util/ReinitConfirmListener.java
modified:
  DHISMobile/.mtj
  DHISMobile/build.properties
  DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ModelRecordStore.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/SplashScreen.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 'DHISMobile/.mtj'
--- DHISMobile/.mtj	2010-10-05 09:14:30 +0000
+++ DHISMobile/.mtj	2010-10-06 04:47:32 +0000
@@ -38,5 +38,31 @@
             <symbol name="screen.height" value="320"/>
          </symbolSet>
       </configuration>
+      <configuration active="false" name="S40_5th_Edition_SDK_Feature_Pack_1_Lite">
+         <device group="Series 40 5th Edition SDK, Feature Pack 1 Lite" name="S40_5th_Edition_SDK_Feature_Pack_1_Lite"/>
+         <symbolSet name="S40_5th_Edition_SDK_Feature_Pack_1_Lite">
+            <symbol name="MMAPI" value="1.2"/>
+            <symbol name="screen.isColor" value="true"/>
+            <symbol name="model" value="Series 40 5th Edition SDK,  Feature Pack 1 Lite"/>
+            <symbol name="screen.width" value="128"/>
+            <symbol name="screen.bitDepth" value="16"/>
+            <symbol name="nokiaui" value="1.1"/>
+            <symbol name="screen.isTouch" value="false"/>
+            <symbol name="JSR82" value="1.1"/>
+            <symbol name="screen.canvas.width" value="128"/>
+            <symbol name="screen.canvas.y" value="40"/>
+            <symbol name="screen.canvas.x" value="0"/>
+            <symbol name="SATSA-APDU" value="1.0"/>
+            <symbol name="MIDP" value="1.0"/>
+            <symbol name="JSR75" value="1.0"/>
+            <symbol name="CLDC" value="1.0"/>
+            <symbol name="screen.canvas.height" value="160"/>
+            <symbol name="SATSA-CRYPTO" value="1.0"/>
+            <symbol name="version.configuration" value="CDLC-1.1"/>
+            <symbol name="WMA" value="1.1"/>
+            <symbol name="version.profile" value="MIDP-2.1"/>
+            <symbol name="screen.height" value="160"/>
+         </symbolSet>
+      </configuration>
    </configurations>
 </mtjMetadata>
\ No newline at end of file

=== modified file 'DHISMobile/build.properties'
--- DHISMobile/build.properties	2010-10-05 09:14:30 +0000
+++ DHISMobile/build.properties	2010-10-06 04:47:32 +0000
@@ -4,3 +4,8 @@
 
 DefaultColorPhone.excludes=\
 
+S40_5th_Edition_SDK_Feature_Pack_1_Lite.includes=src\
+,res\
+
+S40_5th_Edition_SDK_Feature_Pack_1_Lite.excludes=\
+

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java	2010-10-05 09:14:30 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java	2010-10-06 04:47:32 +0000
@@ -6,6 +6,9 @@
 import java.io.*;
 import java.util.Vector;
 import javax.microedition.io.*;
+import javax.microedition.rms.RecordStoreException;
+
+import org.hisp.dhis.mobile.reporting.db.SettingsRecordStore;
 import org.hisp.dhis.mobile.reporting.gui.DHISMIDlet;
 import org.hisp.dhis.mobile.reporting.model.AbstractModel;
 import org.hisp.dhis.mobile.reporting.model.AbstractModelList;
@@ -14,6 +17,7 @@
 import org.hisp.dhis.mobile.reporting.model.DataSet;
 import org.hisp.dhis.mobile.reporting.model.DataSetValue;
 import org.hisp.dhis.mobile.reporting.model.Program;
+import org.hisp.dhis.mobile.reporting.util.AlertUtil;
 
 public class ConnectionManager extends Thread {
 
@@ -24,6 +28,7 @@
 	public static final String DOWNLOAD_PROGRAM = "program";
 	public static final String DOWNLOAD_ACTIVITYPLAN = "activityplan";
 	public static final String UPLOAD_ACTIVITY_VALUES = "uploadactivityvalue";
+	public static final String AUTHENTICATE = "authenticate";
 
 	Vector abstractModelListVector = new Vector();
 	private DataSet dataSet = null;
@@ -187,6 +192,78 @@
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}					
+		} else if (task.equals(ConnectionManager.AUTHENTICATE)) {
+			authenticate(rootUrl + "user");
+		}
+	}
+	
+	private void authenticate(String url) {
+		HttpConnection hcon = null;
+
+		try {
+			int redirectTimes = 0;
+			boolean redirect;
+			do {
+				redirect = false;
+				hcon = (HttpConnection) Connector.open(url);
+				configureConnection(hcon);
+
+				int status = hcon.getResponseCode();
+				switch (status) {
+				case HttpConnection.HTTP_OK:
+					dhisMIDlet.setLogin(true);
+					saveInitSetting();
+					dhisMIDlet.switchDisplayable(null, dhisMIDlet.getPinForm());
+					break;
+                case HttpConnection.HTTP_SEE_OTHER:
+                case HttpConnection.HTTP_TEMP_REDIRECT:
+                case HttpConnection.HTTP_MOVED_TEMP:
+                case HttpConnection.HTTP_MOVED_PERM:
+					url = hcon.getHeaderField("location");
+					if (hcon != null)
+						hcon.close();
+
+					hcon = null;
+					redirectTimes++;
+					redirect = true;
+					break;
+				default:
+					hcon.close();
+					throw new IOException("Response status not OK:" + status);
+				}
+
+			} while (redirect == true && redirectTimes < 5);
+			if (redirectTimes == 5) {
+				throw new IOException("Too much redirects");
+			}
+		} catch (SecurityException e) {
+			dhisMIDlet.switchDisplayable(AlertUtil.getErrorAlert("Error", e.getMessage()), dhisMIDlet.getLoginForm());
+			e.printStackTrace();
+		} catch (Exception e) {
+			dhisMIDlet.switchDisplayable(AlertUtil.getErrorAlert("Error", e.getMessage()), dhisMIDlet.getLoginForm());
+			e.printStackTrace();
+		} finally {
+			try {
+				if (hcon != null)
+					hcon.close();
+			} catch (IOException ioe) {
+				ioe.printStackTrace();
+			}
+		}
+
+	}
+	
+	private void saveInitSetting() {
+		SettingsRecordStore settingsRecord = null;
+		try {
+			settingsRecord = new SettingsRecordStore(
+					SettingsRecordStore.SETTINGS_DB);
+			settingsRecord.put("url", dhisMIDlet.getServerUrl().getString());
+			settingsRecord.put("username", dhisMIDlet.getUserName().getString());
+			settingsRecord.put("password", dhisMIDlet.getPassword().getString());
+			settingsRecord.save();
+		} catch (RecordStoreException e) {
+			e.printStackTrace();
 		}
 	}
 

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ModelRecordStore.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ModelRecordStore.java	2010-09-24 14:08:46 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ModelRecordStore.java	2010-10-06 04:47:32 +0000
@@ -10,6 +10,8 @@
 import java.util.Vector;
 import javax.microedition.rms.RecordEnumeration;
 import javax.microedition.rms.RecordStore;
+import javax.microedition.rms.RecordStoreNotOpenException;
+
 import org.hisp.dhis.mobile.reporting.model.AbstractModel;
 
 /**
@@ -134,4 +136,31 @@
 				rs.closeRecordStore();
 		}
 	}
+	
+	public static void clear(String db) {
+		RecordStore rs = null;
+		RecordEnumeration re = null;
+		try {
+			rs = RecordStore.openRecordStore(db, true);
+			re = rs.enumerateRecords(null, null, false);
+			int id;
+			while (re.hasNextElement()) {
+				id = re.nextRecordId();
+				rs.deleteRecord(id);
+			}
+		} 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();
+				}
+		}
+	}	
 }
\ No newline at end of file

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java	2010-10-05 09:14:30 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java	2010-10-06 04:47:32 +0000
@@ -22,6 +22,8 @@
 import org.hisp.dhis.mobile.reporting.model.Period;
 import org.hisp.dhis.mobile.reporting.model.Program;
 import org.hisp.dhis.mobile.reporting.model.ProgramStage;
+import org.hisp.dhis.mobile.reporting.util.AlertUtil;
+import org.hisp.dhis.mobile.reporting.util.ReinitConfirmListener;
 
 /**
  * @author abyotag_adm
@@ -50,12 +52,15 @@
 	private TextField dhisUserName;
 	private TextField userName;
 	private TextField password;
+	private TextField serverURL;
+	private TextField pinTextField;
 	private ChoiceGroup periodChoice;
 	private Alert successAlert;
 	private Alert errorAlert;
 	private Form activityEntryForm;
 	private Form dataEntryForm;
 	private Form loginForm;
+	private Form pinForm;
 	private Form settingsForm;
 	private Form periodForm;
 	private Form waitForm;		
@@ -100,6 +105,8 @@
 	private Command periodNxtCmd;
 	private Command dsDeleteCmd;
 	private Command selectDailyPeriodCmd;
+	private Command pinFormNextCmd;
+	private Command pinFormReinitCmd;
 	private Image logo;
 
 	/**
@@ -119,7 +126,7 @@
 	 * Performs an action assigned to the Mobile Device - MIDlet Started point.
 	 */
 	public void startMIDlet() {
-		new SplashScreen(getLogo(), getDisplay(), (Displayable) getLoginForm());
+		new SplashScreen(getLogo(), getDisplay(), (Displayable) getLoginForm(), (Displayable) getPinForm());
 	}
 
 	/**
@@ -255,8 +262,9 @@
 				exitMIDlet();
 			} else if (command == lgnFrmLgnCmd) 
 			{
+				switchDisplayable(null, getWaitForm());
 				login();
-				switchDisplayable(null, getMainMenuList());
+//				switchDisplayable(null, getMainMenuList());
 			}
 		} 
 		else if (displayable == mainMenuList) 
@@ -359,9 +367,49 @@
 			{
 				saveSettings();
 				switchDisplayable(null, getMainMenuList());
+			} 
+		} else if (displayable == pinForm) {
+			if (command == pinFormNextCmd) {
+				checkPIN();
+			} else if (command == exitCommand){
+				exitMIDlet();
+			} else if (command == pinFormReinitCmd) {
+				ReinitConfirmListener listener = new ReinitConfirmListener();
+				listener.setCurrentScrren(getPinForm());
+				listener.setNextScreen(getLoginForm());
+				this.getDisplay().setCurrent(AlertUtil.getConfirmAlert("Reinisialize", "All of the data will be lost. Are you sure you want to reinit", listener, this, getPinForm(), getLoginForm()));
 			}
 		}
 	}
+		
+	private void checkPIN() {
+		SettingsRecordStore settingRs = null;
+        try
+        {
+            settingRs = new SettingsRecordStore( SettingsRecordStore.SETTINGS_DB );
+            if ( settingRs.get( "pin" ).equals(""))
+            {
+                if (!getPinTextField().getString().equals("")){
+                	settingRs.put("pin", getPinTextField().getString().trim());
+                	settingRs.save();
+                	switchDisplayable(null, getMainMenuList());
+                } else {
+                	switchDisplayable(AlertUtil.getInfoAlert("Error", "PIN cannot be empty"), getPinForm());
+                }
+            } else {
+            	if (settingRs.get( "pin" ).equals(getPinTextField().getString())){
+            		switchDisplayable(null, getMainMenuList());
+            	} else {
+            		switchDisplayable(AlertUtil.getInfoAlert("Error", "Ivalid PIN"), getPinForm());
+            	}
+            }
+            settingRs = null;
+        }
+        catch ( RecordStoreException e )
+        {
+            e.printStackTrace();
+        }
+	}
 
 	/**
 	 * Returns an initiliazed instance of exitCommand component.
@@ -795,13 +843,50 @@
 	public Form getLoginForm() {
 		if (loginForm == null) {
 			loginForm = new Form("Please login", new Item[] { getUserName(),
-					getPassword() });
+					getPassword(), getServerUrl() });
 			loginForm.addCommand(getLgnFrmExtCmd());
 			loginForm.addCommand(getLgnFrmLgnCmd());
 			loginForm.setCommandListener(this);
 		}
 		return loginForm;
 	}
+	
+	public Form getPinForm() {
+		if (pinForm == null) {
+			pinForm = new Form("Enter a 4 digit PIN");
+			pinForm.append(this.getPinTextField());
+			pinForm.addCommand(this.getPinFormNextCmd());
+			pinForm.addCommand(this.getPinFormReinitCmd());
+			pinForm.addCommand(this.getExitCommand());
+			pinForm.setCommandListener(this);
+		} else if (pinForm != null) {
+			getPinTextField().setString("");
+		}
+		return pinForm;
+	}
+	
+	private TextField getPinTextField() {
+		if (pinTextField == null) {
+			pinTextField = new TextField("PIN", "", 4, TextField.NUMERIC
+					| TextField.PASSWORD);
+
+		}
+		return pinTextField;
+	}
+
+	private Command getPinFormNextCmd() {
+		if (pinFormNextCmd == null) {
+			pinFormNextCmd = new Command("Next", Command.SCREEN, 0);
+		}
+		return pinFormNextCmd;
+	}
+
+	private Command getPinFormReinitCmd() {
+		if (pinFormReinitCmd == null) {
+			pinFormReinitCmd = new Command("ReInit", Command.SCREEN, 1);
+		}
+		return pinFormReinitCmd;
+	}
 
 	/**
 	 * Returns an initiliazed instance of userName component.
@@ -828,6 +913,14 @@
 		}
 		return password;
 	}
+	
+	public TextField getServerUrl() {
+		if (serverURL == null) {
+			serverURL = new TextField("Server Location",
+					"http://localhost:8080/api/";, 64, TextField.URL);
+		}
+		return serverURL;
+	}
 
 	/**
 	 * Returns an initiliazed instance of lgnFrmExtCmd component.
@@ -1467,22 +1560,17 @@
 	}
 
 	private void login() {
-
 		if (getUserName().getString() != null
 				&& getPassword().getString() != null) {
 			if (getUserName().getString().trim().length() != 0
 					&& getPassword().getString().trim().length() != 0) {
-				login = true;
+				ConnectionManager connectionManager = new ConnectionManager(
+						this, getServerUrl().getString(), getUserName()
+								.getString(), getPassword().getString(),
+						getLocale().getString(), ConnectionManager.AUTHENTICATE);
+				connectionManager.start();
 			}
 		}
-		// Take action based on login value
-		if (login) {
-			System.out.println("Login successfull");
-
-		} else {
-			System.out.println("Login failed...");
-		}
-		login = false;
 	}
 
 	private void saveSettings() {
@@ -1570,16 +1658,12 @@
 		SettingsRecordStore settingsRecord;
 
 		try {
-			settingsRecord = new SettingsRecordStore(SettingsRecordStore.SETTINGS_DB);
-			String rootUrl = "";
+			settingsRecord = new SettingsRecordStore(
+					SettingsRecordStore.SETTINGS_DB);
+			
 			String localeSetting = "";
-
-			rootUrl = settingsRecord.get("url");
-			if (rootUrl.trim().length() == 0) {
-				rootUrl = "http://<your_server_address>/api/";
-			}
-
 			localeSetting = settingsRecord.get("locale");
+			
 			if (localeSetting.trim().length() == 0) {
 				localeSetting = System.getProperty("microedition.locale");
 				if (localeSetting == null) {
@@ -1587,10 +1671,10 @@
 				}
 			}
 
-			getUrl().setString(rootUrl);
+			getUrl().setString(settingsRecord.get("url"));
 			getDhisUserName().setString(settingsRecord.get("username"));
 			getDhisUserPass().setString(settingsRecord.get("password"));
-			getLocale().setString(localeSetting);		
+			getLocale().setString(localeSetting);
 
 		} catch (RecordStoreException rse) {
 		}
@@ -1987,4 +2071,12 @@
 		}
 		return selectDailyPeriodCmd;
 	}
+	
+	public boolean isLogin() {
+		return login;
+	}
+
+	public void setLogin(boolean login) {
+		this.login = login;
+	}
 }

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/SplashScreen.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/SplashScreen.java	2010-09-24 14:08:46 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/SplashScreen.java	2010-10-06 04:47:32 +0000
@@ -7,6 +7,9 @@
 
 import java.util.*;
 import javax.microedition.lcdui.*;
+import javax.microedition.rms.RecordStoreException;
+
+import org.hisp.dhis.mobile.reporting.db.SettingsRecordStore;
 
 /**
  * 
@@ -16,16 +19,20 @@
 
 	private Display display;
 
-	private Displayable nextScreen;
+	private Displayable loginForm;
+
+	private Displayable pinForm;
 
 	private Image image;
 
 	private Timer timer = new Timer();
 
-	public SplashScreen(Image image, Display display, Displayable nextScreen) {
+	public SplashScreen(Image image, Display display, Displayable loginForm,
+			Displayable pinForm) {
 		this.image = image;
 		this.display = display;
-		this.nextScreen = nextScreen;
+		this.loginForm = loginForm;
+		this.pinForm = pinForm;
 		display.setCurrent(this);
 	}
 
@@ -51,7 +58,19 @@
 
 	private void dismissSplashScreen() {
 		timer.cancel();
-		display.setCurrent(nextScreen);
+		SettingsRecordStore settingStore = null;
+
+		try {
+			settingStore = new SettingsRecordStore(
+					SettingsRecordStore.SETTINGS_DB);
+			if (settingStore.get("pin").equals("")) {
+				display.setCurrent(loginForm);
+			} else {
+				display.setCurrent(pinForm);
+			}
+		} catch (RecordStoreException e) {
+			e.printStackTrace();
+		}
 	}
 
 	// count down for the splash display

=== added directory 'DHISMobile/src/org/hisp/dhis/mobile/reporting/util'
=== added file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertConfirmListener.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertConfirmListener.java	1970-01-01 00:00:00 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertConfirmListener.java	2010-10-06 04:47:32 +0000
@@ -0,0 +1,54 @@
+package org.hisp.dhis.mobile.reporting.util;
+
+import javax.microedition.lcdui.Command;
+import javax.microedition.lcdui.CommandListener;
+import javax.microedition.lcdui.Displayable;
+import javax.microedition.midlet.MIDlet;
+
+
+
+/**
+ * @author Tran Ng Minh Luan
+ *
+ */
+public abstract class AlertConfirmListener implements CommandListener
+{
+    protected Displayable currentScrren;
+    
+    protected Displayable nextScreen;
+
+    protected MIDlet midlet;
+    
+    public AlertConfirmListener(  )
+    {
+        
+    }
+    
+    public void setCurrentScrren( Displayable currentScrren )
+    {
+        this.currentScrren = currentScrren;
+    }
+
+
+
+    public void setNextScreen( Displayable nextScreen )
+    {
+        this.nextScreen = nextScreen;
+    }
+
+
+
+    public void setMidlet( MIDlet midlet )
+    {
+        this.midlet = midlet;
+    }
+
+
+
+    public void commandAction( Command c, Displayable d )
+    {
+        //Define action when Command == OK
+        //Define action when Command == CANCEL
+    }
+
+}

=== added file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertUtil.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertUtil.java	1970-01-01 00:00:00 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/util/AlertUtil.java	2010-10-06 04:47:32 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.mobile.reporting.util;
+
+import javax.microedition.lcdui.Alert;
+import javax.microedition.lcdui.AlertType;
+import javax.microedition.lcdui.Command;
+import javax.microedition.lcdui.Displayable;
+import javax.microedition.midlet.MIDlet;
+
+public class AlertUtil
+{
+
+    public static Alert getErrorAlert( String title, String msg )
+    {
+        Alert alert = new Alert( title );
+        alert.setString( msg );
+        alert.setType( AlertType.ERROR );
+        alert.setTimeout( Alert.FOREVER );
+        return alert;
+    }
+
+    public static Alert getInfoAlert( String title, String msg )
+    {
+        Alert alert = new Alert( title );
+        alert.setString( msg );
+        alert.setType( AlertType.INFO );
+        alert.setTimeout( Alert.FOREVER );
+        return alert;
+    }
+
+    public static Alert getConfirmAlert( String title, String msg, AlertConfirmListener listener, MIDlet midlet,
+        Displayable currentScreen, Displayable nextScreen )
+    {
+
+        Alert alert = new Alert( title, msg, null, AlertType.CONFIRMATION );
+        alert.addCommand( new Command( "YES", Command.OK, 0 ) );
+        alert.addCommand( new Command( "NO", Command.CANCEL, 0 ) );
+        listener.setMidlet( midlet );
+        listener.setCurrentScrren( currentScreen );
+        listener.setNextScreen( nextScreen );
+        alert.setCommandListener( listener );
+        return alert;
+    }
+
+}

=== added file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/util/ReinitConfirmListener.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/util/ReinitConfirmListener.java	1970-01-01 00:00:00 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/util/ReinitConfirmListener.java	2010-10-06 04:47:32 +0000
@@ -0,0 +1,32 @@
+package org.hisp.dhis.mobile.reporting.util;
+
+import javax.microedition.lcdui.Command;
+import javax.microedition.lcdui.Displayable;
+
+import org.hisp.dhis.mobile.reporting.db.ModelRecordStore;
+import org.hisp.dhis.mobile.reporting.db.SettingsRecordStore;
+import org.hisp.dhis.mobile.reporting.db.ValueRecordStore;
+import org.hisp.dhis.mobile.reporting.gui.DHISMIDlet;
+
+public class ReinitConfirmListener
+    extends AlertConfirmListener
+{
+    public void commandAction( Command c, Displayable d )
+    {
+        if ( c.getCommandType() == Command.OK )
+        {
+        	ModelRecordStore.clear(ModelRecordStore.ACTIVITY_PLAN_DB);
+        	ModelRecordStore.clear(ModelRecordStore.ACTIVITY_DB);
+        	ModelRecordStore.clear(ModelRecordStore.DATASET_DB);
+        	ModelRecordStore.clear(ModelRecordStore.PROGRAM_DB);
+        	ModelRecordStore.clear(ModelRecordStore.PROGRAM_STAGE_DB);
+        	ModelRecordStore.clear(SettingsRecordStore.SETTINGS_DB);
+        	ModelRecordStore.clear(ValueRecordStore.VALUE_DB);
+        	((DHISMIDlet) this.midlet).switchDisplayable( null, nextScreen );
+        }
+        else if ( c.getCommandType() == Command.CANCEL )
+        {
+        	((DHISMIDlet) this.midlet).switchDisplayable( null, currentScrren );
+        }
+    }
+}