← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1930: Download Everything

 

------------------------------------------------------------
revno: 1930
committer: Tran Ng Minh Luan <Luan@MinhLuan-PC>
branch nick: cbhis-mobile
timestamp: Wed 2010-10-20 22:56:07 +0700
message:
  Download Everything
modified:
  DHISMobile/.classpath
  DHISMobile/build.properties
  DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ActivityRecordFilter.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/model/Activity.java
  DHISMobile/src/org/hisp/dhis/mobile/reporting/model/ActivityPlan.java
  dhis-2/dhis-web/dhis-web-api/pom.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml


--
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/.classpath'
--- DHISMobile/.classpath	2010-10-20 07:38:45 +0000
+++ DHISMobile/.classpath	2010-10-20 15:56:07 +0000
@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="res"/>
-	<classpathentry kind="con" path="org.elipse.mtj.JavaMEContainer/Series 40 5th Edition SDK, Feature Pack 1/S40_5th_Edition_SDK_Feature_Pack_1"/>
+	<classpathentry kind="con" path="org.elipse.mtj.JavaMEContainer/Sun Java(TM) Wireless Toolkit 2.5.2_01 for CLDC/DefaultColorPhone"/>
 	<classpathentry exported="true" kind="lib" path="lib/jzlib-1.0.7.jar"/>
 	<classpathentry kind="lib" path="lib/LWUIT.jar"/>
 	<classpathentry exported="true" kind="con" path="org.eclipse.mtj.core.EXTERNAL_LIBRARY/JMUnit for CLDC 1.1"/>

=== modified file 'DHISMobile/build.properties'
--- DHISMobile/build.properties	2010-10-20 14:54:30 +0000
+++ DHISMobile/build.properties	2010-10-20 15:56:07 +0000
@@ -1,8 +1,8 @@
 # MTJ Build Properties
-S40_5th_Edition_SDK_Feature_Pack_1.includes=src\
+DefaultColorPhone.includes=src\
 ,res\
 
-S40_5th_Edition_SDK_Feature_Pack_1.excludes=\
+DefaultColorPhone.excludes=\
 
 S40_5th_Edition_SDK_Feature_Pack_1.includes=src\
 ,res\

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java	2010-10-19 18:02:48 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/connection/ConnectionManager.java	2010-10-20 15:56:07 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.mobile.reporting.model.AbstractModelList;
 import org.hisp.dhis.mobile.reporting.model.ActivityPlan;
 import org.hisp.dhis.mobile.reporting.model.ActivityValue;
+import org.hisp.dhis.mobile.reporting.model.ActivityWrapper;
 import org.hisp.dhis.mobile.reporting.model.DataSet;
 import org.hisp.dhis.mobile.reporting.model.DataSetValue;
 import org.hisp.dhis.mobile.reporting.model.Program;
@@ -59,7 +60,8 @@
 	public static final String DOWNLOAD_ACTIVITYPLAN = "activityplan";
 	public static final String UPLOAD_ACTIVITY_VALUES = "uploadactivityvalue";
 	public static final String AUTHENTICATE = "authenticate";
-
+	public static final String DOWNLOAD_ALL = "downloadall";
+	
 	Vector abstractModelListVector = new Vector();
 	private DataSet dataSet = null;
 	private Program program = null;
@@ -76,7 +78,7 @@
 	private int param;
 	private DataSetValue dataSetValue;
 	private ActivityValue activityValue;
-
+	private ActivityWrapper activityWrapper;
 	public ConnectionManager() {
 	}
 
