← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6422: Impl first cut of data value import service and controller

 

------------------------------------------------------------
revno: 6422
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 20:27:56 +0200
message:
  Impl first cut of data value import service and controller
added:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValueService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DefaultDataValueService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
  dhis-2/dhis-dxf2/pom.xml
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java
  dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.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-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java	2012-01-19 04:42:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java	2012-03-28 18:27:56 +0000
@@ -34,6 +34,11 @@
 {
     final String[] I18N_PROPERTIES = { "name" };
     
+    enum IdentifiableProperty
+    {
+        ID, UID, NAME, CODE, LAST_UPDATED
+    }
+    
     int getId();
 
     String getUid();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-03-20 15:25:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-03-28 18:27:56 +0000
@@ -1,5 +1,9 @@
 package org.hisp.dhis.common;
 
+import java.util.Map;
+
+import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+
 /*
  * Copyright (c) 2004-2005, University of Oslo
  * All rights reserved.
@@ -40,6 +44,8 @@
     
     void delete( IdentifiableObject object );
     
+    <T extends IdentifiableObject> Map<String, T> getIdMap( Class<T> clazz, IdentifiableProperty property );
+    
     IdentifiableObject getObject( String uid, String simpleClassName );
     
     IdentifiableObject getObject( int id, String simpleClassName );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2012-03-17 14:07:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2012-03-28 18:27:56 +0000
@@ -27,17 +27,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.Weighted;
 import org.hisp.dhis.common.view.DetailedView;
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Kristian Nordal
@@ -53,7 +54,7 @@
     private static final long serialVersionUID = -4445992494203466044L;
 
     public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
-
+    
     private static final String SEPARATOR = "_";
 
     /**
@@ -223,7 +224,7 @@
         
         return (int) Math.floor( no );
     }
-
+    
     // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2012-03-12 13:27:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java	2012-03-28 18:27:56 +0000
@@ -293,6 +293,27 @@
 
         return null;
     }
+    
+    /**
+     * Returns a period type based on the given date string in ISO format. Returns
+     * null if the date string cannot be parsed to a date.
+     * 
+     * @param isoPeriod the date string in ISO format.
+     * @return a period.
+     */
+    public static Period getPeriodFromIsoString( String isoPeriod )
+    {
+        PeriodType periodType = getPeriodTypeFromIsoString( isoPeriod );
+        
+        try
+        {
+            return periodType != null ? periodType.createPeriod() : null;
+        }
+        catch ( Exception ex )
+        {
+            return null;
+        }
+    }
 
     /**
      * Creates a period based on the given external identifier, which is on the

=== modified file 'dhis-2/dhis-dxf2/pom.xml'
--- dhis-2/dhis-dxf2/pom.xml	2012-03-28 16:04:53 +0000
+++ dhis-2/dhis-dxf2/pom.xml	2012-03-28 18:27:56 +0000
@@ -22,6 +22,10 @@
     </dependency>
     <dependency>
       <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-system</artifactId>
     </dependency>
     <dependency>

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java	2012-03-28 16:14:44 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java	2012-03-28 18:27:56 +0000
@@ -27,8 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Date;
-
 import org.hisp.dhis.common.Dxf2Namespace;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -50,7 +48,7 @@
     
     private String storedBy;
 
-    private Date timestamp;
+    private String timestamp;
 
     private String comment;
 
@@ -138,12 +136,12 @@
 
     @JsonProperty
     @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
-    public Date getTimestamp()
+    public String getTimestamp()
     {
         return timestamp;
     }
 
-    public void setTimestamp( Date timestamp )
+    public void setTimestamp( String timestamp )
     {
         this.timestamp = timestamp;
     }

=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValueService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValueService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValueService.java	2012-03-28 18:27:56 +0000
@@ -0,0 +1,35 @@
+package org.hisp.dhis.dxf2.datavalue;
+
+/*
+ * Copyright (c) 2011, 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 org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+
+public interface DataValueService
+{
+    void saveDataValues( DataValues dataValues, IdentifiableProperty idScheme );
+}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java	2012-03-28 16:04:53 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java	2012-03-28 18:27:56 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.dxf2.datavalue;
 
+/*
+ * Copyright (c) 2011, 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;
 

=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DefaultDataValueService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DefaultDataValueService.java	2012-03-28 18:27:56 +0000
@@ -0,0 +1,132 @@
+package org.hisp.dhis.dxf2.datavalue;
+
+/*
+ * Copyright (c) 2011, 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.system.util.DateUtils.getDefaultDate;
+
+import java.util.Map;
+
+import org.amplecode.quick.BatchHandler;
+import org.amplecode.quick.BatchHandlerFactory;
+import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+public class DefaultDataValueService
+    implements DataValueService
+{
+    @Autowired
+    private IdentifiableObjectManager identifiableObjectManager;
+    
+    @Autowired
+    private DataElementCategoryService categoryService;
+    
+    @Autowired
+    private PeriodService periodService;
+    
+    @Autowired
+    private org.hisp.dhis.datavalue.DataValueService dataValueService;
+    
+    @Autowired
+    private BatchHandlerFactory batchHandlerFactory;
+    
+    @Transactional
+    public void saveDataValues( DataValues dataValues, IdentifiableProperty idScheme )
+    {
+        Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, idScheme );
+        Map<String, OrganisationUnit> orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, idScheme );
+        Map<String, DataElementCategoryOptionCombo> categoryOptionComboMap = identifiableObjectManager.getIdMap( DataElementCategoryOptionCombo.class, IdentifiableProperty.UID );
+        
+        DataElementCategoryOptionCombo fallbackCategoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+
+        BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler( DataValueBatchHandler.class ).init();
+        
+        for ( org.hisp.dhis.dxf2.datavalue.DataValue dataValue : dataValues.getDataValues() )
+        {
+            DataValue internalValue = new DataValue();
+            
+            DataElement dataElement = dataElementMap.get( dataValue.getDataElement() );
+            OrganisationUnit orgUnit = orgUnitMap.get( dataValue.getOrgUnit() );
+            DataElementCategoryOptionCombo categoryOptionCombo = categoryOptionComboMap.get( dataValue.getCategoryOptionCombo() );
+            Period period = PeriodType.getPeriodFromIsoString( dataValue.getPeriod() );
+            
+            if ( dataElement == null )
+            {
+                continue;
+            }
+            
+            if ( orgUnit == null )
+            {
+                continue;
+            }
+
+            if ( period == null )
+            {
+                continue;
+            }
+            
+            if ( categoryOptionCombo == null )
+            {
+                categoryOptionCombo = fallbackCategoryOptionCombo;
+            }
+                   
+            internalValue.setDataElement( dataElement );
+            internalValue.setPeriod( periodService.reloadPeriod( period ) );
+            internalValue.setSource( orgUnit );
+            internalValue.setOptionCombo( categoryOptionCombo );
+            internalValue.setValue( dataValue.getValue() );
+            internalValue.setStoredBy( dataValue.getStoredBy() );
+            internalValue.setTimestamp( getDefaultDate( dataValue.getTimestamp() ) );
+            internalValue.setComment( dataValue.getComment() );
+            internalValue.setFollowup( dataValue.getFollowup() );
+            
+            if ( batchHandler.objectExists( internalValue ) )
+            {
+                dataValueService.updateDataValue( internalValue );
+            }
+            else
+            {
+                batchHandler.addObject( internalValue );
+            }
+            
+            System.out.println( "Inserted " + internalValue );
+        }
+        
+        batchHandler.flush();
+    }
+}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java	2012-03-28 16:04:53 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java	2012-03-28 18:27:56 +0000
@@ -41,16 +41,6 @@
 @JacksonXmlRootElement( localName = "dataValueSet", namespace = Dxf2Namespace.NAMESPACE )
 public class DataValueSet
 {
-    /*
-    public static final String ATTR_COMMENT = "comment";
-    public static final String ATTR_DATASET = "dataSet";
-    public static final String ATTR_IDSCHEME = "idScheme";
-    public static final String ATTR_ORGUNIT = "orgUnit";
-    public static final String ATTR_PERIOD = "period";
-    public static final String ATTR_COMPLETE = "period";
-    public static final String DATAVALUE = "dataValue";
-    */
-    
     public enum IdentificationStrategy { INTERNAL, UID, CODE  };
 
     /**

=== modified file 'dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml	2012-03-28 16:04:53 +0000
+++ dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml	2012-03-28 18:27:56 +0000
@@ -2,6 +2,8 @@
 <beans xmlns="http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd";>
 
+  <bean id="org.hisp.dhis.dxf2.datavalue.DataValueService" class="org.hisp.dhis.dxf2.datavalue.DefaultDataValueService"/>
+
   <bean id="org.hisp.dhis.dxf2.datavalueset.DataValueSetService" class="org.hisp.dhis.dxf2.datavalueset.DefaultDataValueSetService">
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-03-20 15:25:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-03-28 18:27:56 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -36,6 +37,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import static org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+
 /**
  * @author Lars Helge Overland
  */
@@ -83,6 +86,38 @@
     {
         objectStoreMap.get( object.getClass() ).delete( object );
     }
+
+    @SuppressWarnings("unchecked")
+    public <T extends IdentifiableObject> Map<String, T> getIdMap( Class<T> clazz, IdentifiableProperty property )
+    {
+        Map<String, T> map = new HashMap<String, T>();
+        
+        GenericIdentifiableObjectStore<T> store = (GenericIdentifiableObjectStore<T>) objectStoreMap.get( clazz );
+        
+        Collection<T> objects = store.getAll();
+        
+        for ( T object : objects )
+        {
+            if ( IdentifiableProperty.ID.equals( property ) )
+            {
+                map.put( String.valueOf( object.getId() ), object );
+            }
+            else if ( IdentifiableProperty.UID.equals( property ) )
+            {
+                map.put( object.getUid(), object );
+            }
+            else if ( IdentifiableProperty.CODE.equals( property ) )
+            {
+                map.put( object.getCode(), object );
+            }
+            else if ( IdentifiableProperty.NAME.equals( property ) )
+            {
+                map.put( object.getName(), object );
+            }
+        }
+        
+        return map;
+    }
     
     public IdentifiableObject getObject( String uid, String simpleClassName )
     {

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2012-03-08 15:19:22 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2012-03-28 18:27:56 +0000
@@ -153,7 +153,26 @@
         
         return getHttpDateString( cal.getTime() );
     }
-    
+
+    /**
+     * Parses the given string into a Date using the default date format which is
+     * yyyy-MM-dd. Returns null if the string cannot be parsed.
+     * 
+     * @param dateString the date string.
+     * @return a date.
+     */
+    public static Date getDefaultDate( String dateString )
+    {
+        try
+        {
+            return new SimpleDateFormat( DEFAULT_DATE_FORMAT ).parse( dateString );
+        }
+        catch ( Exception ex )
+        {
+            return null;
+        }
+    }
+
     /**
      * Parses a date from a String on the format YYYY-MM-DD.
      * 

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java	2012-03-28 18:27:56 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2011, 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.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dxf2.datavalue.DataValueService;
+import org.hisp.dhis.dxf2.datavalue.DataValues;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+@RequestMapping( value = DataValueController.RESOURCE_PATH )
+public class DataValueController
+{
+    public static final String RESOURCE_PATH = "/dataValues";
+
+    private static final Log log = LogFactory.getLog( DataValueController.class );
+    
+    @Autowired
+    private DataValueService dataValueService;
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
+    public void postDataValues( HttpServletResponse response, InputStream input )
+        throws IOException
+    {
+        DataValues dataValues = JacksonUtils.fromXml( input, DataValues.class );
+        
+        dataValueService.saveDataValues( dataValues, IdentifiableObject.IdentifiableProperty.UID );
+
+        log.info( "SIZE " + dataValues.getDataValues().size() );
+        
+        ContextUtils.okResponse( response, "Data values saved successfully" );
+    }
+}