← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13820: Web API, added register and un-register complete data set registration methods. Data entry, using...

 

------------------------------------------------------------
revno: 13820
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-23 11:31:23 +0200
message:
  Web API, added register and un-register complete data set registration methods. Data entry, using Web API instead of actions for complete registrations.
removed:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js


--
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/api/controller/CompleteDataSetRegistrationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java	2013-09-25 14:13:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java	2014-01-23 09:31:23 +0000
@@ -28,18 +28,25 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.api.utils.InputUtils;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.view.BasicView;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrations;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.stereotype.Controller;
@@ -67,9 +74,12 @@
     public static final String RESOURCE_PATH = "/completeDataSetRegistrations";
 
     @Autowired
-    private CompleteDataSetRegistrationService completeDataSetRegistrationService;
+    private CompleteDataSetRegistrationService registrationService;
 
     @Autowired
+    private DataSetService dataSetService;
+    
+    @Autowired
     private PeriodService periodService;
 
     @Autowired
@@ -77,7 +87,16 @@
 
     @Autowired
     private OrganisationUnitService organisationUnitService;
+    
+    @Autowired
+    private CurrentUserService currentUserService;
 
+    @Autowired
+    private InputUtils inputUtils;
+    
+    @Autowired
+    private I18nManager i18nManager;
+    
     @RequestMapping( method = RequestMethod.GET, produces = CONTENT_TYPE_XML )
     public void getCompleteDataSetRegistrationsXml(
         @RequestParam Set<String> dataSet,
@@ -140,8 +159,188 @@
 
         CompleteDataSetRegistrations completeDataSetRegistrations = new CompleteDataSetRegistrations();
         completeDataSetRegistrations.setCompleteDataSetRegistrationList( new ArrayList<CompleteDataSetRegistration>(
-            completeDataSetRegistrationService.getCompleteDataSetRegistrations( dataSets, organisationUnits, periods ) ) );
+            registrationService.getCompleteDataSetRegistrations( dataSets, organisationUnits, periods ) ) );
 
         return completeDataSetRegistrations;
     }
