← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20793: minor refactor in AbstractEventService, when updating multiple events, only get current user one ...

 

------------------------------------------------------------
revno: 20793
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-20 15:14:51 +0700
message:
  minor refactor in AbstractEventService, when updating multiple events, only get current user one time and reuse for all updates (we already did this in add events)
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2015-10-09 02:35:38 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2015-10-20 08:14:51 +0000
@@ -606,10 +606,11 @@
     public ImportSummaries updateEvents( List<Event> events, boolean singleValue )
     {
         ImportSummaries importSummaries = new ImportSummaries();
+        User user = currentUserService.getCurrentUser();
 
         for ( Event event : events )
         {
-            importSummaries.addImportSummary( updateEvent( event, singleValue ) );
+            importSummaries.addImportSummary( updateEvent( event, user, singleValue, null ) );
         }
 
         return importSummaries;
@@ -624,6 +625,11 @@
     @Override
     public ImportSummary updateEvent( Event event, boolean singleValue, ImportOptions importOptions )
     {
+        return updateEvent( event, currentUserService.getCurrentUser(), singleValue, importOptions );
+    }
+
+    private ImportSummary updateEvent( Event event, User user, boolean singleValue, ImportOptions importOptions )
+    {
         ImportSummary importSummary = new ImportSummary();
         ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event.getEvent() );
 
@@ -660,7 +666,7 @@
             dueDate = DateUtils.parseDate( event.getDueDate() );
         }
 
-        String storedBy = getStoredBy( event, null, currentUserService.getCurrentUser() );
+        String storedBy = getStoredBy( event, null, user );
 
         if ( event.getStatus() == EventStatus.ACTIVE )
         {
@@ -743,10 +749,7 @@
 
         if ( !singleValue )
         {
-            for ( TrackedEntityDataValue value : dataValues )
-            {
-                dataValueService.deleteTrackedEntityDataValue( value );
-            }
+            dataValues.forEach( dataValueService::deleteTrackedEntityDataValue );
         }
 
         return importSummary;