@@ -219,7 +221,86 @@
 			}
 		} else if (task.equals(ConnectionManager.AUTHENTICATE)) {
 			authenticate(rootUrl + "user");
-		}
+		}else if(task.equals(ConnectionManager.DOWNLOAD_ALL)){
+			downloadAll(rootUrl + "download");
+			dhisMIDlet.saveActivityPlan(activityWrapper.getActivityPlan());
+			Vector progs = activityWrapper.getPrograms();
+			int numbProg = progs.size();			
+			for(int i = 0; i < numbProg; i++){
+				dhisMIDlet.saveProgram((Program)progs.elementAt(i));
+			}
+			//save programs trong activity wrapper
+		}
+	}
+
+	private void downloadAll(String url) {
+		HttpConnection hcon = null;
+		DataInputStream dis = null;
+		System.out.println("Pro URL" + url);
+		try {
+			int redirectTimes = 0;
+			boolean redirect;
+			do {
+				redirect = false;
+				hcon = (HttpConnection) Connector.open(url);
+				configureConnection(hcon);
+
+				hcon.setRequestProperty("Accept",
+						"application/vnd.org.dhis2.activitywrapper+serialized");
+
+				dis = new DataInputStream(hcon.openInputStream());
+				dis = getDecompressedStream(dis);
+
+				if (dis != null) {
+					activityWrapper = new ActivityWrapper();
+					activityWrapper.deSerialize(dis);
+				}
+
+				int status = hcon.getResponseCode();
+				switch (status) {
+				case HttpConnection.HTTP_OK:
+					break;
+				case HttpConnection.HTTP_TEMP_REDIRECT:
+				case HttpConnection.HTTP_MOVED_TEMP:
+				case HttpConnection.HTTP_MOVED_PERM:
+
+					url = hcon.getHeaderField("location");
+
+					if (dis != null)
+						dis.close();
+					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) {
+			 e.printStackTrace();
+		} catch (Exception e) {
+			 e.printStackTrace();
+		} finally {
+			try {
+				if (hcon != null)
+					hcon.close();
+				if (dis != null)
+					dis.close();
+
+			} catch (IOException ioe) {
+				ioe.printStackTrace();
+			}
+		}
+		
 	}
 
 	private void authenticate(String url) {
@@ -240,6 +321,8 @@
 					dhisMIDlet.setLogin(true);
 					saveInitSetting();
 					dhisMIDlet.switchDisplayable(null, dhisMIDlet.getPinForm());
+//					dhisMIDlet.setDownloading(true);
+//					dhisMIDlet.downloadAll();
 					break;
 				case HttpConnection.HTTP_SEE_OTHER:
 				case HttpConnection.HTTP_TEMP_REDIRECT:
@@ -248,7 +331,6 @@
 					url = hcon.getHeaderField("location");
 					if (hcon != null)
 						hcon.close();
-
 					hcon = null;
 					redirectTimes++;
 					redirect = true;

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ActivityRecordFilter.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ActivityRecordFilter.java	2010-10-19 09:32:21 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/db/ActivityRecordFilter.java	2010-10-20 15:56:07 +0000
@@ -76,6 +76,7 @@
 				dis.readUTF();
 				dis.readUTF();
 				dis.readUTF();
+				dis.readBoolean();
 				int i = dis.readInt();
 				for(int j = 0; j < i; j++){
 				    dis.readUTF();
@@ -108,6 +109,7 @@
 				dis.readUTF();
 				dis.readUTF();
 				dis.readUTF();
+				dis.readBoolean();
 				int i = dis.readInt();
                                 for(int j = 0; j < i; j++){
                                     dis.readUTF();
@@ -140,6 +142,7 @@
 				dis.readUTF();
 				dis.readUTF();
 				dis.readUTF();
+				dis.readBoolean();
 				int i = dis.readInt();
                                 for(int j = 0; j < i; j++){
                                     dis.readUTF();

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java	2010-10-20 14:54:30 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/gui/DHISMIDlet.java	2010-10-20 15:56:07 +0000
@@ -72,7 +72,7 @@
 	private ProgramStage selectedProgramStage;
 
 	private Hashtable dataElements = new Hashtable();
-
+	private boolean downloading = true;
 	private String selectedPeriod;
 	private DateField dailyPeriodDateField;
 	private TextField url;
@@ -257,16 +257,19 @@
 		} else if (displayable == loginForm) {
 			if (command == lgnFrmExtCmd) {
 				exitMIDlet();
-			} else if (command == lgnFrmLgnCmd) {
+			} 
+			else if (command == lgnFrmLgnCmd) {
 				if (getUserName().getString().trim().length() == 0
 						|| getPassword().getString().trim().length() == 0) {
 					switchDisplayable(AlertUtil.getErrorAlert(
 							"Incomplete Form", "Username or Password Missing"),
 							getLoginForm());
 					return;
-				}
+			}
 				switchDisplayable(null, getWaitForm());
+				
 				login();
+				
 				// switchDisplayable(null, getMainMenuList());
 			}
 		} else if (displayable == mainMenuList) {
@@ -384,6 +387,16 @@
 			e.printStackTrace();
 		}
 	}
+	
+	
+
+	public boolean isDownloading() {
+		return downloading;
+	}
+
+	public void setDownloading(boolean downloading) {
+		this.downloading = downloading;
+	}
 
 	/**
 	 * Returns an initialized instance of exitCommand component.
@@ -1294,6 +1307,7 @@
 			maintenanceList.append("Delete Program", null);
 			maintenanceList.append("Download Activity Plan", null);
 			maintenanceList.append("Delete Activity Plan", null);
+			maintenanceList.append("Download All",null);
 			maintenanceList.addCommand(getMntnceBakCmd());
 			maintenanceList.setCommandListener(this);
 			// maintenanceList.setSelectedFlags(new boolean[] { false, false });
@@ -1341,9 +1355,18 @@
 				switchDisplayable(null, getWaitForm());
 
 				deleteActivityPlan();
+			}else if(__selectedString.equals("Download All")){
+				getWaitForm().deleteAll();
+				getWaitForm().setTitle("Download All");
+				getWaitForm().append("Please wait........");
+				switchDisplayable(null, getWaitForm());
+
+				downloadAll();
 			}
 		}
 	}
+	
+	
 
 	/**
 	 * Returns an initialized instance of mntnceBakCmd component.
@@ -1732,6 +1755,15 @@
 				ConnectionManager.BROWSE_DATASETS);
 		connectionManager.start();
 	}
+	
+	public void downloadAll(){
+		loadSettings();
+		ConnectionManager connectionManager = new ConnectionManager(this,
+				getUrl().getString(), getDhisUserName().getString(),
+				getDhisUserPass().getString(), getLocale().getString(),
+				ConnectionManager.DOWNLOAD_ALL);
+		connectionManager.start();
+	}
 
 	private void browsePrograms() {
 		loadSettings();
@@ -1898,9 +1930,10 @@
 					getErrorAlert().setString("FAILURE");
 					switchDisplayable(getErrorAlert(), getDsDnldList());
 				}
-				getSuccessAlert().setTitle("Download Status");
-				getSuccessAlert().setString("SUCCESS");
-				switchDisplayable(getSuccessAlert(), getPrDnldList());
+//				getSuccessAlert().setTitle("Download Status");
+//				getSuccessAlert().setString("SUCCESS");
+//				switchDisplayable(getSuccessAlert(), getPrDnldList());
+				switchDisplayable(getSuccessAlert(), getMainMenuList());
 
 			} catch (RecordStoreException rse) {
 			}
@@ -1926,7 +1959,8 @@
 		} else {
 			getErrorAlert().setTitle("Download Status");
 			getErrorAlert().setString("FAILURE");
-			switchDisplayable(getErrorAlert(), getMaintenanceList());
+//			switchDisplayable(getErrorAlert(), getMaintenanceList());
+			switchDisplayable(getErrorAlert(), getMainMenuList());
 		}
 	}
 

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/model/Activity.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/model/Activity.java	2010-10-19 09:32:21 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/model/Activity.java	2010-10-20 15:56:07 +0000
@@ -16,14 +16,27 @@
 
 	private Date dueDate;
 
+	private boolean late;
+	
 	public Activity() {
 	}
 
 	// Getter and Setter
+	
+	
+	
 	public Beneficiary getBeneficiary() {
 		return beneficiary;
 	}
 
+	public boolean isLate() {
+		return late;
+	}
+
+	public void setLate(boolean late) {
+		this.late = late;
+	}
+
 	public void setBeneficiary(Beneficiary beneficiary) {
 		this.beneficiary = beneficiary;
 	}
@@ -57,6 +70,7 @@
 			beneficiary.setLastName(din.readUTF());
 			beneficiary.setMiddleName(din.readUTF());
 			beneficiary.setFirstName(din.readUTF());
+			activity.setLate(din.readBoolean());
 			Vector atts = new Vector();
 			beneficiary.setAttsValues( atts );
 			int numAtt = din.readInt();
@@ -90,6 +104,7 @@
 			dout.writeUTF(activity.getBeneficiary().getLastName());
 			dout.writeUTF(activity.getBeneficiary().getMiddleName());
 			dout.writeUTF(activity.getBeneficiary().getFirstName());
+			dout.writeBoolean(activity.isLate());
 			Vector atts = activity.getBeneficiary().getAttsValues();
                         int numAtt = atts.size();
                         dout.writeInt(numAtt);

=== modified file 'DHISMobile/src/org/hisp/dhis/mobile/reporting/model/ActivityPlan.java'
--- DHISMobile/src/org/hisp/dhis/mobile/reporting/model/ActivityPlan.java	2010-10-19 18:02:48 +0000
+++ DHISMobile/src/org/hisp/dhis/mobile/reporting/model/ActivityPlan.java	2010-10-20 15:56:07 +0000
@@ -19,6 +19,7 @@
 
 	public void deSerialize(DataInputStream din) throws IOException {
 		int size = din.readInt();
+		System.out.println("number activities:"+size);
 
 		for (int i = 0; i < size; i++) {
 			Activity activity = new Activity();
@@ -29,8 +30,12 @@
 			b.setFirstName(din.readUTF());
 			b.setMiddleName(din.readUTF());
 			b.setLastName(din.readUTF());
+			boolean late = din.readBoolean();
+			System.out.println("deserialize late status:"+late);
+			activity.setLate(late);
+			
 			int attsNumb = din.readInt();
-
+			System.out.println("deserialized attribute number:"+attsNumb);
 			Vector attsVector = b.getAttsValues();
 
 			for (int j = 0; j < attsNumb; j++) {

=== modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml	2010-10-20 15:56:07 +0000
@@ -9,7 +9,7 @@
   </parent>
 
   <artifactId>dhis-web-api</artifactId>
-  <packaging>war</packaging>
+  <packaging>jar</packaging>
   <name>DHIS Web API</name>
 
   <build>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java	2010-10-20 11:54:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java	2010-10-20 15:56:07 +0000
@@ -58,18 +58,20 @@
         	
         	dout.writeLong(activity.getDueDate().getTime());
         	
+        	System.out.println("add beneficiary");        	
         	Beneficiary b = activity.getBeneficiary();
         	dout.writeInt(b.getId()); 
         	dout.writeUTF(b.getFirstName()); 
         	dout.writeUTF(b.getMiddleName()); 
         	dout.writeUTF(b.getLastName());
         	dout.writeBoolean(activity.isLate());
+        	System.out.println("add beneficiary att");
         	Set<String> atts = b.getPatientAttValues();
                 dout.writeInt( atts.size() );
                 for(String att : atts){
                     dout.writeUTF( att );
                 }
-        	
+            System.out.println("add task");
         	Task t = activity.getTask();
         	dout.writeInt(t.getId()); dout.writeInt(t.getProgramStageId()); dout.writeBoolean(t.isCompleted());           
         }      

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java	2010-10-20 15:56:07 +0000
@@ -47,18 +47,18 @@
     {
     	ByteArrayOutputStream bout = new ByteArrayOutputStream();
         DataOutputStream dout = new DataOutputStream(bout);       
-
+        System.out.println("add program info");
         dout.writeInt(this.getId());
         dout.writeUTF(this.getName());        
         dout.writeInt(programStages.size());
-
+        System.out.println("add program stages");
         for(int i=0; i<programStages.size(); i++)
         {
         	ProgramStage programStage = (ProgramStage)programStages.get(i);
         	programStage.serialize(dout);            
         }       
         
-        //bout.flush();
+        bout.flush();
         bout.writeTo(out);    	
     }        
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ProgramStage.java	2010-10-20 15:56:07 +0000
@@ -57,7 +57,7 @@
             dout.writeUTF( de.getType() );
         }       
         
-        //bout.flush();
+        bout.flush();
         bout.writeTo(out);    	
     } 
     
@@ -66,7 +66,7 @@
         dout.writeInt(this.getId());
         dout.writeUTF(this.getName());        
         dout.writeInt(dataElements.size());
-
+        System.out.println("add dataelement");
         for(int i=0; i<dataElements.size(); i++)
         {
             DataElement de = (DataElement)dataElements.get(i);

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ProgramResource.java	2010-10-20 15:56:07 +0000
@@ -30,7 +30,8 @@
 	@Produces( "application/vnd.org.dhis2.abstractmodellist+serialized" ) 
 	public AbstractModelList getAllMobileDataSets(@HeaderParam("accept-language") String locale) 
 	{	
-	    return iprogramService.getAllProgramsForLocale( locale );
+//	    return iprogramService.getAllProgramsForLocale( locale );
+		return null;
 	}	
 		
 	@GET 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java	2010-10-20 15:56:07 +0000
@@ -44,42 +44,65 @@
     // ProgramService
     // -------------------------------------------------------------------------
 	
-	public AbstractModelList getAllProgramsForLocale(String localeString) 
-	{
-		Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
-        OrganisationUnit unit = null;
-        
-        if( units.size() > 0 )
-        {
-        	unit = units.iterator().next();       	
-        }
-        else
-        {
-        	return null;
-        }
-        
-        Locale locale = LocaleUtil.getLocale(localeString);
-		
-		AbstractModelList abstractModelList = new AbstractModelList();
-
-		List<AbstractModel> abstractModels = new ArrayList<AbstractModel>();
-
-		for (org.hisp.dhis.program.Program program : programService.getPrograms(unit)) 
-		{			
-			program = i18n( i18nService, locale, program );		
-
-			AbstractModel abstractModel = new AbstractModel();
-
-			abstractModel.setId( program.getId());				
-			abstractModel.setName(program.getName());			
-
-			abstractModels.add(abstractModel);										
-		}
-		
-		abstractModelList.setAbstractModels(abstractModels);
-		
-		return abstractModelList;
-	}
+//	public AbstractModelList getAllProgramsForLocale(String localeString) 
+//	{
+//		Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+//        OrganisationUnit unit = null;
+//        
+//        if( units.size() > 0 )
+//        {
+//        	unit = units.iterator().next();       	
+//        }
+//        else
+//        {
+//        	return null;
+//        }
+//        
+//        Locale locale = LocaleUtil.getLocale(localeString);
+//		
+//		AbstractModelList abstractModelList = new AbstractModelList();
+//
+//		List<AbstractModel> abstractModels = new ArrayList<AbstractModel>();
+//
+//		for (org.hisp.dhis.program.Program program : programService.getPrograms(unit)) 
+//		{			
+//			program = i18n( i18nService, locale, program );		
+//
+//			AbstractModel abstractModel = new AbstractModel();
+//
+//			abstractModel.setId( program.getId());				
+//			abstractModel.setName(program.getName());			
+//
+//			abstractModels.add(abstractModel);										
+//		}
+//		
+//		abstractModelList.setAbstractModels(abstractModels);
+//		
+//		return abstractModelList;
+//	}
+	
+	public List<Program> getAllProgramsForLocale(String localeString) 
+    {
+            List<Program> programs = new ArrayList<Program>();
+            
+            Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+            OrganisationUnit unit = null;
+    
+            if( units.size() > 0 )
+            {
+                    unit = units.iterator().next();         
+            }
+            else
+            {
+                    return null;
+            }
+            for (org.hisp.dhis.program.Program program : programService.getPrograms(unit)) 
+            {                       
+                programs.add(getProgramForLocale( program.getId() , localeString));                                                                              
+            }
+
+            return programs;
+    }
 	
 	public Program getProgramForLocale(int programId, String localeString) 
 	{

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java	2010-10-20 15:56:07 +0000
@@ -3,6 +3,8 @@
  */
 package org.hisp.dhis.web.api.service;
 
+import java.util.List;
+
 import org.hisp.dhis.web.api.model.AbstractModelList;
 import org.hisp.dhis.web.api.model.Program;
 
@@ -12,7 +14,7 @@
  */
 public interface IProgramService {
 	
-	AbstractModelList getAllProgramsForLocale( String localeString );
+	List<Program> getAllProgramsForLocale( String localeString );
 	
 	Program getProgramForLocale( int programId, String localeString );
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-10-20 15:56:07 +0000
@@ -22,10 +22,11 @@
 	<bean id="org.hisp.dhis.web.api.consumer.DataSetValueConsumer"
 		class="org.hisp.dhis.web.api.consumer.DataSetValueConsumer" scope="singleton"/>
 		
+	<bean id="org.hisp.dhis.web.api.provider.ActivityWrapperProvider"
+		class="org.hisp.dhis.web.api.provider.ActivityWrapperProvider" scope="singleton"/>	
+		
 	<bean id="org.hisp.dhis.web.api.consumer.ActivityValueConsumer"
-		class="org.hisp.dhis.web.api.consumer.ActivityValueConsumer" scope="singleton"/>	
-		
-		
+		class="org.hisp.dhis.web.api.consumer.ActivityValueConsumer" scope="singleton"/>
 	<!-- Resources -->
 	
 	<bean id="org.hisp.dhis.web.api.resources.UserResource"
@@ -47,7 +48,9 @@
     <bean id="org.hisp.dhis.web.api.resources.ActivityPlanResource"
       class="org.hisp.dhis.web.api.resources.ActivityPlanResource" scope="prototype"/>  
 	
-	
+	<bean id="org.hisp.dhis.web.api.resources.ActivityWrapperResource"
+      class="org.hisp.dhis.web.api.resources.ActivityWrapperResource" scope="prototype"/>  
+      
 	<!-- Services -->
 	
 	<bean id="org.hisp.dhis.web.api.service.ActivityPlanModelService"