=== 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 2013-12-14 13:35:23 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2013-12-14 14:14:40 +0000
@@ -48,6 +48,7 @@
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.user.CurrentUserService;
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;
@@ -79,10 +80,12 @@
@Autowired
private DataSetService dataSetService;
-
+
+ @PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@RequestMapping( method = RequestMethod.POST, produces = "text/plain" )
public void saveDataValue( @RequestParam String de, @RequestParam String co,
- @RequestParam String pe, @RequestParam String ou, @RequestParam String value,
+ @RequestParam String pe, @RequestParam String ou,
+ @RequestParam(required=false) String value, @RequestParam(required=false) String comment,
HttpServletResponse response )
{
DataElement dataElement = dataElementService.getDataElement( de );
@@ -123,8 +126,6 @@
return;
}
- value = StringUtils.trimToNull( value );
-
String valid = ValidationUtils.dataValueIsValid( value, dataElement );
if ( valid != null )
@@ -133,6 +134,14 @@
return;
}
+ valid = ValidationUtils.commentIsValid( comment );
+
+ if ( valid != null )
+ {
+ ContextUtils.conflictResponse( response, "Invalid comment: " + comment );
+ return;
+ }
+
String storedBy = currentUserService.getCurrentUsername();
Date now = new Date();
@@ -141,15 +150,32 @@
if ( dataValue == null )
{
+ dataValue = new DataValue( dataElement, period, organisationUnit, null, storedBy, now, null, categoryOptionCombo );
+
if ( value != null )
{
- dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, now, null, categoryOptionCombo );
- dataValueService.addDataValue( dataValue );
- }
+ dataValue.setValue( StringUtils.trimToNull( value ) );
+ }
+
+ if ( comment != null )
+ {
+ dataValue.setComment( StringUtils.trimToNull( comment ) );
+ }
+
+ dataValueService.addDataValue( dataValue );
}
else
{
- dataValue.setValue( value );
+ if ( value != null )
+ {
+ dataValue.setValue( StringUtils.trimToNull( value ) );
+ }
+
+ if ( comment != null )
+ {
+ dataValue.setComment( StringUtils.trimToNull( comment ) );
+ }
+
dataValue.setTimestamp( now );
dataValue.setStoredBy( storedBy );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java 2013-09-27 12:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java 2013-12-14 14:14:40 +0000
@@ -150,9 +150,9 @@
this.periodId = periodId;
}
- private Integer organisationUnitId;
+ private String organisationUnitId;
- public void setOrganisationUnitId( Integer organisationUnitId )
+ public void setOrganisationUnitId( String organisationUnitId )
{
this.organisationUnitId = organisationUnitId;
}
=== 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 2013-12-13 18:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2013-12-14 14:14:40 +0000
@@ -38,10 +38,8 @@
/dhis-web-dataentry/responseVoid.vm
-