+
+    @RequestMapping( method = RequestMethod.POST, produces = "text/plain" )
+    public void saveCompleteDataSetRegistration( 
+        @RequestParam String ds,
+        @RequestParam String pe,
+        @RequestParam String ou,
+        @RequestParam( required = false ) String cc, 
+        @RequestParam( required = false ) String cp, 
+        @RequestParam( required = false, defaultValue="false" ) boolean multiOu, HttpServletResponse response )
+    {
+        DataSet dataSet = dataSetService.getDataSet( ds );
+        
+        if ( dataSet == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal data set identifier: " + ds );
+            return;
+        }
+
+        Period period = PeriodType.getPeriodFromIsoString( pe );
+
+        if ( period == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
+            return;
+        }
+
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+
+        if ( organisationUnit == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou );
+            return;
+        }
+
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        
+        if ( attributeOptionCombo == null )
+        {
+            return;
+        }
+
+        // ---------------------------------------------------------------------
+        // Check locked status
+        // ---------------------------------------------------------------------
+
+        if ( dataSetService.isLocked( dataSet, period, organisationUnit, attributeOptionCombo, null, multiOu ) )
+        {
+            ContextUtils.conflictResponse( response, "Data set is locked: " + ds );
+            return;
+        }
+
+        // ---------------------------------------------------------------------
+        // Register as completed data set
+        // ---------------------------------------------------------------------
+        
+        Set<OrganisationUnit> children = organisationUnit.getChildren();
+
+        String storedBy = currentUserService.getCurrentUsername();
+
+        if ( !multiOu )
+        {
+            registerCompleteDataSet( dataSet, period, organisationUnit, storedBy );
+        }
+        else
+        {
+            for ( OrganisationUnit unit : children )
+            {
+                if ( unit.getDataSets().contains( dataSet ) )
+                {
+                    registerCompleteDataSet( dataSet, period, unit, storedBy );
+                }
+            }
+        }
+    }
+    
+    @RequestMapping( method = RequestMethod.DELETE, produces = "text/plain" )
+    public void deleteCompleteDataSetRegistration( 
+        @RequestParam String ds,
+        @RequestParam String pe,
+        @RequestParam String ou,
+        @RequestParam( required = false ) String cc, 
+        @RequestParam( required = false ) String cp, 
+        @RequestParam( required = false, defaultValue="false" ) boolean multiOu, HttpServletResponse response )
+    {
+        DataSet dataSet = dataSetService.getDataSet( ds );
+        
+        if ( dataSet == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal data set identifier: " + ds );
+            return;
+        }
+
+        Period period = PeriodType.getPeriodFromIsoString( pe );
+
+        if ( period == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
+            return;
+        }
+
+        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+
+        if ( organisationUnit == null )
+        {
+            ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou );
+            return;
+        }
+
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        
+        if ( attributeOptionCombo == null )
+        {
+            return;
+        }
+
+        // ---------------------------------------------------------------------
+        // Check locked status
+        // ---------------------------------------------------------------------
+
+        if ( dataSetService.isLocked( dataSet, period, organisationUnit, attributeOptionCombo, null, multiOu ) )
+        {
+            ContextUtils.conflictResponse( response, "Data set is locked: " + ds );
+            return;
+        }
+
+        // ---------------------------------------------------------------------
+        // Un-register as completed data set
+        // ---------------------------------------------------------------------
+        
+        Set<OrganisationUnit> children = organisationUnit.getChildren();
+
+        if ( !multiOu )
+        {
+            unRegisterCompleteDataSet( dataSet, period, organisationUnit );
+        }
+        else
+        {
+            for ( OrganisationUnit unit : children )
+            {
+                if ( unit.getDataSets().contains( dataSet ) )
+                {
+                    unRegisterCompleteDataSet( dataSet, period, unit );
+                }
+            }
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private void registerCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit, String storedBy )
+    {
+        I18nFormat format = i18nManager.getI18nFormat();
+        
+        CompleteDataSetRegistration registration = new CompleteDataSetRegistration();
+
+        if ( registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit ) == null )
+        {
+            registration.setDataSet( dataSet );
+            registration.setPeriod( period );
+            registration.setSource( organisationUnit );
+            registration.setDate( new Date() );
+            registration.setStoredBy( storedBy );
+
+            registration.setPeriodName( format.formatPeriod( registration.getPeriod() ) );
+
+            registrationService.saveCompleteDataSetRegistration( registration, true );
+        }
+    }
+
+    private void unRegisterCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit )
+    {
+        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit );
+
+        if ( registration != null )
+        {
+            registrationService.deleteCompleteDataSetRegistration( registration );
+        }
+    }
 }

