← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2014: [DHIS Mobile] Import data value with different Category Option Combo

 

------------------------------------------------------------
revno: 2014
committer: Long <thanhlongngo1988>
branch nick: dhis2
timestamp: Tue 2010-11-09 09:53:08 +0700
message:
  [DHIS Mobile] Import data value with different Category Option Combo
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataValueService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultPeriodService.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 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/AbstractModelList.java	2010-11-09 02:53:08 +0000
@@ -14,71 +14,77 @@
 import java.util.List;
 
 /**
- *
+ * 
  * @author abyotag_adm
  */
-public class AbstractModelList implements ISerializable {
-
-    private List<AbstractModel> abstractModels;    
-    
-
-    public List<AbstractModel> getAbstractModels() {
-		return abstractModels;
-	}
-
-	public void setAbstractModels(List<AbstractModel> abstractModels) {
-		this.abstractModels = abstractModels;
-	}
-
-	public byte[] serialize() throws IOException
+public class AbstractModelList
+    implements ISerializable
+{
+
+    private List<AbstractModel> abstractModels;
+
+    public List<AbstractModel> getAbstractModels()
+    {
+        return abstractModels;
+    }
+
+    public void setAbstractModels( List<AbstractModel> abstractModels )
+    {
+        this.abstractModels = abstractModels;
+    }
+
+    public byte[] serialize()
+        throws IOException
     {
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        DataOutputStream dout = new DataOutputStream(bout);
-        
-        dout.writeInt(abstractModels.size());
-
-        for(int i=0; i<abstractModels.size(); i++)
+        DataOutputStream dout = new DataOutputStream( bout );
+
+        dout.writeInt( abstractModels.size() );
+
+        for ( int i = 0; i < abstractModels.size(); i++ )
         {
-        	AbstractModel abstractModel = (AbstractModel)abstractModels.get(i);
+            AbstractModel abstractModel = (AbstractModel) abstractModels.get( i );
             dout.writeInt( abstractModel.getId() );
-            dout.writeUTF( abstractModel.getName() );            
+            dout.writeUTF( abstractModel.getName() );
         }
 
         return bout.toByteArray();
     }
 
-    public void deSerialize(byte[] data) throws IOException
+    public void deSerialize( byte[] data )
+        throws IOException
     {
-        ByteArrayInputStream bin = new ByteArrayInputStream(data);
-        DataInputStream din = new DataInputStream(bin);       
+        ByteArrayInputStream bin = new ByteArrayInputStream( data );
+        DataInputStream din = new DataInputStream( bin );
 
         int size = din.readInt();
 
-        for(int i=0; i<size; i++)
+        for ( int i = 0; i < size; i++ )
         {
-        	AbstractModel abstractModel = new AbstractModel();
-        	abstractModel.setId( din.readInt() );
-        	abstractModel.setName( din.readUTF() );            
-            this.abstractModels.add(abstractModel);
+            AbstractModel abstractModel = new AbstractModel();
+            abstractModel.setId( din.readInt() );
+            abstractModel.setName( din.readUTF() );
+            this.abstractModels.add( abstractModel );
         }
     }
-    
-    public void serialize( OutputStream out ) throws IOException
+
+    public void serialize( OutputStream out )
+        throws IOException
     {
-    	ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        DataOutputStream dout = new DataOutputStream(bout);       
-
-        dout.writeInt(abstractModels.size());
-
-        for(int i=0; i<abstractModels.size(); i++)
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        DataOutputStream dout = new DataOutputStream( bout );
+
+        dout.writeInt( abstractModels.size() );
+
+        for ( int i = 0; i < abstractModels.size(); i++ )
         {
-        	AbstractModel abstractModel = (AbstractModel)abstractModels.get(i);
+            AbstractModel abstractModel = (AbstractModel) abstractModels.get( i );
             dout.writeInt( abstractModel.getId() );
-            dout.writeUTF( abstractModel.getName() );            
-        }       
-        
-        //bout.flush();
-        bout.writeTo(out);
-    	
-    }	
+            dout.writeUTF( abstractModel.getName() );
+        }
+
+        // bout.flush();
+        bout.writeTo( out );
+
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java	2010-11-02 03:53:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java	2010-11-09 02:53:08 +0000
@@ -69,6 +69,7 @@
         {
             DataValue dv = (DataValue)dataValues.get(i);
             dout.writeInt( dv.getId() );
+            dout.writeInt( dv.getCategoryOptComboID() );
             dout.writeUTF( dv.getVal() );            
         }
 
@@ -90,6 +91,7 @@
         {
             DataValue dv = new DataValue();
             dv.setId( din.readInt() );
+            dv.setCategoryOptComboID( din.readInt() );
             dv.setVal( din.readUTF() );            
             this.dataValues.add(dv);
         }
@@ -109,6 +111,7 @@
         {
             DataValue dv = new DataValue();
             dv.setId( din.readInt() );
+            dv.setCategoryOptComboID( din.readInt() );
             dv.setVal( din.readUTF() );            
             this.dataValues.add(dv);
         }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java	2010-11-09 02:53:08 +0000
@@ -6,39 +6,61 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlType;
 
-@XmlType(name = "dv")
-@XmlAccessorType(XmlAccessType.FIELD) 
-public class DataValue implements ISerializable {
-	
-	private int id;
-	
-	private String val;
-
-	public int getId() {
-		return id;
-	}
-
-	public void setId(int id) {
-		this.id = id;
-	}
-
-	public String getVal() {
-		return val;
-	}
-
-	public void setVal(String val) {
-		this.val = val;
-	}
-
-	@Override
-	public byte[] serialize() throws IOException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void deSerialize(byte[] data) throws IOException {
-		// TODO Auto-generated method stub
-		
-	}	
+@XmlType( name = "dv" )
+@XmlAccessorType( XmlAccessType.FIELD )
+public class DataValue
+    implements ISerializable
+{
+
+    private int id;
+
+    private int categoryOptComboID;
+
+    private String val;
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getVal()
+    {
+        return val;
+    }
+
+    public void setVal( String val )
+    {
+        this.val = val;
+    }
+
+    public int getCategoryOptComboID()
+    {
+        return categoryOptComboID;
+    }
+
+    public void setCategoryOptComboID( int categoryOptComboID )
+    {
+        this.categoryOptComboID = categoryOptComboID;
+    }
+
+    @Override
+    public byte[] serialize()
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void deSerialize( byte[] data )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java	2010-10-20 12:54:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java	2010-11-09 02:53:08 +0000
@@ -25,42 +25,44 @@
 
 /**
  * @author abyotag_adm
- *
+ * 
  */
-public class DefaultActivityPlanService implements IActivityPlanService {
+public class DefaultActivityPlanService
+    implements IActivityPlanService
+{
 
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	
-	@Autowired
-	private org.hisp.dhis.activityplan.ActivityPlanService activityPlanService;
-	
-	@Autowired
-        private PatientAttributeValueService patientAttValueService ;
-	
-	@Autowired
+
+    @Autowired
+    private org.hisp.dhis.activityplan.ActivityPlanService activityPlanService;
+
+    @Autowired
+    private PatientAttributeValueService patientAttValueService;
+
+    @Autowired
     private CurrentUserService currentUserService;
-	
-	// -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
     // MobileDataSetService
-    // -------------------------------------------------------------------------	
-	
-	public ActivityPlan getCurrentActivityPlan(String localeString) 
-	{
-		Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+    // -------------------------------------------------------------------------
+
+    public ActivityPlan getCurrentActivityPlan( String localeString )
+    {
+        Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
         OrganisationUnit unit = null;
-        
-        if( units.size() > 0 )
+
+        if ( units.size() > 0 )
         {
-        	unit = units.iterator().next();       	
+            unit = units.iterator().next();
         }
         else
         {
-        	return null;
-        }		
-		
-		DateTime dt = new DateTime();
+            return null;
+        }
+
+        DateTime dt = new DateTime();
         DateMidnight from = dt.withDayOfMonth( 1 ).toDateMidnight();
         DateMidnight to = from.plusMonths( 1 );
 
@@ -73,69 +75,71 @@
         int i = 0;
         for ( Activity activity : allActivities )
         {
-            //there are error on db with patientattributeid 14, so I limit the patient to be downloaded
-            if(i++>10){
-            	break;
+            // there are error on db with patientattributeid 14, so I limit the
+            // patient to be downloaded
+            if ( i++ > 10 )
+            {
+                break;
             }
 
-        	long dueTime = activity.getDueDate().getTime();
+            long dueTime = activity.getDueDate().getTime();
             if ( to.isBefore( dueTime ) )
             {
                 continue;
             }
-            
-            if (from.isBefore( dueTime )) {
-                items.add( getActivityModel( activity) );
-            } else if (!activity.getTask().isCompleted()) {
-            	org.hisp.dhis.web.api.model.Activity a = getActivityModel( activity);
-            	items.add( a );
-            	a.setLate(true);
-            }
-        }
-        if (!items.isEmpty()) {
-        	plan.setActivitiesList( items );
-        }
-        
+
+            if ( from.isBefore( dueTime ) )
+            {
+                items.add( getActivityModel( activity ) );
+            }
+            else if ( !activity.getTask().isCompleted() )
+            {
+                org.hisp.dhis.web.api.model.Activity a = getActivityModel( activity );
+                items.add( a );
+                a.setLate( true );
+            }
+        }
+        if ( !items.isEmpty() )
+        {
+            plan.setActivitiesList( items );
+        }
+
         return plan;
-	}
-	
-
-		private org.hisp.dhis.web.api.model.Activity getActivityModel( org.hisp.dhis.activityplan.Activity activity )
-        {
-            if ( activity == null )
-            {
-                return null;
-            }
-            org.hisp.dhis.web.api.model.Activity item = new org.hisp.dhis.web.api.model.Activity();
-            Patient patient = activity.getBeneficiary();
-            
-            item.setBeneficiary( getBeneficiaryModel(patient) );
-            item.setDueDate( activity.getDueDate() );
-            item.setTask( new TaskMapper().getModel( activity.getTask()) );
-            return item;
-        }
-        
-        
-        
-        private org.hisp.dhis.web.api.model.Beneficiary getBeneficiaryModel( Patient patient )
-        {
-            
-
-            Beneficiary beneficiary = new Beneficiary();
-
-            Set<String> patientAttValues = new HashSet<String>();
-            
-            
-            beneficiary.setId( patient.getId() );
-            beneficiary.setFirstName( patient.getFirstName() );
-            beneficiary.setLastName( patient.getLastName() );
-            beneficiary.setMiddleName( patient.getMiddleName() );
-            
-            for(PatientAttributeValue value : patientAttValueService.getPatientAttributeValues( patient )){
-                patientAttValues.add( value.getPatientAttribute().getName() +" : "+ value.getValue());
-            }
-            beneficiary.setPatientAttValues( patientAttValues );
-            
-            return beneficiary;
-        }
+    }
+
+    private org.hisp.dhis.web.api.model.Activity getActivityModel( org.hisp.dhis.activityplan.Activity activity )
+    {
+        if ( activity == null )
+        {
+            return null;
+        }
+        org.hisp.dhis.web.api.model.Activity item = new org.hisp.dhis.web.api.model.Activity();
+        Patient patient = activity.getBeneficiary();
+
+        item.setBeneficiary( getBeneficiaryModel( patient ) );
+        item.setDueDate( activity.getDueDate() );
+        item.setTask( new TaskMapper().getModel( activity.getTask() ) );
+        return item;
+    }
+
+    private org.hisp.dhis.web.api.model.Beneficiary getBeneficiaryModel( Patient patient )
+    {
+
+        Beneficiary beneficiary = new Beneficiary();
+
+        Set<String> patientAttValues = new HashSet<String>();
+
+        beneficiary.setId( patient.getId() );
+        beneficiary.setFirstName( patient.getFirstName() );
+        beneficiary.setLastName( patient.getLastName() );
+        beneficiary.setMiddleName( patient.getMiddleName() );
+
+        for ( PatientAttributeValue value : patientAttValueService.getPatientAttributeValues( patient ) )
+        {
+            patientAttValues.add( value.getPatientAttribute().getName() + " : " + value.getValue() );
+        }
+        beneficiary.setPatientAttValues( patientAttValues );
+
+        return beneficiary;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java	2010-11-08 03:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataSetService.java	2010-11-09 02:53:08 +0000
@@ -5,6 +5,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
@@ -21,165 +22,176 @@
 import org.hisp.dhis.web.api.utils.LocaleUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 
-public class DefaultDataSetService implements IDataSetService {
-	
-	// -------------------------------------------------------------------------
-        // Dependencies
-        // -------------------------------------------------------------------------
-	private DataElementSortOrderComparator dataElementComparator = new DataElementSortOrderComparator();
-	
-	@Autowired
-	private org.hisp.dhis.dataset.DataSetService dataSetService;
-	
-	@Autowired
-	private org.hisp.dhis.i18n.I18nService i18nService;	
-	
-	@Autowired
-        private CurrentUserService currentUserService;
-	
-	
-	// -------------------------------------------------------------------------
-        // MobileDataSetService
-        // -------------------------------------------------------------------------
-
-	public List<DataSet> getAllMobileDataSetsForLocale(String localeString) {
-		Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+public class DefaultDataSetService
+    implements IDataSetService
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    private DataElementSortOrderComparator dataElementComparator = new DataElementSortOrderComparator();
+
+    @Autowired
+    private org.hisp.dhis.dataset.DataSetService dataSetService;
+
+    @Autowired
+    private org.hisp.dhis.i18n.I18nService i18nService;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
+    // -------------------------------------------------------------------------
+    // MobileDataSetService
+    // -------------------------------------------------------------------------
+
+    public List<DataSet> getAllMobileDataSetsForLocale( String localeString )
+    {
+        Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+
         OrganisationUnit unit = null;
-        
-        if( units.size() > 0 )
-        {
-        	unit = units.iterator().next();       	
-        }
-        else
-        {
-        	return null;
-        }
-		
-		List<DataSet> datasets = new ArrayList<DataSet>();
-		Locale locale = LocaleUtil.getLocale(localeString);			
-//		AbstractModelList abstractModelList = new AbstractModelList();
-//
-//		List<AbstractModel> abstractModels = new ArrayList<AbstractModel>();
-//
-		for (org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile(unit)) 
-		{			
-			if( dataSet.getPeriodType().getName().equals( "Daily") ||
-					dataSet.getPeriodType().getName().equals( "Weekly") ||
-					dataSet.getPeriodType().getName().equals( "Monthly") ||
-					dataSet.getPeriodType().getName().equals( "Yearly") || 
-					dataSet.getPeriodType().getName().equals("Quarterly") )
-			{
-				datasets.add(getDataSetForLocale(dataSet.getId(),locale));
-			}
-		}
-//		
-//		abstractModelList.setAbstractModels(abstractModels);
-		
-		return datasets;
-	}
-
-	public DataSet getDataSetForLocale(int dataSetId, Locale locale) {
-		org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetId );
-		dataSet = i18n( i18nService, locale, dataSet );
-		Set<org.hisp.dhis.dataset.Section> sections = dataSet.getSections();
-		
-//		Collection<org.hisp.dhis.dataelement.DataElement> dataElements = dataSet.getDataElements();
-
-		//Mobile
-		DataSet ds = new DataSet();
-		
-		ds.setId( dataSet.getId() );			
-		ds.setName( dataSet.getName() );
-		ds.setPeriodType( dataSet.getPeriodType().getName() );
-		
-		//Mobile
-		List<Section> sectionList = new ArrayList<Section>(); 
-		ds.setSections(sectionList);
-		
-		
-		
-			if(sections.size() == 0 || sections == null){
-//				Collection<org.hisp.dhis.dataelement.DataElement> dataElements = new ArrayList<org.hisp.dhis.dataelement.DataElement>();
-				List<org.hisp.dhis.dataelement.DataElement> dataElements = new ArrayList<org.hisp.dhis.dataelement.DataElement>(dataSet.getDataElements());
-									
-				Collections.sort(dataElements, dataElementComparator);
-				
-				//Fake Section to store Data Elements
-				Section section = new Section();
-				
-				sectionList.add(section);
-				section.setId(0);
-				section.setName("");
-				
-				List<DataElement> dataElementList = new ArrayList<DataElement>();
-				section.setDes(dataElementList);
-				
-				for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
-				{
-				        //Server DataElement
-				        dataElement = i18n( i18nService, locale, dataElement );
-				        Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
-				        //Client DataElement
-				        AbstractModelList deCateOptCombo = new AbstractModelList();
-				        List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
-				        deCateOptCombo.setAbstractModels( listCateOptCombo );
-				        
-				        for(DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs){				                
-				                AbstractModel oneCateOptCombo = new AbstractModel();
-				                oneCateOptCombo.setId( oneCatOptCombo.getId() );
-				                oneCateOptCombo.setName( oneCatOptCombo.getName() );
-				                listCateOptCombo.add( oneCateOptCombo );
-	                                }
-				        
-					DataElement de = new DataElement();
-					de.setId( dataElement.getId() );
-					de.setName( dataElement.getName() );
-					de.setType( dataElement.getType() );
-					de.setCategoryOptionCombos( deCateOptCombo );
-					dataElementList.add( de );
-				}
-			}else{
-				for(org.hisp.dhis.dataset.Section each : sections){
-				List<org.hisp.dhis.dataelement.DataElement> dataElements = each.getDataElements();
-				
-				Section section = new Section();
-				section.setId(each.getId());
-				section.setName(each.getName());
-				//Mobile
-				List<DataElement> dataElementList = new ArrayList<DataElement>();
-				section.setDes(dataElementList);
-				
-				
-				for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
-				{
-				        //Server DataElement
-					dataElement = i18n( i18nService, locale, dataElement );
-					Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
-					
-					//Client DataElement
-                                        AbstractModelList deCateOptCombo = new AbstractModelList();
-                                        List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
-                                        deCateOptCombo.setAbstractModels( listCateOptCombo );
-                                        
-                                        for(DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs){                                             
-                                            AbstractModel oneCateOptCombo = new AbstractModel();
-                                            oneCateOptCombo.setId( oneCatOptCombo.getId() );
-                                            oneCateOptCombo.setName( oneCatOptCombo.getName() );
-                                            listCateOptCombo.add( oneCateOptCombo );
-                                        }
-                                        
-					DataElement de = new DataElement();
-					de.setId( dataElement.getId() );
-					de.setName( dataElement.getName() );
-					de.setType( dataElement.getType() );
-					de.setCategoryOptionCombos( deCateOptCombo );
-					dataElementList.add( de );
-				}
-				sectionList.add(section);
-			}
-		}		
-		
-		return ds;
-	}	
-	
+
+        if ( units.size() > 0 )
+        {
+            unit = units.iterator().next();
+        }
+        else
+        {
+            return null;
+        }
+
+        List<DataSet> datasets = new ArrayList<DataSet>();
+        Locale locale = LocaleUtil.getLocale( localeString );
+        // AbstractModelList abstractModelList = new AbstractModelList();
+        //
+        // List<AbstractModel> abstractModels = new ArrayList<AbstractModel>();
+        //
+        for ( org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile( unit ) )
+        {
+            if ( dataSet.getPeriodType().getName().equals( "Daily" )
+                || dataSet.getPeriodType().getName().equals( "Weekly" )
+                || dataSet.getPeriodType().getName().equals( "Monthly" )
+                || dataSet.getPeriodType().getName().equals( "Yearly" )
+                || dataSet.getPeriodType().getName().equals( "Quarterly" ) )
+            {
+                datasets.add( getDataSetForLocale( dataSet.getId(), locale ) );
+            }
+        }
+        //
+        // abstractModelList.setAbstractModels(abstractModels);
+
+        return datasets;
+    }
+
+    public DataSet getDataSetForLocale( int dataSetId, Locale locale )
+    {
+        org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetId );
+        dataSet = i18n( i18nService, locale, dataSet );
+        Set<org.hisp.dhis.dataset.Section> sections = dataSet.getSections();
+
+        // Collection<org.hisp.dhis.dataelement.DataElement> dataElements =
+        // dataSet.getDataElements();
+
+        // Mobile
+        DataSet ds = new DataSet();
+
+        ds.setId( dataSet.getId() );
+        ds.setName( dataSet.getName() );
+        ds.setPeriodType( dataSet.getPeriodType().getName() );
+
+        // Mobile
+        List<Section> sectionList = new ArrayList<Section>();
+        ds.setSections( sectionList );
+
+        if ( sections.size() == 0 || sections == null )
+        {
+            // Collection<org.hisp.dhis.dataelement.DataElement> dataElements =
+            // new ArrayList<org.hisp.dhis.dataelement.DataElement>();
+            List<org.hisp.dhis.dataelement.DataElement> dataElements = new ArrayList<org.hisp.dhis.dataelement.DataElement>(
+                dataSet.getDataElements() );
+
+            Collections.sort( dataElements, dataElementComparator );
+
+            // Fake Section to store Data Elements
+            Section section = new Section();
+
+            sectionList.add( section );
+            section.setId( 0 );
+            section.setName( "" );
+
+            List<DataElement> dataElementList = new ArrayList<DataElement>();
+            section.setDes( dataElementList );
+
+            for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
+            {
+                // Server DataElement
+                dataElement = i18n( i18nService, locale, dataElement );
+                Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
+                // Client DataElement
+                AbstractModelList deCateOptCombo = new AbstractModelList();
+                List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
+                deCateOptCombo.setAbstractModels( listCateOptCombo );
+
+                for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
+                {
+                    AbstractModel oneCateOptCombo = new AbstractModel();
+                    oneCateOptCombo.setId( oneCatOptCombo.getId() );
+                    oneCateOptCombo.setName( oneCatOptCombo.getName() );
+                    listCateOptCombo.add( oneCateOptCombo );
+                }
+
+                DataElement de = new DataElement();
+                de.setId( dataElement.getId() );
+                de.setName( dataElement.getName() );
+                de.setType( dataElement.getType() );
+                de.setCategoryOptionCombos( deCateOptCombo );
+                dataElementList.add( de );
+            }
+        }
+        else
+        {
+            for ( org.hisp.dhis.dataset.Section each : sections )
+            {
+                List<org.hisp.dhis.dataelement.DataElement> dataElements = each.getDataElements();
+
+                Section section = new Section();
+                section.setId( each.getId() );
+                section.setName( each.getName() );
+                // Mobile
+                List<DataElement> dataElementList = new ArrayList<DataElement>();
+                section.setDes( dataElementList );
+
+                for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
+                {
+                    // Server DataElement
+                    dataElement = i18n( i18nService, locale, dataElement );
+                    Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo()
+                        .getOptionCombos();
+
+                    // Client DataElement
+                    AbstractModelList deCateOptCombo = new AbstractModelList();
+                    List<AbstractModel> listCateOptCombo = new ArrayList<AbstractModel>();
+                    deCateOptCombo.setAbstractModels( listCateOptCombo );
+
+                    for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
+                    {
+                        AbstractModel oneCateOptCombo = new AbstractModel();
+                        oneCateOptCombo.setId( oneCatOptCombo.getId() );
+                        oneCateOptCombo.setName( oneCatOptCombo.getName() );
+                        listCateOptCombo.add( oneCateOptCombo );
+                    }
+
+                    DataElement de = new DataElement();
+                    de.setId( dataElement.getId() );
+                    de.setName( dataElement.getName() );
+                    de.setType( dataElement.getType() );
+                    de.setCategoryOptionCombos( deCateOptCombo );
+                    dataElementList.add( de );
+                }
+                sectionList.add( section );
+            }
+        }
+
+        return ds;
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataValueService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataValueService.java	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultDataValueService.java	2010-11-09 02:53:08 +0000
@@ -15,137 +15,140 @@
 import org.hisp.dhis.web.api.model.DataValue;
 import org.springframework.beans.factory.annotation.Autowired;
 
-public class DefaultDataValueService implements IDataValueService {
+public class DefaultDataValueService
+    implements IDataValueService
+{
 
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	
-	@Autowired
-	private org.hisp.dhis.dataset.DataSetService dataSetService;
-	
-	@Autowired
-	private IPeriodService periodService;
-	
-	@Autowired
-	private org.hisp.dhis.dataelement.DataElementCategoryService categoryService;
-	
-	@Autowired
-	private org.hisp.dhis.datavalue.DataValueService dataValueService;
-	
-	@Autowired
+
+    @Autowired
+    private org.hisp.dhis.dataset.DataSetService dataSetService;
+
+    @Autowired
+    private IPeriodService periodService;
+
+    @Autowired
+    private org.hisp.dhis.dataelement.DataElementCategoryService categoryService;
+
+    @Autowired
+    private org.hisp.dhis.datavalue.DataValueService dataValueService;
+
+    @Autowired
     private CurrentUserService currentUserService;
-	
-	
-	// -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
     // DataValueService
     // -------------------------------------------------------------------------
 
+    @Override
+    public String saveValues( DataSetValue dataSetValue )
+    {
 
-	@Override
-	public String saveValues(DataSetValue dataSetValue) {
-		
-		Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
+        Collection<OrganisationUnit> units = currentUserService.getCurrentUser().getOrganisationUnits();
         OrganisationUnit unit = null;
-        
-        if( units.size() > 0 )
+
+        if ( units.size() > 0 )
         {
-        	unit = units.iterator().next();       	
+            unit = units.iterator().next();
         }
         else
         {
-        	return "INVALID_REPORTING_UNIT";
-        }
-		
-		org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetValue.getId() );
-		
-		if( !dataSetService.getDataSetsBySource( unit ).contains( dataSet) )
-		{
-			return "INVALID_DATASET_ASSOCIATION";
-		}
-		
-		org.hisp.dhis.period.Period selectedPeriod = periodService.getPeriod( dataSetValue.getpName(), dataSet );
-		
-		if( selectedPeriod == null )
-		{
-			return "INVALID_PERIOD";
-		}
-		
-		Collection<org.hisp.dhis.dataelement.DataElement> dataElements = dataSet.getDataElements();			
-		Collection<Integer> dataElementIds = new ArrayList<Integer>(dataSetValue.getDataValues().size());
-		
-		for( DataValue dv : dataSetValue.getDataValues() )
-		{
-			dataElementIds.add( dv.getId() );		
-		}
-		
-		if( dataElements.size() != dataElementIds.size() )
-		{
-			return "INVALID_DATASET";
-		}
-		
-		Map<Integer, org.hisp.dhis.dataelement.DataElement> dataElementMap = new HashMap<Integer, org.hisp.dhis.dataelement.DataElement>();
-		for( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
-		{
-			if( !dataElementIds.contains( dataElement.getId()) )
-			{
-				return "INVALID_DATASET";
-			}
-			dataElementMap.put(dataElement.getId(), dataElement);
-		}
-		
-		//Everything is fine, hence save		
-		saveDataValues( dataSetValue, dataElementMap, selectedPeriod, unit, categoryService.getDefaultDataElementCategoryOptionCombo() );		
-		
-		return "SUCCESS";
-		
-	}
-	
-	// -------------------------------------------------------------------------
+            return "INVALID_REPORTING_UNIT";
+        }
+
+        org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetValue.getId() );
+
+        if ( !dataSetService.getDataSetsBySource( unit ).contains( dataSet ) )
+        {
+            return "INVALID_DATASET_ASSOCIATION";
+        }
+
+        org.hisp.dhis.period.Period selectedPeriod = periodService.getPeriod( dataSetValue.getpName(), dataSet );
+
+        if ( selectedPeriod == null )
+        {
+            return "INVALID_PERIOD";
+        }
+
+        Collection<org.hisp.dhis.dataelement.DataElement> dataElements = dataSet.getDataElements();
+        Collection<Integer> dataElementIds = new ArrayList<Integer>( dataSetValue.getDataValues().size() );
+
+        for ( DataValue dv : dataSetValue.getDataValues() )
+        {
+            dataElementIds.add( dv.getId() );
+        }
+
+//        if ( dataElements.size() != dataElementIds.size() )
+//        {
+//            return "INVALID_DATASET";
+//        }
+
+        Map<Integer, org.hisp.dhis.dataelement.DataElement> dataElementMap = new HashMap<Integer, org.hisp.dhis.dataelement.DataElement>();
+        for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
+        {
+            if ( !dataElementIds.contains( dataElement.getId() ) )
+            {
+                return "INVALID_DATASET";
+            }
+            dataElementMap.put( dataElement.getId(), dataElement );
+        }
+
+        // Everything is fine, hence save
+        saveDataValues( dataSetValue, dataElementMap, selectedPeriod, unit,
+            categoryService.getDefaultDataElementCategoryOptionCombo() );
+
+        return "SUCCESS";
+
+    }
+
+    // -------------------------------------------------------------------------
     // Supportive method
     // -------------------------------------------------------------------------
-	
-	
-	private void saveDataValues(DataSetValue dataSetValue,
-			Map<Integer, DataElement> dataElementMap, Period period,
-			OrganisationUnit orgUnit, DataElementCategoryOptionCombo optionCombo) {
-		
-		
-		org.hisp.dhis.dataelement.DataElement dataElement;
-		String value;
-		
-		for( DataValue dv : dataSetValue.getDataValues() )
-		{			
-			value = dv.getVal();		
-			
-			if ( value != null && value.trim().length() == 0 )
-	        {				
-	            value = null;
-	        }
-	        
-	        if ( value != null )
-	        {
-	            value = value.trim();
-	        }
-			
-			dataElement = dataElementMap.get( dv.getId() );
-			org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, optionCombo );
-			
-			if ( dataValue == null )												
-	        {		
-				if( value != null )
-				{
-					dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, orgUnit, value, "", new Date(), "", optionCombo );
-	                dataValueService.addDataValue( dataValue );
-				}				
-	        }
-	        else
-	        {            
-	            dataValue.setValue( value );
-	            dataValue.setTimestamp( new Date() );
-	            dataValueService.updateDataValue( dataValue );            
-	        }				
-			
-		}		
-	}
+
+    private void saveDataValues( DataSetValue dataSetValue, Map<Integer, DataElement> dataElementMap, Period period,
+        OrganisationUnit orgUnit, DataElementCategoryOptionCombo optionCombo )
+    {
+
+        org.hisp.dhis.dataelement.DataElement dataElement;
+        String value;
+
+        for ( DataValue dv : dataSetValue.getDataValues() )
+        {
+            value = dv.getVal();
+            DataElementCategoryOptionCombo cateOptCombo = categoryService.getDataElementCategoryOptionCombo( dv
+                .getCategoryOptComboID() );
+            if ( value != null && value.trim().length() == 0 )
+            {
+                value = null;
+            }
+
+            if ( value != null )
+            {
+                value = value.trim();
+            }
+
+            dataElement = dataElementMap.get( dv.getId() );
+            org.hisp.dhis.datavalue.DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period,
+                cateOptCombo );
+
+            if ( dataValue == null )
+            {
+                if ( value != null )
+                {
+                    dataValue = new org.hisp.dhis.datavalue.DataValue( dataElement, period, orgUnit, value, "",
+                        new Date(), "", cateOptCombo );
+                    dataValueService.addDataValue( dataValue );
+                }
+            }
+            else
+            {
+                dataValue.setValue( value );
+                dataValue.setTimestamp( new Date() );
+                dataValueService.updateDataValue( dataValue );
+            }
+
+        }
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultPeriodService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultPeriodService.java	2010-11-04 09:49:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultPeriodService.java	2010-11-09 02:53:08 +0000
@@ -19,127 +19,149 @@
 
 /**
  * @author abyotag_adm
- *
+ * 
  */
-public class DefaultPeriodService implements IPeriodService {
+public class DefaultPeriodService
+    implements IPeriodService
+{
 
-	// -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-	
-	@Autowired
-	private org.hisp.dhis.period.PeriodService periodService;
-	
-	
-	// -------------------------------------------------------------------------
+
+    @Autowired
+    private org.hisp.dhis.period.PeriodService periodService;
+
+    // -------------------------------------------------------------------------
     // PeriodService
     // -------------------------------------------------------------------------
-	
-	
-	public Period getPeriod(String periodName, DataSet dataSet) {
-		org.hisp.dhis.period.Period period = null;
-		org.hisp.dhis.period.Period persistedPeriod = null;
-		if( dataSet.getPeriodType().getName().equals("Daily"))
-		{
-			String pattern = "yyyy-MM-dd";
-		    SimpleDateFormat formatter = new SimpleDateFormat(pattern);		    
-		    Date date = new Date();
-			
-		    try {
-				
-		    	date = formatter.parse(periodName);				
-				DailyPeriodType dailyPeriodType = new DailyPeriodType();
-				period = dailyPeriodType.createPeriod(date);
-				
-			} catch (ParseException e) {				
-				e.printStackTrace();
-			}					
-		}
-		else if( dataSet.getPeriodType().getName().equals("Weekly"))
-		{			
-			try{
-				int week = Integer.parseInt( periodName.substring(0,periodName.indexOf('-')) );
-				int year = Integer.parseInt( periodName.substring(periodName.indexOf('-') + 1, periodName.length()) );
-				
-				Calendar cal = Calendar.getInstance();								
-				cal.set( Calendar.YEAR, year );
-				cal.set( Calendar.WEEK_OF_YEAR, week );	
-				cal.setFirstDayOfWeek(Calendar.MONDAY);	
-		        
-		        WeeklyPeriodType weeklyPeriodType = new WeeklyPeriodType();				
-				period = weeklyPeriodType.createPeriod( cal.getTime() );				
-				
-			}catch(Exception e)
-			{
-				e.printStackTrace();
-			}			
-		}
-		
-		else if( dataSet.getPeriodType().getName().equals("Monthly"))
-		{			
-			try{
-				int month = Integer.parseInt( periodName.substring(0,periodName.indexOf('-')) );
-				int year = Integer.parseInt( periodName.substring(periodName.indexOf('-') + 1, periodName.length()) );
-				
-				Calendar cal = Calendar.getInstance();
-				cal.set( Calendar.YEAR, year );
-				cal.set( Calendar.MONTH, month );				
-				
-				MonthlyPeriodType monthlyPeriodType = new MonthlyPeriodType();
-				period = monthlyPeriodType.createPeriod( cal.getTime() );			
-				
-			}catch(Exception e)
-			{
-				e.printStackTrace();
-			}			
-		}
-		
-		else if( dataSet.getPeriodType().getName().equals("Yearly"))
-		{
-			Calendar cal = Calendar.getInstance();
-			cal.set( Calendar.YEAR, Integer.parseInt(periodName) );
-			
-			YearlyPeriodType yearlyPeriodType = new YearlyPeriodType();
-			
-			period = yearlyPeriodType.createPeriod( cal.getTime() );			
-		}else if(dataSet.getPeriodType().getName().equals("Quarterly")){
-			Calendar cal = Calendar.getInstance();
-			
-			int month = 0;
-			if(periodName.substring(0,periodName.indexOf(" ")).equals("Jan")){
-				month = 1;
-			}else if(periodName.substring(0,periodName.indexOf(" ")).equals("Apr")){
-				month = 4;
-			}else if(periodName.substring(0,periodName.indexOf(" ")).equals("Jul")){
-				month = 6;
-			}else if(periodName.substring(0,periodName.indexOf(" ")).equals("Oct")){
-				month = 10;
-			}
-				
-			int year = Integer.parseInt(periodName.substring(periodName.lastIndexOf(" ")+1));
-			
-			cal.set(Calendar.MONTH, month);
-			cal.set(Calendar.YEAR, year);
-			
-			QuarterlyPeriodType quarterlyPeriodType = new QuarterlyPeriodType();
-			if(month != 0){
-				period =  quarterlyPeriodType.createPeriod(cal.getTime());
-			}
-			
-		}
-		
-		if( period != null )
-		{	
-			persistedPeriod = periodService.getPeriod( period.getStartDate(), period.getEndDate(), dataSet.getPeriodType() );
-			
-			if(  persistedPeriod == null )
-			{				
-				periodService.addPeriod( period );				
-				persistedPeriod = periodService.getPeriod( period.getStartDate(), period.getEndDate(), dataSet.getPeriodType() );
-			}
-		}
-		
-		return persistedPeriod;	
-	}
+
+    public Period getPeriod( String periodName, DataSet dataSet )
+    {
+        org.hisp.dhis.period.Period period = null;
+        org.hisp.dhis.period.Period persistedPeriod = null;
+        if ( dataSet.getPeriodType().getName().equals( "Daily" ) )
+        {
+            String pattern = "yyyy-MM-dd";
+            SimpleDateFormat formatter = new SimpleDateFormat( pattern );
+            Date date = new Date();
+
+            try
+            {
+
+                date = formatter.parse( periodName );
+                DailyPeriodType dailyPeriodType = new DailyPeriodType();
+                period = dailyPeriodType.createPeriod( date );
+
+            }
+            catch ( ParseException e )
+            {
+                e.printStackTrace();
+            }
+        }
+        else if ( dataSet.getPeriodType().getName().equals( "Weekly" ) )
+        {
+            try
+            {
+                int week = Integer.parseInt( periodName.substring( 0, periodName.indexOf( '-' ) ) );
+                int year = Integer
+                    .parseInt( periodName.substring( periodName.indexOf( '-' ) + 1, periodName.length() ) );
+
+                Calendar cal = Calendar.getInstance();
+                cal.set( Calendar.YEAR, year );
+                cal.set( Calendar.WEEK_OF_YEAR, week );
+                cal.setFirstDayOfWeek( Calendar.MONDAY );
+
+                WeeklyPeriodType weeklyPeriodType = new WeeklyPeriodType();
+                period = weeklyPeriodType.createPeriod( cal.getTime() );
+
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+            }
+        }
+
+        else if ( dataSet.getPeriodType().getName().equals( "Monthly" ) )
+        {
+            try
+            {
+                int month = Integer.parseInt( periodName.substring( 0, periodName.indexOf( '-' ) ) );
+                int year = Integer
+                    .parseInt( periodName.substring( periodName.indexOf( '-' ) + 1, periodName.length() ) );
+
+                Calendar cal = Calendar.getInstance();
+                cal.set( Calendar.YEAR, year );
+                cal.set( Calendar.MONTH, month );
+
+                MonthlyPeriodType monthlyPeriodType = new MonthlyPeriodType();
+                period = monthlyPeriodType.createPeriod( cal.getTime() );
+
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+            }
+        }
+
+        else if ( dataSet.getPeriodType().getName().equals( "Yearly" ) )
+        {
+            Calendar cal = Calendar.getInstance();
+            cal.set( Calendar.YEAR, Integer.parseInt( periodName ) );
+
+            YearlyPeriodType yearlyPeriodType = new YearlyPeriodType();
+
+            period = yearlyPeriodType.createPeriod( cal.getTime() );
+        }
+        else if ( dataSet.getPeriodType().getName().equals( "Quarterly" ) )
+        {
+            Calendar cal = Calendar.getInstance();
+
+            int month = 0;
+            if ( periodName.substring( 0, periodName.indexOf( " " ) ).equals( "Jan" ) )
+            {
+                month = 1;
+            }
+            else if ( periodName.substring( 0, periodName.indexOf( " " ) ).equals( "Apr" ) )
+            {
+                month = 4;
+            }
+            else if ( periodName.substring( 0, periodName.indexOf( " " ) ).equals( "Jul" ) )
+            {
+                month = 6;
+            }
+            else if ( periodName.substring( 0, periodName.indexOf( " " ) ).equals( "Oct" ) )
+            {
+                month = 10;
+            }
+
+            int year = Integer.parseInt( periodName.substring( periodName.lastIndexOf( " " ) + 1 ) );
+
+            cal.set( Calendar.MONTH, month );
+            cal.set( Calendar.YEAR, year );
+
+            QuarterlyPeriodType quarterlyPeriodType = new QuarterlyPeriodType();
+            if ( month != 0 )
+            {
+                period = quarterlyPeriodType.createPeriod( cal.getTime() );
+            }
+
+        }
+
+        if ( period != null )
+        {
+            persistedPeriod = periodService.getPeriod( period.getStartDate(), period.getEndDate(),
+                dataSet.getPeriodType() );
+
+            if ( persistedPeriod == null )
+            {
+                periodService.addPeriod( period );
+                persistedPeriod = periodService.getPeriod( period.getStartDate(), period.getEndDate(),
+                    dataSet.getPeriodType() );
+            }
+        }
+
+        return persistedPeriod;
+    }
 
 }