=== modified 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 2014-02-03 11:42:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2014-02-11 15:34:53 +0000 @@ -234,4 +234,99 @@ dataValueService.updateDataValue( dataValue ); } } + + @PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_DELETE')" ) + @RequestMapping( method = RequestMethod.DELETE, produces = "text/plain" ) + public void deleteDataValue( + @RequestParam String de, + @RequestParam( required = false ) String co, + @RequestParam( required = false ) String cc, + @RequestParam( required = false ) String cp, + @RequestParam String pe, + @RequestParam String ou, HttpServletResponse response ) + { + // --------------------------------------------------------------------- + // Input validation + // --------------------------------------------------------------------- + + DataElement dataElement = dataElementService.getDataElement( de ); + + if ( dataElement == null ) + { + ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de ); + return; + } + + DataElementCategoryOptionCombo categoryOptionCombo = null; + + if ( co != null ) + { + categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( co ); + } + else + { + categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); + } + + if ( categoryOptionCombo == null ) + { + ContextUtils.conflictResponse( response, "Illegal category option combo identifier: " + co ); + return; + } + + DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp ); + + if ( attributeOptionCombo == null ) + { + 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; + } + + boolean isInHierarchy = organisationUnitService.isInUserHierarchy( organisationUnit ); + + if ( !isInHierarchy ) + { + ContextUtils.conflictResponse( response, "Organisation unit is not in the hierarchy of the current user: " + ou ); + return; + } + + // --------------------------------------------------------------------- + // Locking validation + // --------------------------------------------------------------------- + + if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) ) + { + ContextUtils.conflictResponse( response, "Data set is locked" ); + return; + } + + // --------------------------------------------------------------------- + // Delete data value + // --------------------------------------------------------------------- + + DataValue dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo ); + + if ( dataValue == null ) + { + ContextUtils.conflictResponse( response, "Data value cannot be deleted because it does not exist" ); + return; + } + + dataValueService.deleteDataValue( dataValue ); + } } === 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-23 09:31:23 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2014-02-11 15:34:53 +0000 @@ -37,6 +37,10 @@ F_DATAVALUE_ADD + + F_DATAVALUE_DELETE + + /dhis-web-dataentry/status.vm plainTextError === 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 2014-01-23 15:36:54 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2014-02-11 15:34:53 +0000 @@ -309,11 +309,12 @@ url: '../api/dataValues', data: dataValue, dataType: 'json', + type: 'post', success: handleSuccess, error: handleError } ); }; - + function handleSuccess() { dhis2.de.storageManager.clearDataValueJSON( dataValue ); === 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-24 15:20:17 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2014-02-11 15:34:53 +0000 @@ -344,6 +344,7 @@ url: '../api/dataValues', data: value, dataType: 'json', + type: 'post', success: function( data, textStatus, xhr ) { dhis2.de.storageManager.clearDataValueJSON( value );