=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java	2014-01-03 08:57:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java	1970-01-01 00:00:00 +0000
@@ -1,232 +0,0 @@
-package org.hisp.dhis.de.action;
-
-/*
- * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.api.utils.InputUtils;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataset.CompleteDataSetRegistration;
-import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
-import java.util.Set;
-
-/**
- * @author Lars Helge Overland
- */
-public class RegisterCompleteDataSetAction
-    implements Action
-{
-    private static final Log log = LogFactory.getLog( RegisterCompleteDataSetAction.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private CompleteDataSetRegistrationService registrationService;
-
-    public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
-    {
-        this.registrationService = registrationService;
-    }
-
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private CurrentUserService currentUserService;
-
-    public void setCurrentUserService( CurrentUserService currentUserService )
-    {
-        this.currentUserService = currentUserService;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    @Autowired
-    private InputUtils inputUtils;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String periodId;
-
-    public void setPeriodId( String periodId )
-    {
-        this.periodId = periodId;
-    }
-
-    private String dataSetId;
-
-    public void setDataSetId( String dataSetId )
-    {
-        this.dataSetId = dataSetId;
-    }
-
-    private String organisationUnitId;
-
-    public void setOrganisationUnitId( String organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
-    private boolean multiOrganisationUnit;
-
-    public void setMultiOrganisationUnit( boolean multiOrganisationUnit )
-    {
-        this.multiOrganisationUnit = multiOrganisationUnit;
-    }
-
-    private String cc;
-
-    public void setCc( String cc )
-    {
-        this.cc = cc;
-    }
-
-    private String cp;
-
-    public void setCp( String cp )
-    {
-        this.cp = cp;
-    }
-
-    private int statusCode;
-
-    public int getStatusCode()
-    {
-        return statusCode;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        DataSet dataSet = dataSetService.getDataSet( dataSetId );
-        Period period = PeriodType.getPeriodFromIsoString( periodId );
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-        Set<OrganisationUnit> children = organisationUnit.getChildren();
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( ServletActionContext.getResponse(), cc, cp );
-
-        String storedBy = currentUserService.getCurrentUsername();
-        
-        // ---------------------------------------------------------------------
-        // Check locked status
-        // ---------------------------------------------------------------------
-
-        if ( dataSetService.isLocked( dataSet, period, organisationUnit, attributeOptionCombo, null, multiOrganisationUnit ) )
-        {
-            return logError( "Entry locked: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
-        }
-
-        // ---------------------------------------------------------------------
-        // Register as completed dataSet
-        // ---------------------------------------------------------------------
-
-        if ( !multiOrganisationUnit )
-        {
-            registerCompleteDataSet( dataSet, period, organisationUnit, storedBy );
-        }
-        else
-        {
-            for ( OrganisationUnit ou : children )
-            {
-                if ( ou.getDataSets().contains( dataSet ) )
-                {
-                    registerCompleteDataSet( dataSet, period, ou, storedBy );
-                }
-            }
-        }
-
-        return SUCCESS;
-    }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    private void registerCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit, String storedBy )
-    {
-        CompleteDataSetRegistration registration = new CompleteDataSetRegistration();
-
-        if ( registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit ) == null )
-        {
-            registration.setDataSet( dataSet );
-            registration.setPeriod( period );
-            registration.setSource( organisationUnit );
-            registration.setDate( new Date() );
-            registration.setStoredBy( storedBy );
-
-            registration.setPeriodName( format.formatPeriod( registration.getPeriod() ) );
-
-            registrationService.saveCompleteDataSetRegistration( registration, true );
-
-            log.info( "DataSet registered as complete: " + registration );
-        }
-    }
-
-    private String logError( String message, int statusCode )
-    {
-        log.info( message );
-
-        this.statusCode = statusCode;
-
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java	2014-01-02 13:36:45 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java	1970-01-01 00:00:00 +0000
@@ -1,205 +0,0 @@
-package org.hisp.dhis.de.action;
-
-/*
- * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.api.utils.InputUtils;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataset.CompleteDataSetRegistration;
-import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Set;
-
-/**
- * @author Lars Helge Overland
- */
-public class UndoCompleteDataSetAction
-    implements Action
-{
-    private static final Log log = LogFactory.getLog( UndoCompleteDataSetAction.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private CompleteDataSetRegistrationService registrationService;
-
-    public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
-    {
-        this.registrationService = registrationService;
-    }
-
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    @Autowired
-    private InputUtils inputUtils;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String periodId;
-
-    public void setPeriodId( String periodId )
-    {
-        this.periodId = periodId;
-    }
-
-    private String dataSetId;
-
-    public void setDataSetId( String dataSetId )
-    {
-        this.dataSetId = dataSetId;
-    }
-
-    private String organisationUnitId;
-
-    public void setOrganisationUnitId( String organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
-    private boolean multiOrganisationUnit;
-
-    public void setMultiOrganisationUnit( boolean multiOrganisationUnit )
-    {
-        this.multiOrganisationUnit = multiOrganisationUnit;
-    }
-
-    private String cc;
-
-    public void setCc( String cc )
-    {
-        this.cc = cc;
-    }
-
-    private String cp;
-
-    public void setCp( String cp )
-    {
-        this.cp = cp;
-    }
-
-    private int statusCode;
-
-    public int getStatusCode()
-    {
-        return statusCode;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        DataSet dataSet = dataSetService.getDataSet( dataSetId );
-        Period period = PeriodType.getPeriodFromIsoString( periodId );
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-        Set<OrganisationUnit> children = organisationUnit.getChildren();
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( ServletActionContext.getResponse(), cc, cp );
-
-        // ---------------------------------------------------------------------
-        // Check locked status
-        // ---------------------------------------------------------------------
-
-        if ( dataSetService.isLocked( dataSet, period, organisationUnit, attributeOptionCombo, null, multiOrganisationUnit ) )
-        {
-            return logError( "Entry locked: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
-        }
-
-        // ---------------------------------------------------------------------
-        // Un-register as completed dataSet
-        // ---------------------------------------------------------------------
-
-        if ( !multiOrganisationUnit )
-        {
-            deregisterCompleteDataSet( dataSet, period, organisationUnit );
-        }
-        else
-        {
-            for ( OrganisationUnit ou : children )
-            {
-                if ( ou.getDataSets().contains( dataSet ) )
-                {
-                    deregisterCompleteDataSet( dataSet, period, ou );
-                }
-            }
-        }
-
-        return SUCCESS;
-    }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    private void deregisterCompleteDataSet( DataSet dataSet, Period period, OrganisationUnit organisationUnit )
-    {
-        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit );
-
-        if ( registration != null )
-        {
-            registrationService.deleteCompleteDataSetRegistration( registration );
-
-            log.info( "DataSet un-registered as complete: " + registration );
-        }
-    }
-
-    private String logError( String message, int statusCode )
-    {
-        log.info( message );
-
-        this.statusCode = statusCode;
-
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2013-12-15 22:24:29 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2014-01-23 09:31:23 +0000
@@ -114,37 +114,32 @@
     // Input
     // -------------------------------------------------------------------------
 
-    private String periodId;
-
-    public void setPeriodId( String periodId )
-    {
-        this.periodId = periodId;
-    }
-
-    private String dataSetId;
-
-    public void setDataSetId( String dataSetId )
-    {
-        this.dataSetId = dataSetId;
-    }
-
-    private String organisationUnitId;
-
-    public void setOrganisationUnitId( String organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-
-    private boolean multiOrganisationUnit;
-
-    public void setMultiOrganisationUnit( boolean multiOrganisationUnit )
-    {
-        this.multiOrganisationUnit = multiOrganisationUnit;
-    }
-
-    public boolean isMultiOrganisationUnit()
-    {
-        return multiOrganisationUnit;
+    private String ds;
+
+    public void setDs( String ds )
+    {
+        this.ds = ds;
+    }
+
+    private String pe;
+
+    public void setPe( String pe )
+    {
+        this.pe = pe;
+    }
+
+    private String ou;
+
+    public void setOu( String ou )
+    {
+        this.ou = ou;
+    }
+
+    private boolean multiOu;
+
+    public void setMultiOu( boolean multiOu )
+    {
+        this.multiOu = multiOu;
     }
 
     // -------------------------------------------------------------------------
@@ -186,13 +181,13 @@
     public String execute()
         throws Exception
     {
-        OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
-        DataSet dataSet = dataSetService.getDataSet( dataSetId );
-
-        Period selectedPeriod = PeriodType.getPeriodFromIsoString( periodId );
-
-        if ( selectedPeriod == null || orgUnit == null || ( multiOrganisationUnit && !orgUnit.hasChild() ) )
+        OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ou );
+
+        DataSet dataSet = dataSetService.getDataSet( ds );
+
+        Period selectedPeriod = PeriodType.getPeriodFromIsoString( pe );
+
+        if ( selectedPeriod == null || orgUnit == null || ( multiOu && !orgUnit.hasChild() ) )
         {
             return SUCCESS;
         }
@@ -202,7 +197,7 @@
 
         List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
 
-        if ( !multiOrganisationUnit )
+        if ( !multiOu )
         {
             organisationUnits.add( orgUnit );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2014-01-03 09:14:06 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2014-01-23 09:31:23 +0000
@@ -59,22 +59,6 @@
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>
 
-  <bean id="org.hisp.dhis.de.action.RegisterCompleteDataSetAction"
-      class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction"
-      scope="prototype">
-    <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
-    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-  </bean>
-
-  <bean id="org.hisp.dhis.de.action.UndoCompleteDataSetAction" class="org.hisp.dhis.de.action.UndoCompleteDataSetAction"
-      scope="prototype">
-    <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
-    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-  </bean>
-
   <bean id="org.hisp.dhis.de.action.ValidationAction" class="org.hisp.dhis.de.action.ValidationAction"
       scope="prototype">
     <property name="validationRuleService" ref="org.hisp.dhis.validation.ValidationRuleService" />

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2014-01-03 09:14:06 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2014-01-23 09:31:23 +0000
@@ -55,17 +55,6 @@
       <result name="success" type="velocity">/dhis-web-dataentry/history.vm</result>
     </action>
 
-    <action name="registerCompleteDataSet" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction">
-      <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-      <result name="input" type="velocity-json">../dhis-web-commons/ajax/jsonResponseInput.vm</result>
-      <param name="requiredAuthorities">F_DATAVALUE_ADD</param>
-    </action>
-
-    <action name="undoCompleteDataSet" class="org.hisp.dhis.de.action.UndoCompleteDataSetAction">
-      <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-      <param name="requiredAuthorities">F_DATAVALUE_ADD</param>
-    </action>
-
     <action name="getValidationViolations" class="org.hisp.dhis.de.action.ValidationAction">
       <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
       <result name="input" type="velocity-json">../dhis-web-commons/ajax/jsonResponseInput.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-12-22 10:06:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2014-01-23 09:31:23 +0000
@@ -324,10 +324,10 @@
     		markValue( fieldId, COLOR_RED );
     		setHeaderMessage( xhr.responseText );
     	}
-    	else // No connection
+    	else // Offline, keep local value
     	{
+    		markValue( fieldId, resultColor );
     		setHeaderMessage( i18n_offline_notification );
-    		markValue( fieldId, resultColor );
     	}
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-01-22 14:39:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-01-23 09:31:23 +0000
@@ -285,36 +285,36 @@
         log( 'Uploaded complete data set: ' + key + ', with value: ' + value );
 
         $.ajax( {
-            url: 'registerCompleteDataSet.action',
+            url: '../api/completeDataSetRegistrations',
             data: value,
             dataType: 'json',
             success: function( data, textStatus, jqXHR )
             {
-                if ( data.status == 2 )
-                {
-                    log( 'DataSet is locked' );
-                    setHeaderMessage( i18n_register_complete_failed_dataset_is_locked );
-                }
-                else
-                {
-                    log( 'Successfully saved complete dataset with value: ' + value );
-                    dhis2.de.storageManager.clearCompleteDataSet( value );
-                    ( array = array.slice( 1 ) ).length && pushCompleteDataSets( array );
+            	dhis2.de.storageManager.clearCompleteDataSet( value );
+                log( 'Successfully saved complete dataset with value: ' + value );
+                ( array = array.slice( 1 ) ).length && pushCompleteDataSets( array );
 
-                    if ( array.length < 1 )
-                    {
-                        setHeaderDelayMessage( i18n_sync_success );
-                    }
+                if ( array.length < 1 )
+                {
+                    setHeaderDelayMessage( i18n_sync_success );
                 }
             },
             error: function( jqXHR, textStatus, errorThrown )
             {
-                var message = i18n_sync_failed
-                    + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
-                setHeaderMessage( message );
-
-                $( '#sync_button' ).bind( 'click', uploadLocalData );
+            	if ( 409 == xhr.status ) // Invalid value or locked
+            	{
+            		// Ignore value for now TODO needs better handling for locking
+            		
+            		dhis2.de.storageManager.clearCompleteDataSet( value );
+            	}
+            	else // Connection lost during upload
+        		{
+                    var message = i18n_sync_failed
+                        + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
+
+                    setHeaderMessage( message );
+                    $( '#sync_button' ).bind( 'click', uploadLocalData );
+        		}
             }
         } );
     }
@@ -1578,8 +1578,6 @@
 	
 	validate( true, function() {	
 	    var params = dhis2.de.storageManager.getCurrentCompleteDataSetParams();
-        params.organisationUnitId = getCurrentOrganisationUnit();
-        params.multiOrganisationUnit = dhis2.de.multiOrganisationUnit;
 
         var cc = dhis2.de.getCurrentCategoryCombo();
         var cp = dhis2.de.getCurrentCategoryOptionsQueryValue();
@@ -1593,26 +1591,26 @@
         dhis2.de.storageManager.saveCompleteDataSet( params );
 	
 	    $.ajax( {
-	    	url: 'registerCompleteDataSet.action',
+	    	url: '../api/completeDataSetRegistrations',
 	    	data: params,
 	        dataType: 'json',
-	    	success: function(data)
+	        type: 'post',
+	    	success: function( data, textStatus, xhr )
 	        {
-	            if ( data.status == 2 )
-	            {
-	                log( 'Data set is locked' );
-	                setHeaderMessage( i18n_register_complete_failed_dataset_is_locked );
-	            }
-	            else
-	            {
-	                disableCompleteButton();
-	
-	                dhis2.de.storageManager.clearCompleteDataSet( params );
-	            }
+	    		disableCompleteButton();
+	    		dhis2.de.storageManager.clearCompleteDataSet( params );
 	        },
-		    error: function()
+		    error:  function( xhr, textStatus, errorThrown )
 		    {
-		    	disableCompleteButton();
+		    	if ( 409 == xhr.status ) // Invalid value or locked
+	        	{
+	        		setHeaderMessage( xhr.responseText );
+	        	}
+	        	else // Offline, keep local value
+	        	{
+	        		disableCompleteButton();
+	        		setHeaderMessage( i18n_offline_notification );
+	        	}
 		    }
 	    } );
 	} );
@@ -1626,39 +1624,44 @@
 	}
 	
     var params = dhis2.de.storageManager.getCurrentCompleteDataSetParams();
-    params.organisationUnitId = getCurrentOrganisationUnit();
-    params.multiOrganisationUnit = dhis2.de.multiOrganisationUnit;
 
     var cc = dhis2.de.getCurrentCategoryCombo();
     var cp = dhis2.de.getCurrentCategoryOptionsQueryValue();
     
+    var params = 
+    	'?ds=' + params.ds +
+    	'&pe=' + params.pe +
+    	'&ou=' + params.ou + 
+    	'&multiOu=' + params.multiOu;
+
     if ( cc && cp )
     {
-    	params.cc = cc;
-    	params.cp = cp;
+    	params += '&cc=' + cc;
+    	params += '&cp=' + cp;
     }
-    
+        
     $.ajax( {
-    	url: 'undoCompleteDataSet.action',
-    	data: params,
+    	url: '../api/completeDataSetRegistrations' + params,
     	dataType: 'json',
-    	success: function(data)
+    	type: 'delete',
+    	success: function( data, textStatus, xhr )
         {
-            if ( data.status == 2 )
-            {
-                log( 'Data set is locked' );
-                setHeaderMessage( i18n_unregister_complete_failed_dataset_is_locked );
-            }
-            else
-            {
-                disableUndoButton();
-                dhis2.de.storageManager.clearCompleteDataSet( params );
-            }
-
+    		disableUndoButton();
+            dhis2.de.storageManager.clearCompleteDataSet( params );
         },
-        error: function()
+        error: function( xhr, textStatus, errorThrown )
         {
-        	dhis2.de.storageManager.clearCompleteDataSet( params );
+        	if ( 409 == xhr.status ) // Invalid value or locked
+        	{
+        		setHeaderMessage( xhr.responseText );
+        	}
+        	else // Offline, keep local value
+        	{
+        		disableUndoButton();
+        		setHeaderMessage( i18n_offline_notification );
+        	}
+
+    		dhis2.de.storageManager.clearCompleteDataSet( params );
         }
     } );
 }
@@ -1742,8 +1745,6 @@
 	var validCompleteOnly = dhis2.de.dataSets[dhis2.de.currentDataSetId].validCompleteOnly;
 
     var params = dhis2.de.storageManager.getCurrentCompleteDataSetParams();
-	params['organisationUnitId'] = getCurrentOrganisationUnit();
-    params['multiOrganisationUnit'] = dhis2.de.multiOrganisationUnit;
 
     $( '#validationDiv' ).load( 'validate.action', params, function( response, status, xhr ) {
     	var success = null;
@@ -2363,7 +2364,7 @@
      */
     this.getCompleteDataSetId = function( json )
     {
-        return json.periodId + '-' + json.dataSetId + '-' + json.organisationUnitId;
+        return json.ds + '-' + json.pe + '-' + json.ou;
     };
 
     /**
@@ -2374,9 +2375,10 @@
     this.getCurrentCompleteDataSetParams = function()
     {
         var params = {
-            'periodId' : $( '#selectedPeriodId' ).val(),
-            'dataSetId' : $( '#selectedDataSetId' ).val(),
-            'organisationUnitId' : getCurrentOrganisationUnit()
+            'ds': $( '#selectedDataSetId' ).val(),
+            'pe': $( '#selectedPeriodId' ).val(),
+            'ou': getCurrentOrganisationUnit(),
+            'multiOu': dhis2.de.multiOrganisationUnit
         };
 
         return params;