← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2192: Tentative solution for not requiring all values to be filled when saving data values for a data set.

 

------------------------------------------------------------
revno: 2192
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2010-11-27 09:45:31 +0530
message:
  Tentative solution for not requiring all values to be filled when saving data values for a data set.
added:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/Mapping.java
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java
  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/Beneficiary.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.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/FacilityReportingServiceImpl.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/Activity.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java	2010-11-21 11:37:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Activity.java	2010-11-27 04:15:31 +0000
@@ -32,6 +32,8 @@
 import java.io.IOException;
 import java.util.Date;
 
+import javax.xml.bind.annotation.XmlAttribute;
+
 public class Activity
     implements DataStreamSerializable
 {
@@ -74,6 +76,7 @@
         this.dueDate = dueDate;
     }
 
+    @XmlAttribute
     public boolean isLate()
     {
         return late;

=== 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-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ActivityPlan.java	2010-11-27 04:15:31 +0000
@@ -32,7 +32,9 @@
 import java.io.IOException;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+
 @XmlRootElement
 public class ActivityPlan
     implements DataStreamSerializable
@@ -40,6 +42,7 @@
 
     private List<Activity> activitiesList;
 
+    @XmlElement(name="activity")
     public List<Activity> getActivitiesList()
     {
         return activitiesList;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java	2010-11-27 04:15:31 +0000
@@ -34,23 +34,41 @@
 import java.util.Date;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+@XmlAccessorType( XmlAccessType.FIELD )
 public class Beneficiary
     implements DataStreamSerializable
 {
+    @XmlAttribute
     private int id;
 
+    @XmlAttribute
     private String firstName;
 
+    @XmlAttribute
     private String middleName;
 
+    @XmlAttribute
     private String lastName;
 
+    @XmlAttribute
     private int age;
 
+    @XmlElementWrapper(name="attributes")
+    @XmlElement(name="attribute")
     private List<PatientAttribute> patientAttValues;
 
     private PatientAttribute groupAttribute;
 
+    @XmlElementWrapper( name = "identifiers" )
+    @XmlElement( name = "identifier" )
     private List<PatientIdentifier> identifiers;
 
     private String gender;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java	2010-11-18 04:09:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataElement.java	2010-11-27 04:15:31 +0000
@@ -1,5 +1,9 @@
 package org.hisp.dhis.web.api.model;
 
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -37,11 +41,6 @@
 
     private ModelList categoryOptionCombos;
 
-    public DataElement()
-    {
-
-    }
-
     public String getType()
     {
         return type;
@@ -72,4 +71,33 @@
         this.compulsory = compulsory;
     }
 
+    public void serializeHack( DataOutputStream dout )
+        throws IOException
+    {
+        dout.writeInt( getId() );
+        dout.writeUTF( getName() );
+        dout.writeUTF( type );
+        dout.writeBoolean( compulsory );
+
+        if ( categoryOptionCombos == null )
+        {
+            dout.writeInt( 0 );
+            return;
+        }
+
+        List<Model> cateOptCombos = categoryOptionCombos.getModels();
+        if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
+        {
+            dout.writeInt( 0 );
+            return;
+        }
+
+        dout.writeInt( cateOptCombos.size() );
+        for ( Model each : cateOptCombos )
+        {
+            dout.writeInt( each.getId() );
+            dout.writeUTF( each.getName() );
+        }
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java	2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Model.java	2010-11-27 04:15:31 +0000
@@ -31,6 +31,8 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import javax.xml.bind.annotation.XmlAttribute;
+
 public class Model
     implements DataStreamSerializable
 {
@@ -39,6 +41,7 @@
 
     private String name;
 
+    @XmlAttribute
     public int getId()
     {
         return id;
@@ -49,6 +52,7 @@
         this.id = id;
     }
 
+    @XmlAttribute
     public String getName()
     {
         return name;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/ModelList.java	2010-11-27 04:15:31 +0000
@@ -33,12 +33,15 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
+
 public class ModelList
     implements DataStreamSerializable
 {
 
     private List<Model> models;
 
+    @XmlElement(name="model")
     public List<Model> getModels()
     {
         return models;
@@ -53,6 +56,10 @@
     public void serialize( DataOutputStream dataOutputStream )
         throws IOException
     {
+        if (models == null) {
+            dataOutputStream.writeInt( 0 );            
+        }
+        
         dataOutputStream.writeInt( models.size() );
 
         for ( int i = 0; i < models.size(); i++ )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java	2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java	2010-11-27 04:15:31 +0000
@@ -31,6 +31,8 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import javax.xml.bind.annotation.XmlAttribute;
+
 public class PatientAttribute implements DataStreamSerializable
 {
     private String name;
@@ -47,6 +49,7 @@
     {   
     }
     
+    @XmlAttribute
     public String getName()
     {
         return name;
@@ -57,6 +60,7 @@
         this.name = name;
     }
 
+    @XmlAttribute
     public String getValue()
     {
         return value;
@@ -79,8 +83,8 @@
     public void deSerialize( DataInputStream dataInputStream )
         throws IOException
     {
-        // FIXME: Get implementation from client
-        
+        name = dataInputStream.readUTF();
+        value = dataInputStream.readUTF();
     }
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Section.java	2010-11-27 04:15:31 +0000
@@ -27,17 +27,24 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
+
 public class Section
     extends Model
 {
 
     private List<DataElement> dataElements;
 
+    @XmlElement(name="dataElement")
+    public List<DataElement> getDataElements()
+    {
+        return dataElements;
+    }
+
     public void setDataElements( List<DataElement> des )
     {
         this.dataElements = des;
@@ -60,36 +67,9 @@
             for ( int i = 0; i < dataElements.size(); i++ )
             {
                 DataElement de = (DataElement) dataElements.get( i );
-                dout.writeInt( de.getId() );
-                dout.writeUTF( de.getName() );
-                dout.writeUTF( de.getType() );
-                dout.writeBoolean( de.isCompulsory() );
-                
-                List<Model> cateOptCombos = de.getCategoryOptionCombos().getModels();
-                if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
-                {
-                    dout.writeInt( 0 );
-                }
-                else
-                {
-                    dout.writeInt( cateOptCombos.size() );
-                    for ( Model each : cateOptCombos )
-                    {
-                        dout.writeInt( each.getId() );
-                        dout.writeUTF( each.getName() );
-                    }
-                }
-
+                de.serializeHack( dout );
             }
         }
     }
 
-    @Override
-    public void deSerialize( DataInputStream dataInputStream )
-        throws IOException
-    {
-        // FIXME
-    }
-
-
 }

=== 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-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java	2010-11-27 04:15:31 +0000
@@ -1,17 +1,40 @@
 package org.hisp.dhis.web.api.service;
 
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 import static org.hisp.dhis.i18n.I18nUtils.i18n;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
-import java.util.Set;
 
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.web.api.model.DataElement;
-import org.hisp.dhis.web.api.model.Model;
-import org.hisp.dhis.web.api.model.ModelList;
 import org.hisp.dhis.web.api.model.Program;
 import org.hisp.dhis.web.api.model.ProgramStage;
 import org.hisp.dhis.web.api.utils.LocaleUtil;
@@ -23,7 +46,7 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private org.hisp.dhis.program.ProgramService programService;
 
     private org.hisp.dhis.i18n.I18nService i18nService;
@@ -72,26 +95,13 @@
             for ( org.hisp.dhis.program.ProgramStageDataElement programStagedataElement : programStage
                 .getProgramStageDataElements() )
             {
-                ModelList mobileCategpryOptCombos = new ModelList();
-                mobileCategpryOptCombos.setModels( new ArrayList<Model>() );
                 programStagedataElement = i18n( i18nService, locale, programStagedataElement );
-                Set<DataElementCategoryOptionCombo> deCatOptCombs = programStagedataElement.getDataElement()
-                    .getCategoryCombo().getOptionCombos();
-
-                for ( DataElementCategoryOptionCombo categoryOptCombo : deCatOptCombs )
-                {
-                    Model mobileCategpryOptCombo = new Model();
-                    mobileCategpryOptCombo.setId( categoryOptCombo.getId() );
-                    mobileCategpryOptCombo.setName( categoryOptCombo.getName() );
-                    mobileCategpryOptCombos.getModels().add( mobileCategpryOptCombo );
-                }
-
-                DataElement de = new DataElement();
-                de.setId( programStagedataElement.getDataElement().getId() );
-                de.setName( programStagedataElement.getDataElement().getName() );
-                de.setType( programStagedataElement.getDataElement().getType() );
+
+                org.hisp.dhis.dataelement.DataElement dataElement = programStagedataElement.getDataElement();
+
+                DataElement de = Mapping.getDataElement( dataElement );
+
                 de.setCompulsory( programStagedataElement.isCompulsory() );
-                de.setCategoryOptionCombos( mobileCategpryOptCombos );
 
                 des.add( de );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-11-27 04:15:31 +0000
@@ -42,6 +42,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -56,8 +58,6 @@
 import org.hisp.dhis.web.api.model.DataSet;
 import org.hisp.dhis.web.api.model.DataSetValue;
 import org.hisp.dhis.web.api.model.DataValue;
-import org.hisp.dhis.web.api.model.Model;
-import org.hisp.dhis.web.api.model.ModelList;
 import org.hisp.dhis.web.api.model.Section;
 import org.hisp.dhis.web.api.utils.LocaleUtil;
 import org.springframework.beans.factory.annotation.Required;
@@ -65,6 +65,7 @@
 public class FacilityReportingServiceImpl
     implements FacilityReportingService
 {
+    private static Log log = LogFactory.getLog( FacilityReportingServiceImpl.class );
 
     private DataElementSortOrderComparator dataElementComparator = new DataElementSortOrderComparator();
 
@@ -102,6 +103,12 @@
             {
                 datasets.add( getDataSetForLocale( dataSet.getId(), locale ) );
             }
+            else
+            {
+                log.warn( "Dataset '" + dataSet.getName()
+                    + "' set to be reported from mobile, but not of a supported period type: "
+                    + dataSet.getPeriodType().getName() );
+            }
         }
 
         return datasets;
@@ -113,24 +120,17 @@
         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 == null || sections.size() == 0 )
         {
-            // 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() );
 
@@ -138,83 +138,22 @@
 
             // 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.setDataElements( dataElementList );
-
-            for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
-            {
-                // Server DataElement
-                dataElement = i18n( i18nService, locale, dataElement );
-                Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
-                // Client DataElement
-                ModelList deCateOptCombo = new ModelList();
-                List<Model> listCateOptCombo = new ArrayList<Model>();
-                deCateOptCombo.setModels( listCateOptCombo );
-
-                for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
-                {
-                    Model oneCateOptCombo = new Model();
-                    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() );
-                
-                //For facility Reporting, all data element are mandetory
-                de.setCompulsory( true );
-                de.setCategoryOptionCombos( deCateOptCombo );
-                dataElementList.add( de );
-            }
+            section.setDataElements( getDataElements( locale, dataElements ) );
+            sectionList.add( section );
         }
         else
         {
-            for ( org.hisp.dhis.dataset.Section each : sections )
+            for ( org.hisp.dhis.dataset.Section s : 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.setId( s.getId() );
+                section.setName( s.getName() );
+
+                List<DataElement> dataElementList = getDataElements( locale, s.getDataElements() );
                 section.setDataElements( dataElementList );
-
-                for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
-                {
-                    // Server DataElement
-                    dataElement = i18n( i18nService, locale, dataElement );
-                    Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo()
-                        .getOptionCombos();
-
-                    // Client DataElement
-                    ModelList deCateOptCombo = new ModelList();
-                    List<Model> listCateOptCombo = new ArrayList<Model>();
-                    deCateOptCombo.setModels( listCateOptCombo );
-
-                    for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
-                    {
-                        Model oneCateOptCombo = new Model();
-                        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 );
             }
         }
@@ -222,6 +161,24 @@
         return ds;
     }
 
+    private List<DataElement> getDataElements( Locale locale, List<org.hisp.dhis.dataelement.DataElement> dataElements )
+    {
+        List<DataElement> dataElementList = new ArrayList<DataElement>();
+
+        for ( org.hisp.dhis.dataelement.DataElement dataElement : dataElements )
+        {
+            dataElement = i18n( i18nService, locale, dataElement );
+
+            DataElement de = Mapping.getDataElement( dataElement );
+
+            // For facility Reporting, no data elements are mandetory
+            de.setCompulsory( false );
+
+            dataElementList.add( de );
+        }
+        return dataElementList;
+    }
+
     @Override
     public String saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue )
     {
@@ -248,17 +205,13 @@
             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";
+                log.info( "Dataset '" + dataSet.getName() + "' for org unit '" + unit.getName()
+                    + "' missing data element '" + dataElement.getName() + "'" );
             }
             dataElementMap.put( dataElement.getId(), dataElement );
         }

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/Mapping.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/Mapping.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/Mapping.java	2010-11-27 04:15:31 +0000
@@ -0,0 +1,78 @@
+package org.hisp.dhis.web.api.service;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.web.api.model.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.web.api.model.Model;
+import org.hisp.dhis.web.api.model.ModelList;
+
+public class Mapping
+{
+    
+    public static DataElement getDataElement( org.hisp.dhis.dataelement.DataElement dataElement )
+    {
+        DataElement de = new DataElement();
+        de.setId( dataElement.getId() );
+        de.setName( dataElement.getName() );
+        de.setType( dataElement.getType() );
+        
+        de.setCategoryOptionCombos( getCategoryOptionCombos( dataElement ) );
+        return de;
+    }
+    
+    public static ModelList getCategoryOptionCombos( org.hisp.dhis.dataelement.DataElement dataElement )
+    {
+        Set<DataElementCategoryOptionCombo> deCatOptCombs = dataElement.getCategoryCombo().getOptionCombos();
+
+//        if ( deCatOptCombs.size() < 2 )
+//        {
+//            return null;
+//        }
+
+        // Client DataElement
+        ModelList deCateOptCombo = new ModelList();
+        List<Model> listCateOptCombo = new ArrayList<Model>();
+        deCateOptCombo.setModels( listCateOptCombo );
+
+        for ( DataElementCategoryOptionCombo oneCatOptCombo : deCatOptCombs )
+        {
+            Model oneCateOptCombo = new Model();
+            oneCateOptCombo.setId( oneCatOptCombo.getId() );
+            oneCateOptCombo.setName( oneCatOptCombo.getName() );
+            listCateOptCombo.add( oneCateOptCombo );
+        }
+        return deCateOptCombo;
+    }
+
+    
+}