← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21230: default to current username if no stored by value exists in TEDV

 

------------------------------------------------------------
revno: 21230
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-30 07:55:05 +0700
message:
  default to current username if no stored by value exists in TEDV
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java	2015-11-27 08:43:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java	2015-11-30 00:55:05 +0000
@@ -68,8 +68,13 @@
     @Override
     public void saveTrackedEntityDataValue( TrackedEntityDataValue dataValue )
     {
-        if ( dataValue.getValue() != null )
+        if ( !StringUtils.isEmpty( dataValue.getValue() ) )
         {
+            if ( StringUtils.isEmpty( dataValue.getStoredBy() ) )
+            {
+                dataValue.setStoredBy( currentUserService.getCurrentUsername() );
+            }
+
             dataValueStore.saveVoid( dataValue );
         }
     }
@@ -83,6 +88,11 @@
         }
         else
         {
+            if ( StringUtils.isEmpty( dataValue.getStoredBy() ) )
+            {
+                dataValue.setStoredBy( currentUserService.getCurrentUsername() );
+            }
+
             TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( dataValue, dataValue.getValue(), dataValue.getStoredBy(),
                 new Date(), AuditType.UPDATE );